babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Animations/runtimeAnimation" {
  6777. import { Animation } from "babylonjs/Animations/animation";
  6778. import { Animatable } from "babylonjs/Animations/animatable";
  6779. import { Scene } from "babylonjs/scene";
  6780. /**
  6781. * Defines a runtime animation
  6782. */
  6783. export class RuntimeAnimation {
  6784. private _events;
  6785. /**
  6786. * The current frame of the runtime animation
  6787. */
  6788. private _currentFrame;
  6789. /**
  6790. * The animation used by the runtime animation
  6791. */
  6792. private _animation;
  6793. /**
  6794. * The target of the runtime animation
  6795. */
  6796. private _target;
  6797. /**
  6798. * The initiating animatable
  6799. */
  6800. private _host;
  6801. /**
  6802. * The original value of the runtime animation
  6803. */
  6804. private _originalValue;
  6805. /**
  6806. * The original blend value of the runtime animation
  6807. */
  6808. private _originalBlendValue;
  6809. /**
  6810. * The offsets cache of the runtime animation
  6811. */
  6812. private _offsetsCache;
  6813. /**
  6814. * The high limits cache of the runtime animation
  6815. */
  6816. private _highLimitsCache;
  6817. /**
  6818. * Specifies if the runtime animation has been stopped
  6819. */
  6820. private _stopped;
  6821. /**
  6822. * The blending factor of the runtime animation
  6823. */
  6824. private _blendingFactor;
  6825. /**
  6826. * The BabylonJS scene
  6827. */
  6828. private _scene;
  6829. /**
  6830. * The current value of the runtime animation
  6831. */
  6832. private _currentValue;
  6833. /** @hidden */
  6834. _workValue: any;
  6835. /**
  6836. * The active target of the runtime animation
  6837. */
  6838. private _activeTarget;
  6839. /**
  6840. * The target path of the runtime animation
  6841. */
  6842. private _targetPath;
  6843. /**
  6844. * The weight of the runtime animation
  6845. */
  6846. private _weight;
  6847. /**
  6848. * The ratio offset of the runtime animation
  6849. */
  6850. private _ratioOffset;
  6851. /**
  6852. * The previous delay of the runtime animation
  6853. */
  6854. private _previousDelay;
  6855. /**
  6856. * The previous ratio of the runtime animation
  6857. */
  6858. private _previousRatio;
  6859. /**
  6860. * Gets the current frame of the runtime animation
  6861. */
  6862. readonly currentFrame: number;
  6863. /**
  6864. * Gets the weight of the runtime animation
  6865. */
  6866. readonly weight: number;
  6867. /**
  6868. * Gets the current value of the runtime animation
  6869. */
  6870. readonly currentValue: any;
  6871. /**
  6872. * Gets the target path of the runtime animation
  6873. */
  6874. readonly targetPath: string;
  6875. /**
  6876. * Gets the actual target of the runtime animation
  6877. */
  6878. readonly target: any;
  6879. /**
  6880. * Create a new RuntimeAnimation object
  6881. * @param target defines the target of the animation
  6882. * @param animation defines the source animation object
  6883. * @param scene defines the hosting scene
  6884. * @param host defines the initiating Animatable
  6885. */
  6886. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6887. /**
  6888. * Gets the animation from the runtime animation
  6889. */
  6890. readonly animation: Animation;
  6891. /**
  6892. * Resets the runtime animation to the beginning
  6893. * @param restoreOriginal defines whether to restore the target property to the original value
  6894. */
  6895. reset(restoreOriginal?: boolean): void;
  6896. /**
  6897. * Specifies if the runtime animation is stopped
  6898. * @returns Boolean specifying if the runtime animation is stopped
  6899. */
  6900. isStopped(): boolean;
  6901. /**
  6902. * Disposes of the runtime animation
  6903. */
  6904. dispose(): void;
  6905. /**
  6906. * Interpolates the animation from the current frame
  6907. * @param currentFrame The frame to interpolate the animation to
  6908. * @param repeatCount The number of times that the animation should loop
  6909. * @param loopMode The type of looping mode to use
  6910. * @param offsetValue Animation offset value
  6911. * @param highLimitValue The high limit value
  6912. * @returns The interpolated value
  6913. */
  6914. private _interpolate;
  6915. /**
  6916. * Apply the interpolated value to the target
  6917. * @param currentValue defines the value computed by the animation
  6918. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6919. */
  6920. setValue(currentValue: any, weight?: number): void;
  6921. private _setValue;
  6922. /**
  6923. * Gets the loop pmode of the runtime animation
  6924. * @returns Loop Mode
  6925. */
  6926. private _getCorrectLoopMode;
  6927. /**
  6928. * Move the current animation to a given frame
  6929. * @param frame defines the frame to move to
  6930. */
  6931. goToFrame(frame: number): void;
  6932. /**
  6933. * @hidden Internal use only
  6934. */
  6935. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6936. /**
  6937. * Execute the current animation
  6938. * @param delay defines the delay to add to the current frame
  6939. * @param from defines the lower bound of the animation range
  6940. * @param to defines the upper bound of the animation range
  6941. * @param loop defines if the current animation must loop
  6942. * @param speedRatio defines the current speed ratio
  6943. * @param weight defines the weight of the animation (default is -1 so no weight)
  6944. * @param onLoop optional callback called when animation loops
  6945. * @returns a boolean indicating if the animation is running
  6946. */
  6947. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6948. }
  6949. }
  6950. declare module "babylonjs/Collisions/intersectionInfo" {
  6951. import { Nullable } from "babylonjs/types";
  6952. /**
  6953. * @hidden
  6954. */
  6955. export class IntersectionInfo {
  6956. bu: Nullable<number>;
  6957. bv: Nullable<number>;
  6958. distance: number;
  6959. faceId: number;
  6960. subMeshId: number;
  6961. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingSphere" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6967. /**
  6968. * Class used to store bounding sphere information
  6969. */
  6970. export class BoundingSphere {
  6971. /**
  6972. * Gets the center of the bounding sphere in local space
  6973. */
  6974. readonly center: Vector3;
  6975. /**
  6976. * Radius of the bounding sphere in local space
  6977. */
  6978. radius: number;
  6979. /**
  6980. * Gets the center of the bounding sphere in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Radius of the bounding sphere in world space
  6985. */
  6986. radiusWorld: number;
  6987. /**
  6988. * Gets the minimum vector in local space
  6989. */
  6990. readonly minimum: Vector3;
  6991. /**
  6992. * Gets the maximum vector in local space
  6993. */
  6994. readonly maximum: Vector3;
  6995. private _worldMatrix;
  6996. private static readonly TmpVector3;
  6997. /**
  6998. * Creates a new bounding sphere
  6999. * @param min defines the minimum vector (in local space)
  7000. * @param max defines the maximum vector (in local space)
  7001. * @param worldMatrix defines the new world matrix
  7002. */
  7003. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7004. /**
  7005. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7006. * @param min defines the new minimum vector (in local space)
  7007. * @param max defines the new maximum vector (in local space)
  7008. * @param worldMatrix defines the new world matrix
  7009. */
  7010. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7011. /**
  7012. * Scale the current bounding sphere by applying a scale factor
  7013. * @param factor defines the scale factor to apply
  7014. * @returns the current bounding box
  7015. */
  7016. scale(factor: number): BoundingSphere;
  7017. /**
  7018. * Gets the world matrix of the bounding box
  7019. * @returns a matrix
  7020. */
  7021. getWorldMatrix(): DeepImmutable<Matrix>;
  7022. /** @hidden */
  7023. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7024. /**
  7025. * Tests if the bounding sphere is intersecting the frustum planes
  7026. * @param frustumPlanes defines the frustum planes to test
  7027. * @returns true if there is an intersection
  7028. */
  7029. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7030. /**
  7031. * Tests if the bounding sphere center is in between the frustum planes.
  7032. * Used for optimistic fast inclusion.
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @returns true if the sphere center is in between the frustum planes
  7035. */
  7036. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if a point is inside the bounding sphere
  7039. * @param point defines the point to test
  7040. * @returns true if the point is inside the bounding sphere
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if two sphere intersct
  7045. * @param sphere0 sphere 0
  7046. * @param sphere1 sphere 1
  7047. * @returns true if the speres intersect
  7048. */
  7049. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7050. }
  7051. }
  7052. declare module "babylonjs/Culling/boundingBox" {
  7053. import { DeepImmutable } from "babylonjs/types";
  7054. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7055. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7056. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7057. /**
  7058. * Class used to store bounding box information
  7059. */
  7060. export class BoundingBox implements ICullable {
  7061. /**
  7062. * Gets the 8 vectors representing the bounding box in local space
  7063. */
  7064. readonly vectors: Vector3[];
  7065. /**
  7066. * Gets the center of the bounding box in local space
  7067. */
  7068. readonly center: Vector3;
  7069. /**
  7070. * Gets the center of the bounding box in world space
  7071. */
  7072. readonly centerWorld: Vector3;
  7073. /**
  7074. * Gets the extend size in local space
  7075. */
  7076. readonly extendSize: Vector3;
  7077. /**
  7078. * Gets the extend size in world space
  7079. */
  7080. readonly extendSizeWorld: Vector3;
  7081. /**
  7082. * Gets the OBB (object bounding box) directions
  7083. */
  7084. readonly directions: Vector3[];
  7085. /**
  7086. * Gets the 8 vectors representing the bounding box in world space
  7087. */
  7088. readonly vectorsWorld: Vector3[];
  7089. /**
  7090. * Gets the minimum vector in world space
  7091. */
  7092. readonly minimumWorld: Vector3;
  7093. /**
  7094. * Gets the maximum vector in world space
  7095. */
  7096. readonly maximumWorld: Vector3;
  7097. /**
  7098. * Gets the minimum vector in local space
  7099. */
  7100. readonly minimum: Vector3;
  7101. /**
  7102. * Gets the maximum vector in local space
  7103. */
  7104. readonly maximum: Vector3;
  7105. private _worldMatrix;
  7106. private static readonly TmpVector3;
  7107. /**
  7108. * @hidden
  7109. */
  7110. _tag: number;
  7111. /**
  7112. * Creates a new bounding box
  7113. * @param min defines the minimum vector (in local space)
  7114. * @param max defines the maximum vector (in local space)
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * Scale the current bounding box by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding box
  7129. */
  7130. scale(factor: number): BoundingBox;
  7131. /**
  7132. * Gets the world matrix of the bounding box
  7133. * @returns a matrix
  7134. */
  7135. getWorldMatrix(): DeepImmutable<Matrix>;
  7136. /** @hidden */
  7137. _update(world: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * Tests if the bounding box is intersecting the frustum planes
  7140. * @param frustumPlanes defines the frustum planes to test
  7141. * @returns true if there is an intersection
  7142. */
  7143. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7144. /**
  7145. * Tests if the bounding box is entirely inside the frustum planes
  7146. * @param frustumPlanes defines the frustum planes to test
  7147. * @returns true if there is an inclusion
  7148. */
  7149. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7150. /**
  7151. * Tests if a point is inside the bounding box
  7152. * @param point defines the point to test
  7153. * @returns true if the point is inside the bounding box
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Tests if the bounding box intersects with a bounding sphere
  7158. * @param sphere defines the sphere to test
  7159. * @returns true if there is an intersection
  7160. */
  7161. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7162. /**
  7163. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7164. * @param min defines the min vector to use
  7165. * @param max defines the max vector to use
  7166. * @returns true if there is an intersection
  7167. */
  7168. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7169. /**
  7170. * Tests if two bounding boxes are intersections
  7171. * @param box0 defines the first box to test
  7172. * @param box1 defines the second box to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7176. /**
  7177. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7178. * @param minPoint defines the minimum vector of the bounding box
  7179. * @param maxPoint defines the maximum vector of the bounding box
  7180. * @param sphereCenter defines the sphere center
  7181. * @param sphereRadius defines the sphere radius
  7182. * @returns true if there is an intersection
  7183. */
  7184. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7185. /**
  7186. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7188. * @param frustumPlanes defines the frustum planes to test
  7189. * @return true if there is an inclusion
  7190. */
  7191. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /**
  7193. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7195. * @param frustumPlanes defines the frustum planes to test
  7196. * @return true if there is an intersection
  7197. */
  7198. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. }
  7200. }
  7201. declare module "babylonjs/Collisions/collider" {
  7202. import { Nullable, IndicesArray } from "babylonjs/types";
  7203. import { Vector3, Plane } from "babylonjs/Maths/math";
  7204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7205. /** @hidden */
  7206. export class Collider {
  7207. /** Define if a collision was found */
  7208. collisionFound: boolean;
  7209. /**
  7210. * Define last intersection point in local space
  7211. */
  7212. intersectionPoint: Vector3;
  7213. /**
  7214. * Define last collided mesh
  7215. */
  7216. collidedMesh: Nullable<AbstractMesh>;
  7217. private _collisionPoint;
  7218. private _planeIntersectionPoint;
  7219. private _tempVector;
  7220. private _tempVector2;
  7221. private _tempVector3;
  7222. private _tempVector4;
  7223. private _edge;
  7224. private _baseToVertex;
  7225. private _destinationPoint;
  7226. private _slidePlaneNormal;
  7227. private _displacementVector;
  7228. /** @hidden */
  7229. _radius: Vector3;
  7230. /** @hidden */
  7231. _retry: number;
  7232. private _velocity;
  7233. private _basePoint;
  7234. private _epsilon;
  7235. /** @hidden */
  7236. _velocityWorldLength: number;
  7237. /** @hidden */
  7238. _basePointWorld: Vector3;
  7239. private _velocityWorld;
  7240. private _normalizedVelocity;
  7241. /** @hidden */
  7242. _initialVelocity: Vector3;
  7243. /** @hidden */
  7244. _initialPosition: Vector3;
  7245. private _nearestDistance;
  7246. private _collisionMask;
  7247. collisionMask: number;
  7248. /**
  7249. * Gets the plane normal used to compute the sliding response (in local space)
  7250. */
  7251. readonly slidePlaneNormal: Vector3;
  7252. /** @hidden */
  7253. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7254. /** @hidden */
  7255. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7256. /** @hidden */
  7257. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7258. /** @hidden */
  7259. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7260. /** @hidden */
  7261. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7262. /** @hidden */
  7263. _getResponse(pos: Vector3, vel: Vector3): void;
  7264. }
  7265. }
  7266. declare module "babylonjs/Culling/boundingInfo" {
  7267. import { DeepImmutable } from "babylonjs/types";
  7268. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7269. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7270. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7271. import { Collider } from "babylonjs/Collisions/collider";
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. readonly minimum: Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. readonly maximum: Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. isLocked: boolean;
  7331. /**
  7332. * Updates the bounding sphere and box
  7333. * @param world world matrix to be used to update
  7334. */
  7335. update(world: DeepImmutable<Matrix>): void;
  7336. /**
  7337. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7338. * @param center New center of the bounding info
  7339. * @param extend New extend of the bounding info
  7340. * @returns the current bounding info
  7341. */
  7342. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7343. /**
  7344. * Scale the current bounding info by applying a scale factor
  7345. * @param factor defines the scale factor to apply
  7346. * @returns the current bounding info
  7347. */
  7348. scale(factor: number): BoundingInfo;
  7349. /**
  7350. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7351. * @param frustumPlanes defines the frustum to test
  7352. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7353. * @returns true if the bounding info is in the frustum planes
  7354. */
  7355. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7356. /**
  7357. * Gets the world distance between the min and max points of the bounding box
  7358. */
  7359. readonly diagonalLength: number;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7367. /** @hidden */
  7368. _checkCollision(collider: Collider): boolean;
  7369. /**
  7370. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7371. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7372. * @param point the point to check intersection with
  7373. * @returns if the point intersects
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7378. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7379. * @param boundingInfo the bounding info to check intersection with
  7380. * @param precise if the intersection should be done using OBB
  7381. * @returns if the bounding info intersects
  7382. */
  7383. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7384. }
  7385. }
  7386. declare module "babylonjs/Misc/smartArray" {
  7387. /**
  7388. * Defines an array and its length.
  7389. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7390. */
  7391. export interface ISmartArrayLike<T> {
  7392. /**
  7393. * The data of the array.
  7394. */
  7395. data: Array<T>;
  7396. /**
  7397. * The active length of the array.
  7398. */
  7399. length: number;
  7400. }
  7401. /**
  7402. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7403. */
  7404. export class SmartArray<T> implements ISmartArrayLike<T> {
  7405. /**
  7406. * The full set of data from the array.
  7407. */
  7408. data: Array<T>;
  7409. /**
  7410. * The active length of the array.
  7411. */
  7412. length: number;
  7413. protected _id: number;
  7414. /**
  7415. * Instantiates a Smart Array.
  7416. * @param capacity defines the default capacity of the array.
  7417. */
  7418. constructor(capacity: number);
  7419. /**
  7420. * Pushes a value at the end of the active data.
  7421. * @param value defines the object to push in the array.
  7422. */
  7423. push(value: T): void;
  7424. /**
  7425. * Iterates over the active data and apply the lambda to them.
  7426. * @param func defines the action to apply on each value.
  7427. */
  7428. forEach(func: (content: T) => void): void;
  7429. /**
  7430. * Sorts the full sets of data.
  7431. * @param compareFn defines the comparison function to apply.
  7432. */
  7433. sort(compareFn: (a: T, b: T) => number): void;
  7434. /**
  7435. * Resets the active data to an empty array.
  7436. */
  7437. reset(): void;
  7438. /**
  7439. * Releases all the data from the array as well as the array.
  7440. */
  7441. dispose(): void;
  7442. /**
  7443. * Concats the active data with a given array.
  7444. * @param array defines the data to concatenate with.
  7445. */
  7446. concat(array: any): void;
  7447. /**
  7448. * Returns the position of a value in the active data.
  7449. * @param value defines the value to find the index for
  7450. * @returns the index if found in the active data otherwise -1
  7451. */
  7452. indexOf(value: T): number;
  7453. /**
  7454. * Returns whether an element is part of the active data.
  7455. * @param value defines the value to look for
  7456. * @returns true if found in the active data otherwise false
  7457. */
  7458. contains(value: T): boolean;
  7459. private static _GlobalId;
  7460. }
  7461. /**
  7462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7463. * The data in this array can only be present once
  7464. */
  7465. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7466. private _duplicateId;
  7467. /**
  7468. * Pushes a value at the end of the active data.
  7469. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7470. * @param value defines the object to push in the array.
  7471. */
  7472. push(value: T): void;
  7473. /**
  7474. * Pushes a value at the end of the active data.
  7475. * If the data is already present, it won t be added again
  7476. * @param value defines the object to push in the array.
  7477. * @returns true if added false if it was already present
  7478. */
  7479. pushNoDuplicate(value: T): boolean;
  7480. /**
  7481. * Resets the active data to an empty array.
  7482. */
  7483. reset(): void;
  7484. /**
  7485. * Concats the active data with a given array.
  7486. * This ensures no dupplicate will be present in the result.
  7487. * @param array defines the data to concatenate with.
  7488. */
  7489. concatWithNoDuplicate(array: any): void;
  7490. }
  7491. }
  7492. declare module "babylonjs/Materials/multiMaterial" {
  7493. import { Nullable } from "babylonjs/types";
  7494. import { Scene } from "babylonjs/scene";
  7495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7496. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7498. import { Material } from "babylonjs/Materials/material";
  7499. /**
  7500. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7501. * separate meshes. This can be use to improve performances.
  7502. * @see http://doc.babylonjs.com/how_to/multi_materials
  7503. */
  7504. export class MultiMaterial extends Material {
  7505. private _subMaterials;
  7506. /**
  7507. * Gets or Sets the list of Materials used within the multi material.
  7508. * They need to be ordered according to the submeshes order in the associated mesh
  7509. */
  7510. subMaterials: Nullable<Material>[];
  7511. /**
  7512. * Function used to align with Node.getChildren()
  7513. * @returns the list of Materials used within the multi material
  7514. */
  7515. getChildren(): Nullable<Material>[];
  7516. /**
  7517. * Instantiates a new Multi Material
  7518. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7519. * separate meshes. This can be use to improve performances.
  7520. * @see http://doc.babylonjs.com/how_to/multi_materials
  7521. * @param name Define the name in the scene
  7522. * @param scene Define the scene the material belongs to
  7523. */
  7524. constructor(name: string, scene: Scene);
  7525. private _hookArray;
  7526. /**
  7527. * Get one of the submaterial by its index in the submaterials array
  7528. * @param index The index to look the sub material at
  7529. * @returns The Material if the index has been defined
  7530. */
  7531. getSubMaterial(index: number): Nullable<Material>;
  7532. /**
  7533. * Get the list of active textures for the whole sub materials list.
  7534. * @returns All the textures that will be used during the rendering
  7535. */
  7536. getActiveTextures(): BaseTexture[];
  7537. /**
  7538. * Gets the current class name of the material e.g. "MultiMaterial"
  7539. * Mainly use in serialization.
  7540. * @returns the class name
  7541. */
  7542. getClassName(): string;
  7543. /**
  7544. * Checks if the material is ready to render the requested sub mesh
  7545. * @param mesh Define the mesh the submesh belongs to
  7546. * @param subMesh Define the sub mesh to look readyness for
  7547. * @param useInstances Define whether or not the material is used with instances
  7548. * @returns true if ready, otherwise false
  7549. */
  7550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7551. /**
  7552. * Clones the current material and its related sub materials
  7553. * @param name Define the name of the newly cloned material
  7554. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7555. * @returns the cloned material
  7556. */
  7557. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7558. /**
  7559. * Serializes the materials into a JSON representation.
  7560. * @returns the JSON representation
  7561. */
  7562. serialize(): any;
  7563. /**
  7564. * Dispose the material and release its associated resources
  7565. * @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)
  7566. * @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)
  7567. * @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)
  7568. */
  7569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7570. /**
  7571. * Creates a MultiMaterial from parsed MultiMaterial data.
  7572. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7573. * @param scene defines the hosting scene
  7574. * @returns a new MultiMaterial
  7575. */
  7576. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7577. }
  7578. }
  7579. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7580. /**
  7581. * Class used to represent data loading progression
  7582. */
  7583. export class SceneLoaderFlags {
  7584. private static _ForceFullSceneLoadingForIncremental;
  7585. private static _ShowLoadingScreen;
  7586. private static _CleanBoneMatrixWeights;
  7587. private static _loggingLevel;
  7588. /**
  7589. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7590. */
  7591. static ForceFullSceneLoadingForIncremental: boolean;
  7592. /**
  7593. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7594. */
  7595. static ShowLoadingScreen: boolean;
  7596. /**
  7597. * Defines the current logging level (while loading the scene)
  7598. * @ignorenaming
  7599. */
  7600. static loggingLevel: number;
  7601. /**
  7602. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7603. */
  7604. static CleanBoneMatrixWeights: boolean;
  7605. }
  7606. }
  7607. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7608. /**
  7609. * Class used to override all child animations of a given target
  7610. */
  7611. export class AnimationPropertiesOverride {
  7612. /**
  7613. * Gets or sets a value indicating if animation blending must be used
  7614. */
  7615. enableBlending: boolean;
  7616. /**
  7617. * Gets or sets the blending speed to use when enableBlending is true
  7618. */
  7619. blendingSpeed: number;
  7620. /**
  7621. * Gets or sets the default loop mode to use
  7622. */
  7623. loopMode: number;
  7624. }
  7625. }
  7626. declare module "babylonjs/Morph/morphTarget" {
  7627. import { IAnimatable } from "babylonjs/Misc/tools";
  7628. import { Observable } from "babylonjs/Misc/observable";
  7629. import { Nullable, FloatArray } from "babylonjs/types";
  7630. import { Scene } from "babylonjs/scene";
  7631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7632. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7633. /**
  7634. * Defines a target to use with MorphTargetManager
  7635. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7636. */
  7637. export class MorphTarget implements IAnimatable {
  7638. /** defines the name of the target */
  7639. name: string;
  7640. /**
  7641. * Gets or sets the list of animations
  7642. */
  7643. animations: import("babylonjs/Animations/animation").Animation[];
  7644. private _scene;
  7645. private _positions;
  7646. private _normals;
  7647. private _tangents;
  7648. private _influence;
  7649. /**
  7650. * Observable raised when the influence changes
  7651. */
  7652. onInfluenceChanged: Observable<boolean>;
  7653. /** @hidden */
  7654. _onDataLayoutChanged: Observable<void>;
  7655. /**
  7656. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7657. */
  7658. influence: number;
  7659. /**
  7660. * Gets or sets the id of the morph Target
  7661. */
  7662. id: string;
  7663. private _animationPropertiesOverride;
  7664. /**
  7665. * Gets or sets the animation properties override
  7666. */
  7667. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7668. /**
  7669. * Creates a new MorphTarget
  7670. * @param name defines the name of the target
  7671. * @param influence defines the influence to use
  7672. * @param scene defines the scene the morphtarget belongs to
  7673. */
  7674. constructor(
  7675. /** defines the name of the target */
  7676. name: string, influence?: number, scene?: Nullable<Scene>);
  7677. /**
  7678. * Gets a boolean defining if the target contains position data
  7679. */
  7680. readonly hasPositions: boolean;
  7681. /**
  7682. * Gets a boolean defining if the target contains normal data
  7683. */
  7684. readonly hasNormals: boolean;
  7685. /**
  7686. * Gets a boolean defining if the target contains tangent data
  7687. */
  7688. readonly hasTangents: boolean;
  7689. /**
  7690. * Affects position data to this target
  7691. * @param data defines the position data to use
  7692. */
  7693. setPositions(data: Nullable<FloatArray>): void;
  7694. /**
  7695. * Gets the position data stored in this target
  7696. * @returns a FloatArray containing the position data (or null if not present)
  7697. */
  7698. getPositions(): Nullable<FloatArray>;
  7699. /**
  7700. * Affects normal data to this target
  7701. * @param data defines the normal data to use
  7702. */
  7703. setNormals(data: Nullable<FloatArray>): void;
  7704. /**
  7705. * Gets the normal data stored in this target
  7706. * @returns a FloatArray containing the normal data (or null if not present)
  7707. */
  7708. getNormals(): Nullable<FloatArray>;
  7709. /**
  7710. * Affects tangent data to this target
  7711. * @param data defines the tangent data to use
  7712. */
  7713. setTangents(data: Nullable<FloatArray>): void;
  7714. /**
  7715. * Gets the tangent data stored in this target
  7716. * @returns a FloatArray containing the tangent data (or null if not present)
  7717. */
  7718. getTangents(): Nullable<FloatArray>;
  7719. /**
  7720. * Serializes the current target into a Serialization object
  7721. * @returns the serialized object
  7722. */
  7723. serialize(): any;
  7724. /**
  7725. * Returns the string "MorphTarget"
  7726. * @returns "MorphTarget"
  7727. */
  7728. getClassName(): string;
  7729. /**
  7730. * Creates a new target from serialized data
  7731. * @param serializationObject defines the serialized data to use
  7732. * @returns a new MorphTarget
  7733. */
  7734. static Parse(serializationObject: any): MorphTarget;
  7735. /**
  7736. * Creates a MorphTarget from mesh data
  7737. * @param mesh defines the source mesh
  7738. * @param name defines the name to use for the new target
  7739. * @param influence defines the influence to attach to the target
  7740. * @returns a new MorphTarget
  7741. */
  7742. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7743. }
  7744. }
  7745. declare module "babylonjs/Morph/morphTargetManager" {
  7746. import { Nullable } from "babylonjs/types";
  7747. import { Scene } from "babylonjs/scene";
  7748. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  7749. /**
  7750. * This class is used to deform meshes using morphing between different targets
  7751. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7752. */
  7753. export class MorphTargetManager {
  7754. private _targets;
  7755. private _targetInfluenceChangedObservers;
  7756. private _targetDataLayoutChangedObservers;
  7757. private _activeTargets;
  7758. private _scene;
  7759. private _influences;
  7760. private _supportsNormals;
  7761. private _supportsTangents;
  7762. private _vertexCount;
  7763. private _uniqueId;
  7764. private _tempInfluences;
  7765. /**
  7766. * Creates a new MorphTargetManager
  7767. * @param scene defines the current scene
  7768. */
  7769. constructor(scene?: Nullable<Scene>);
  7770. /**
  7771. * Gets the unique ID of this manager
  7772. */
  7773. readonly uniqueId: number;
  7774. /**
  7775. * Gets the number of vertices handled by this manager
  7776. */
  7777. readonly vertexCount: number;
  7778. /**
  7779. * Gets a boolean indicating if this manager supports morphing of normals
  7780. */
  7781. readonly supportsNormals: boolean;
  7782. /**
  7783. * Gets a boolean indicating if this manager supports morphing of tangents
  7784. */
  7785. readonly supportsTangents: boolean;
  7786. /**
  7787. * Gets the number of targets stored in this manager
  7788. */
  7789. readonly numTargets: number;
  7790. /**
  7791. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7792. */
  7793. readonly numInfluencers: number;
  7794. /**
  7795. * Gets the list of influences (one per target)
  7796. */
  7797. readonly influences: Float32Array;
  7798. /**
  7799. * Gets the active target at specified index. An active target is a target with an influence > 0
  7800. * @param index defines the index to check
  7801. * @returns the requested target
  7802. */
  7803. getActiveTarget(index: number): MorphTarget;
  7804. /**
  7805. * Gets the target at specified index
  7806. * @param index defines the index to check
  7807. * @returns the requested target
  7808. */
  7809. getTarget(index: number): MorphTarget;
  7810. /**
  7811. * Add a new target to this manager
  7812. * @param target defines the target to add
  7813. */
  7814. addTarget(target: MorphTarget): void;
  7815. /**
  7816. * Removes a target from the manager
  7817. * @param target defines the target to remove
  7818. */
  7819. removeTarget(target: MorphTarget): void;
  7820. /**
  7821. * Serializes the current manager into a Serialization object
  7822. * @returns the serialized object
  7823. */
  7824. serialize(): any;
  7825. private _syncActiveTargets;
  7826. /**
  7827. * Syncrhonize the targets with all the meshes using this morph target manager
  7828. */
  7829. synchronize(): void;
  7830. /**
  7831. * Creates a new MorphTargetManager from serialized data
  7832. * @param serializationObject defines the serialized data
  7833. * @param scene defines the hosting scene
  7834. * @returns the new MorphTargetManager
  7835. */
  7836. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7837. }
  7838. }
  7839. declare module "babylonjs/Meshes/instancedMesh" {
  7840. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  7841. import { Vector3 } from "babylonjs/Maths/math";
  7842. import { Camera } from "babylonjs/Cameras/camera";
  7843. import { Node } from "babylonjs/node";
  7844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7845. import { Mesh } from "babylonjs/Meshes/mesh";
  7846. import { Material } from "babylonjs/Materials/material";
  7847. import { Skeleton } from "babylonjs/Bones/skeleton";
  7848. /**
  7849. * Creates an instance based on a source mesh.
  7850. */
  7851. export class InstancedMesh extends AbstractMesh {
  7852. private _sourceMesh;
  7853. private _currentLOD;
  7854. /** @hidden */
  7855. _indexInSourceMeshInstanceArray: number;
  7856. constructor(name: string, source: Mesh);
  7857. /**
  7858. * Returns the string "InstancedMesh".
  7859. */
  7860. getClassName(): string;
  7861. /**
  7862. * If the source mesh receives shadows
  7863. */
  7864. readonly receiveShadows: boolean;
  7865. /**
  7866. * The material of the source mesh
  7867. */
  7868. readonly material: Nullable<Material>;
  7869. /**
  7870. * Visibility of the source mesh
  7871. */
  7872. readonly visibility: number;
  7873. /**
  7874. * Skeleton of the source mesh
  7875. */
  7876. readonly skeleton: Nullable<Skeleton>;
  7877. /**
  7878. * Rendering ground id of the source mesh
  7879. */
  7880. renderingGroupId: number;
  7881. /**
  7882. * Returns the total number of vertices (integer).
  7883. */
  7884. getTotalVertices(): number;
  7885. /**
  7886. * Returns a positive integer : the total number of indices in this mesh geometry.
  7887. * @returns the numner of indices or zero if the mesh has no geometry.
  7888. */
  7889. getTotalIndices(): number;
  7890. /**
  7891. * The source mesh of the instance
  7892. */
  7893. readonly sourceMesh: Mesh;
  7894. /**
  7895. * Is this node ready to be used/rendered
  7896. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7897. * @return {boolean} is it ready
  7898. */
  7899. isReady(completeCheck?: boolean): boolean;
  7900. /**
  7901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7902. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7903. * @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.
  7904. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7905. */
  7906. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7907. /**
  7908. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7909. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7910. * The `data` are either a numeric array either a Float32Array.
  7911. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7912. * 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).
  7913. * Note that a new underlying VertexBuffer object is created each call.
  7914. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7915. *
  7916. * Possible `kind` values :
  7917. * - VertexBuffer.PositionKind
  7918. * - VertexBuffer.UVKind
  7919. * - VertexBuffer.UV2Kind
  7920. * - VertexBuffer.UV3Kind
  7921. * - VertexBuffer.UV4Kind
  7922. * - VertexBuffer.UV5Kind
  7923. * - VertexBuffer.UV6Kind
  7924. * - VertexBuffer.ColorKind
  7925. * - VertexBuffer.MatricesIndicesKind
  7926. * - VertexBuffer.MatricesIndicesExtraKind
  7927. * - VertexBuffer.MatricesWeightsKind
  7928. * - VertexBuffer.MatricesWeightsExtraKind
  7929. *
  7930. * Returns the Mesh.
  7931. */
  7932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7933. /**
  7934. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7935. * If the mesh has no geometry, it is simply returned as it is.
  7936. * The `data` are either a numeric array either a Float32Array.
  7937. * No new underlying VertexBuffer object is created.
  7938. * 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.
  7939. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7940. *
  7941. * Possible `kind` values :
  7942. * - VertexBuffer.PositionKind
  7943. * - VertexBuffer.UVKind
  7944. * - VertexBuffer.UV2Kind
  7945. * - VertexBuffer.UV3Kind
  7946. * - VertexBuffer.UV4Kind
  7947. * - VertexBuffer.UV5Kind
  7948. * - VertexBuffer.UV6Kind
  7949. * - VertexBuffer.ColorKind
  7950. * - VertexBuffer.MatricesIndicesKind
  7951. * - VertexBuffer.MatricesIndicesExtraKind
  7952. * - VertexBuffer.MatricesWeightsKind
  7953. * - VertexBuffer.MatricesWeightsExtraKind
  7954. *
  7955. * Returns the Mesh.
  7956. */
  7957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7958. /**
  7959. * Sets the mesh indices.
  7960. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7961. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7962. * This method creates a new index buffer each call.
  7963. * Returns the Mesh.
  7964. */
  7965. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7966. /**
  7967. * Boolean : True if the mesh owns the requested kind of data.
  7968. */
  7969. isVerticesDataPresent(kind: string): boolean;
  7970. /**
  7971. * Returns an array of indices (IndicesArray).
  7972. */
  7973. getIndices(): Nullable<IndicesArray>;
  7974. readonly _positions: Nullable<Vector3[]>;
  7975. /**
  7976. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7977. * This means the mesh underlying bounding box and sphere are recomputed.
  7978. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7979. * @returns the current mesh
  7980. */
  7981. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7982. /** @hidden */
  7983. _preActivate(): InstancedMesh;
  7984. /** @hidden */
  7985. _activate(renderId: number): InstancedMesh;
  7986. /**
  7987. * Returns the current associated LOD AbstractMesh.
  7988. */
  7989. getLOD(camera: Camera): AbstractMesh;
  7990. /** @hidden */
  7991. _syncSubMeshes(): InstancedMesh;
  7992. /** @hidden */
  7993. _generatePointsArray(): boolean;
  7994. /**
  7995. * Creates a new InstancedMesh from the current mesh.
  7996. * - name (string) : the cloned mesh name
  7997. * - newParent (optional Node) : the optional Node to parent the clone to.
  7998. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7999. *
  8000. * Returns the clone.
  8001. */
  8002. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  8003. /**
  8004. * Disposes the InstancedMesh.
  8005. * Returns nothing.
  8006. */
  8007. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8008. }
  8009. }
  8010. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8011. import { Nullable } from "babylonjs/types";
  8012. import { Scene } from "babylonjs/scene";
  8013. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8015. /**
  8016. * Class for creating a cube texture
  8017. */
  8018. export class CubeTexture extends BaseTexture {
  8019. private _delayedOnLoad;
  8020. /**
  8021. * The url of the texture
  8022. */
  8023. url: string;
  8024. /**
  8025. * Gets or sets the center of the bounding box associated with the cube texture.
  8026. * It must define where the camera used to render the texture was set
  8027. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8028. */
  8029. boundingBoxPosition: Vector3;
  8030. private _boundingBoxSize;
  8031. /**
  8032. * Gets or sets the size of the bounding box associated with the cube texture
  8033. * When defined, the cubemap will switch to local mode
  8034. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8035. * @example https://www.babylonjs-playground.com/#RNASML
  8036. */
  8037. /**
  8038. * Returns the bounding box size
  8039. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8040. */
  8041. boundingBoxSize: Vector3;
  8042. protected _rotationY: number;
  8043. /**
  8044. * Sets texture matrix rotation angle around Y axis in radians.
  8045. */
  8046. /**
  8047. * Gets texture matrix rotation angle around Y axis radians.
  8048. */
  8049. rotationY: number;
  8050. /**
  8051. * Are mip maps generated for this texture or not.
  8052. */
  8053. readonly noMipmap: boolean;
  8054. private _noMipmap;
  8055. private _files;
  8056. private _extensions;
  8057. private _textureMatrix;
  8058. private _format;
  8059. private _createPolynomials;
  8060. /** @hidden */
  8061. _prefiltered: boolean;
  8062. /**
  8063. * Creates a cube texture from an array of image urls
  8064. * @param files defines an array of image urls
  8065. * @param scene defines the hosting scene
  8066. * @param noMipmap specifies if mip maps are not used
  8067. * @returns a cube texture
  8068. */
  8069. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8070. /**
  8071. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8072. * @param url defines the url of the prefiltered texture
  8073. * @param scene defines the scene the texture is attached to
  8074. * @param forcedExtension defines the extension of the file if different from the url
  8075. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8076. * @return the prefiltered texture
  8077. */
  8078. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8079. /**
  8080. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8081. * as prefiltered data.
  8082. * @param rootUrl defines the url of the texture or the root name of the six images
  8083. * @param scene defines the scene the texture is attached to
  8084. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8085. * @param noMipmap defines if mipmaps should be created or not
  8086. * @param files defines the six files to load for the different faces
  8087. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8088. * @param onError defines a callback triggered in case of error during load
  8089. * @param format defines the internal format to use for the texture once loaded
  8090. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8091. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8092. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8093. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8094. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8095. * @return the cube texture
  8096. */
  8097. 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);
  8098. /**
  8099. * Get the current class name of the texture useful for serialization or dynamic coding.
  8100. * @returns "CubeTexture"
  8101. */
  8102. getClassName(): string;
  8103. /**
  8104. * Update the url (and optional buffer) of this texture if url was null during construction.
  8105. * @param url the url of the texture
  8106. * @param forcedExtension defines the extension to use
  8107. * @param onLoad callback called when the texture is loaded (defaults to null)
  8108. */
  8109. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8110. /**
  8111. * Delays loading of the cube texture
  8112. * @param forcedExtension defines the extension to use
  8113. */
  8114. delayLoad(forcedExtension?: string): void;
  8115. /**
  8116. * Returns the reflection texture matrix
  8117. * @returns the reflection texture matrix
  8118. */
  8119. getReflectionTextureMatrix(): Matrix;
  8120. /**
  8121. * Sets the reflection texture matrix
  8122. * @param value Reflection texture matrix
  8123. */
  8124. setReflectionTextureMatrix(value: Matrix): void;
  8125. /**
  8126. * Parses text to create a cube texture
  8127. * @param parsedTexture define the serialized text to read from
  8128. * @param scene defines the hosting scene
  8129. * @param rootUrl defines the root url of the cube texture
  8130. * @returns a cube texture
  8131. */
  8132. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8133. /**
  8134. * Makes a clone, or deep copy, of the cube texture
  8135. * @returns a new cube texture
  8136. */
  8137. clone(): CubeTexture;
  8138. }
  8139. }
  8140. declare module "babylonjs/Shaders/postprocess.vertex" {
  8141. /** @hidden */
  8142. export var postprocessVertexShader: {
  8143. name: string;
  8144. shader: string;
  8145. };
  8146. }
  8147. declare module "babylonjs/Cameras/targetCamera" {
  8148. import { Nullable } from "babylonjs/types";
  8149. import { Camera } from "babylonjs/Cameras/camera";
  8150. import { Scene } from "babylonjs/scene";
  8151. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8152. /**
  8153. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8154. * This is the base of the follow, arc rotate cameras and Free camera
  8155. * @see http://doc.babylonjs.com/features/cameras
  8156. */
  8157. export class TargetCamera extends Camera {
  8158. private static _RigCamTransformMatrix;
  8159. private static _TargetTransformMatrix;
  8160. private static _TargetFocalPoint;
  8161. /**
  8162. * Define the current direction the camera is moving to
  8163. */
  8164. cameraDirection: Vector3;
  8165. /**
  8166. * Define the current rotation the camera is rotating to
  8167. */
  8168. cameraRotation: Vector2;
  8169. /**
  8170. * When set, the up vector of the camera will be updated by the rotation of the camera
  8171. */
  8172. updateUpVectorFromRotation: boolean;
  8173. private _tmpQuaternion;
  8174. /**
  8175. * Define the current rotation of the camera
  8176. */
  8177. rotation: Vector3;
  8178. /**
  8179. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8180. */
  8181. rotationQuaternion: Quaternion;
  8182. /**
  8183. * Define the current speed of the camera
  8184. */
  8185. speed: number;
  8186. /**
  8187. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8188. * around all axis.
  8189. */
  8190. noRotationConstraint: boolean;
  8191. /**
  8192. * Define the current target of the camera as an object or a position.
  8193. */
  8194. lockedTarget: any;
  8195. /** @hidden */
  8196. _currentTarget: Vector3;
  8197. /** @hidden */
  8198. _initialFocalDistance: number;
  8199. /** @hidden */
  8200. _viewMatrix: Matrix;
  8201. /** @hidden */
  8202. _camMatrix: Matrix;
  8203. /** @hidden */
  8204. _cameraTransformMatrix: Matrix;
  8205. /** @hidden */
  8206. _cameraRotationMatrix: Matrix;
  8207. /** @hidden */
  8208. _referencePoint: Vector3;
  8209. /** @hidden */
  8210. _transformedReferencePoint: Vector3;
  8211. protected _globalCurrentTarget: Vector3;
  8212. protected _globalCurrentUpVector: Vector3;
  8213. /** @hidden */
  8214. _reset: () => void;
  8215. private _defaultUp;
  8216. /**
  8217. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8218. * This is the base of the follow, arc rotate cameras and Free camera
  8219. * @see http://doc.babylonjs.com/features/cameras
  8220. * @param name Defines the name of the camera in the scene
  8221. * @param position Defines the start position of the camera in the scene
  8222. * @param scene Defines the scene the camera belongs to
  8223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8224. */
  8225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8226. /**
  8227. * Gets the position in front of the camera at a given distance.
  8228. * @param distance The distance from the camera we want the position to be
  8229. * @returns the position
  8230. */
  8231. getFrontPosition(distance: number): Vector3;
  8232. /** @hidden */
  8233. _getLockedTargetPosition(): Nullable<Vector3>;
  8234. private _storedPosition;
  8235. private _storedRotation;
  8236. private _storedRotationQuaternion;
  8237. /**
  8238. * Store current camera state of the camera (fov, position, rotation, etc..)
  8239. * @returns the camera
  8240. */
  8241. storeState(): Camera;
  8242. /**
  8243. * Restored camera state. You must call storeState() first
  8244. * @returns whether it was successful or not
  8245. * @hidden
  8246. */
  8247. _restoreStateValues(): boolean;
  8248. /** @hidden */
  8249. _initCache(): void;
  8250. /** @hidden */
  8251. _updateCache(ignoreParentClass?: boolean): void;
  8252. /** @hidden */
  8253. _isSynchronizedViewMatrix(): boolean;
  8254. /** @hidden */
  8255. _computeLocalCameraSpeed(): number;
  8256. /** @hidden */
  8257. setTarget(target: Vector3): void;
  8258. /**
  8259. * Return the current target position of the camera. This value is expressed in local space.
  8260. * @returns the target position
  8261. */
  8262. getTarget(): Vector3;
  8263. /** @hidden */
  8264. _decideIfNeedsToMove(): boolean;
  8265. /** @hidden */
  8266. _updatePosition(): void;
  8267. /** @hidden */
  8268. _checkInputs(): void;
  8269. protected _updateCameraRotationMatrix(): void;
  8270. /**
  8271. * 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)
  8272. * @returns the current camera
  8273. */
  8274. private _rotateUpVectorWithCameraRotationMatrix;
  8275. private _cachedRotationZ;
  8276. private _cachedQuaternionRotationZ;
  8277. /** @hidden */
  8278. _getViewMatrix(): Matrix;
  8279. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8280. /**
  8281. * @hidden
  8282. */
  8283. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8284. /**
  8285. * @hidden
  8286. */
  8287. _updateRigCameras(): void;
  8288. private _getRigCamPositionAndTarget;
  8289. /**
  8290. * Gets the current object class name.
  8291. * @return the class name
  8292. */
  8293. getClassName(): string;
  8294. }
  8295. }
  8296. declare module "babylonjs/Cameras/cameraInputsManager" {
  8297. import { Nullable } from "babylonjs/types";
  8298. import { Camera } from "babylonjs/Cameras/camera";
  8299. /**
  8300. * @ignore
  8301. * This is a list of all the different input types that are available in the application.
  8302. * Fo instance: ArcRotateCameraGamepadInput...
  8303. */
  8304. export var CameraInputTypes: {};
  8305. /**
  8306. * This is the contract to implement in order to create a new input class.
  8307. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8308. */
  8309. export interface ICameraInput<TCamera extends Camera> {
  8310. /**
  8311. * Defines the camera the input is attached to.
  8312. */
  8313. camera: Nullable<TCamera>;
  8314. /**
  8315. * Gets the class name of the current intput.
  8316. * @returns the class name
  8317. */
  8318. getClassName(): string;
  8319. /**
  8320. * Get the friendly name associated with the input class.
  8321. * @returns the input friendly name
  8322. */
  8323. getSimpleName(): string;
  8324. /**
  8325. * Attach the input controls to a specific dom element to get the input from.
  8326. * @param element Defines the element the controls should be listened from
  8327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8328. */
  8329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8330. /**
  8331. * Detach the current controls from the specified dom element.
  8332. * @param element Defines the element to stop listening the inputs from
  8333. */
  8334. detachControl(element: Nullable<HTMLElement>): void;
  8335. /**
  8336. * Update the current camera state depending on the inputs that have been used this frame.
  8337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8338. */
  8339. checkInputs?: () => void;
  8340. }
  8341. /**
  8342. * Represents a map of input types to input instance or input index to input instance.
  8343. */
  8344. export interface CameraInputsMap<TCamera extends Camera> {
  8345. /**
  8346. * Accessor to the input by input type.
  8347. */
  8348. [name: string]: ICameraInput<TCamera>;
  8349. /**
  8350. * Accessor to the input by input index.
  8351. */
  8352. [idx: number]: ICameraInput<TCamera>;
  8353. }
  8354. /**
  8355. * This represents the input manager used within a camera.
  8356. * It helps dealing with all the different kind of input attached to a camera.
  8357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8358. */
  8359. export class CameraInputsManager<TCamera extends Camera> {
  8360. /**
  8361. * Defines the list of inputs attahed to the camera.
  8362. */
  8363. attached: CameraInputsMap<TCamera>;
  8364. /**
  8365. * Defines the dom element the camera is collecting inputs from.
  8366. * This is null if the controls have not been attached.
  8367. */
  8368. attachedElement: Nullable<HTMLElement>;
  8369. /**
  8370. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8371. */
  8372. noPreventDefault: boolean;
  8373. /**
  8374. * Defined the camera the input manager belongs to.
  8375. */
  8376. camera: TCamera;
  8377. /**
  8378. * Update the current camera state depending on the inputs that have been used this frame.
  8379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8380. */
  8381. checkInputs: () => void;
  8382. /**
  8383. * Instantiate a new Camera Input Manager.
  8384. * @param camera Defines the camera the input manager blongs to
  8385. */
  8386. constructor(camera: TCamera);
  8387. /**
  8388. * Add an input method to a camera
  8389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8390. * @param input camera input method
  8391. */
  8392. add(input: ICameraInput<TCamera>): void;
  8393. /**
  8394. * Remove a specific input method from a camera
  8395. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8396. * @param inputToRemove camera input method
  8397. */
  8398. remove(inputToRemove: ICameraInput<TCamera>): void;
  8399. /**
  8400. * Remove a specific input type from a camera
  8401. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8402. * @param inputType the type of the input to remove
  8403. */
  8404. removeByType(inputType: string): void;
  8405. private _addCheckInputs;
  8406. /**
  8407. * Attach the input controls to the currently attached dom element to listen the events from.
  8408. * @param input Defines the input to attach
  8409. */
  8410. attachInput(input: ICameraInput<TCamera>): void;
  8411. /**
  8412. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8413. * @param element Defines the dom element to collect the events from
  8414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8415. */
  8416. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8417. /**
  8418. * Detach the current manager inputs controls from a specific dom element.
  8419. * @param element Defines the dom element to collect the events from
  8420. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8421. */
  8422. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8423. /**
  8424. * Rebuild the dynamic inputCheck function from the current list of
  8425. * defined inputs in the manager.
  8426. */
  8427. rebuildInputCheck(): void;
  8428. /**
  8429. * Remove all attached input methods from a camera
  8430. */
  8431. clear(): void;
  8432. /**
  8433. * Serialize the current input manager attached to a camera.
  8434. * This ensures than once parsed,
  8435. * the input associated to the camera will be identical to the current ones
  8436. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8437. */
  8438. serialize(serializedCamera: any): void;
  8439. /**
  8440. * Parses an input manager serialized JSON to restore the previous list of inputs
  8441. * and states associated to a camera.
  8442. * @param parsedCamera Defines the JSON to parse
  8443. */
  8444. parse(parsedCamera: any): void;
  8445. }
  8446. }
  8447. declare module "babylonjs/Events/keyboardEvents" {
  8448. /**
  8449. * Gather the list of keyboard event types as constants.
  8450. */
  8451. export class KeyboardEventTypes {
  8452. /**
  8453. * The keydown event is fired when a key becomes active (pressed).
  8454. */
  8455. static readonly KEYDOWN: number;
  8456. /**
  8457. * The keyup event is fired when a key has been released.
  8458. */
  8459. static readonly KEYUP: number;
  8460. }
  8461. /**
  8462. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8463. */
  8464. export class KeyboardInfo {
  8465. /**
  8466. * Defines the type of event (KeyboardEventTypes)
  8467. */
  8468. type: number;
  8469. /**
  8470. * Defines the related dom event
  8471. */
  8472. event: KeyboardEvent;
  8473. /**
  8474. * Instantiates a new keyboard info.
  8475. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8476. * @param type Defines the type of event (KeyboardEventTypes)
  8477. * @param event Defines the related dom event
  8478. */
  8479. constructor(
  8480. /**
  8481. * Defines the type of event (KeyboardEventTypes)
  8482. */
  8483. type: number,
  8484. /**
  8485. * Defines the related dom event
  8486. */
  8487. event: KeyboardEvent);
  8488. }
  8489. /**
  8490. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8491. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8492. */
  8493. export class KeyboardInfoPre extends KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8504. */
  8505. skipOnPointerObservable: boolean;
  8506. /**
  8507. * Instantiates a new keyboard pre info.
  8508. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8509. * @param type Defines the type of event (KeyboardEventTypes)
  8510. * @param event Defines the related dom event
  8511. */
  8512. constructor(
  8513. /**
  8514. * Defines the type of event (KeyboardEventTypes)
  8515. */
  8516. type: number,
  8517. /**
  8518. * Defines the related dom event
  8519. */
  8520. event: KeyboardEvent);
  8521. }
  8522. }
  8523. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8524. import { Nullable } from "babylonjs/types";
  8525. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8526. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8527. /**
  8528. * Manage the keyboard inputs to control the movement of a free camera.
  8529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8530. */
  8531. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8532. /**
  8533. * Defines the camera the input is attached to.
  8534. */
  8535. camera: FreeCamera;
  8536. /**
  8537. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8538. */
  8539. keysUp: number[];
  8540. /**
  8541. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8542. */
  8543. keysDown: number[];
  8544. /**
  8545. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8546. */
  8547. keysLeft: number[];
  8548. /**
  8549. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8550. */
  8551. keysRight: number[];
  8552. private _keys;
  8553. private _onCanvasBlurObserver;
  8554. private _onKeyboardObserver;
  8555. private _engine;
  8556. private _scene;
  8557. /**
  8558. * Attach the input controls to a specific dom element to get the input from.
  8559. * @param element Defines the element the controls should be listened from
  8560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8561. */
  8562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8563. /**
  8564. * Detach the current controls from the specified dom element.
  8565. * @param element Defines the element to stop listening the inputs from
  8566. */
  8567. detachControl(element: Nullable<HTMLElement>): void;
  8568. /**
  8569. * Update the current camera state depending on the inputs that have been used this frame.
  8570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8571. */
  8572. checkInputs(): void;
  8573. /**
  8574. * Gets the class name of the current intput.
  8575. * @returns the class name
  8576. */
  8577. getClassName(): string;
  8578. /** @hidden */
  8579. _onLostFocus(): void;
  8580. /**
  8581. * Get the friendly name associated with the input class.
  8582. * @returns the input friendly name
  8583. */
  8584. getSimpleName(): string;
  8585. }
  8586. }
  8587. declare module "babylonjs/Actions/actionEvent" {
  8588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8589. import { Nullable } from "babylonjs/types";
  8590. import { Sprite } from "babylonjs/Sprites/sprite";
  8591. import { Scene } from "babylonjs/scene";
  8592. import { Vector2 } from "babylonjs/Maths/math";
  8593. /**
  8594. * Interface used to define ActionEvent
  8595. */
  8596. export interface IActionEvent {
  8597. /** The mesh or sprite that triggered the action */
  8598. source: any;
  8599. /** The X mouse cursor position at the time of the event */
  8600. pointerX: number;
  8601. /** The Y mouse cursor position at the time of the event */
  8602. pointerY: number;
  8603. /** The mesh that is currently pointed at (can be null) */
  8604. meshUnderPointer: Nullable<AbstractMesh>;
  8605. /** the original (browser) event that triggered the ActionEvent */
  8606. sourceEvent?: any;
  8607. /** additional data for the event */
  8608. additionalData?: any;
  8609. }
  8610. /**
  8611. * ActionEvent is the event being sent when an action is triggered.
  8612. */
  8613. export class ActionEvent implements IActionEvent {
  8614. /** The mesh or sprite that triggered the action */
  8615. source: any;
  8616. /** The X mouse cursor position at the time of the event */
  8617. pointerX: number;
  8618. /** The Y mouse cursor position at the time of the event */
  8619. pointerY: number;
  8620. /** The mesh that is currently pointed at (can be null) */
  8621. meshUnderPointer: Nullable<AbstractMesh>;
  8622. /** the original (browser) event that triggered the ActionEvent */
  8623. sourceEvent?: any;
  8624. /** additional data for the event */
  8625. additionalData?: any;
  8626. /**
  8627. * Creates a new ActionEvent
  8628. * @param source The mesh or sprite that triggered the action
  8629. * @param pointerX The X mouse cursor position at the time of the event
  8630. * @param pointerY The Y mouse cursor position at the time of the event
  8631. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8632. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8633. * @param additionalData additional data for the event
  8634. */
  8635. constructor(
  8636. /** The mesh or sprite that triggered the action */
  8637. source: any,
  8638. /** The X mouse cursor position at the time of the event */
  8639. pointerX: number,
  8640. /** The Y mouse cursor position at the time of the event */
  8641. pointerY: number,
  8642. /** The mesh that is currently pointed at (can be null) */
  8643. meshUnderPointer: Nullable<AbstractMesh>,
  8644. /** the original (browser) event that triggered the ActionEvent */
  8645. sourceEvent?: any,
  8646. /** additional data for the event */
  8647. additionalData?: any);
  8648. /**
  8649. * Helper function to auto-create an ActionEvent from a source mesh.
  8650. * @param source The source mesh that triggered the event
  8651. * @param evt The original (browser) event
  8652. * @param additionalData additional data for the event
  8653. * @returns the new ActionEvent
  8654. */
  8655. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8656. /**
  8657. * Helper function to auto-create an ActionEvent from a source sprite
  8658. * @param source The source sprite that triggered the event
  8659. * @param scene Scene associated with the sprite
  8660. * @param evt The original (browser) event
  8661. * @param additionalData additional data for the event
  8662. * @returns the new ActionEvent
  8663. */
  8664. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8665. /**
  8666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8667. * @param scene the scene where the event occurred
  8668. * @param evt The original (browser) event
  8669. * @returns the new ActionEvent
  8670. */
  8671. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8672. /**
  8673. * Helper function to auto-create an ActionEvent from a primitive
  8674. * @param prim defines the target primitive
  8675. * @param pointerPos defines the pointer position
  8676. * @param evt The original (browser) event
  8677. * @param additionalData additional data for the event
  8678. * @returns the new ActionEvent
  8679. */
  8680. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8681. }
  8682. }
  8683. declare module "babylonjs/Lights/shadowLight" {
  8684. import { Camera } from "babylonjs/Cameras/camera";
  8685. import { Scene } from "babylonjs/scene";
  8686. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8688. import { Light } from "babylonjs/Lights/light";
  8689. /**
  8690. * Interface describing all the common properties and methods a shadow light needs to implement.
  8691. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8692. * as well as binding the different shadow properties to the effects.
  8693. */
  8694. export interface IShadowLight extends Light {
  8695. /**
  8696. * The light id in the scene (used in scene.findLighById for instance)
  8697. */
  8698. id: string;
  8699. /**
  8700. * The position the shdow will be casted from.
  8701. */
  8702. position: Vector3;
  8703. /**
  8704. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8705. */
  8706. direction: Vector3;
  8707. /**
  8708. * The transformed position. Position of the light in world space taking parenting in account.
  8709. */
  8710. transformedPosition: Vector3;
  8711. /**
  8712. * The transformed direction. Direction of the light in world space taking parenting in account.
  8713. */
  8714. transformedDirection: Vector3;
  8715. /**
  8716. * The friendly name of the light in the scene.
  8717. */
  8718. name: string;
  8719. /**
  8720. * Defines the shadow projection clipping minimum z value.
  8721. */
  8722. shadowMinZ: number;
  8723. /**
  8724. * Defines the shadow projection clipping maximum z value.
  8725. */
  8726. shadowMaxZ: number;
  8727. /**
  8728. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8729. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8730. */
  8731. computeTransformedInformation(): boolean;
  8732. /**
  8733. * Gets the scene the light belongs to.
  8734. * @returns The scene
  8735. */
  8736. getScene(): Scene;
  8737. /**
  8738. * Callback defining a custom Projection Matrix Builder.
  8739. * This can be used to override the default projection matrix computation.
  8740. */
  8741. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8742. /**
  8743. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8744. * @param matrix The materix to updated with the projection information
  8745. * @param viewMatrix The transform matrix of the light
  8746. * @param renderList The list of mesh to render in the map
  8747. * @returns The current light
  8748. */
  8749. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8750. /**
  8751. * Gets the current depth scale used in ESM.
  8752. * @returns The scale
  8753. */
  8754. getDepthScale(): number;
  8755. /**
  8756. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8757. * @returns true if a cube texture needs to be use
  8758. */
  8759. needCube(): boolean;
  8760. /**
  8761. * Detects if the projection matrix requires to be recomputed this frame.
  8762. * @returns true if it requires to be recomputed otherwise, false.
  8763. */
  8764. needProjectionMatrixCompute(): boolean;
  8765. /**
  8766. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8767. */
  8768. forceProjectionMatrixCompute(): void;
  8769. /**
  8770. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8771. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8772. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8773. */
  8774. getShadowDirection(faceIndex?: number): Vector3;
  8775. /**
  8776. * Gets the minZ used for shadow according to both the scene and the light.
  8777. * @param activeCamera The camera we are returning the min for
  8778. * @returns the depth min z
  8779. */
  8780. getDepthMinZ(activeCamera: Camera): number;
  8781. /**
  8782. * Gets the maxZ used for shadow according to both the scene and the light.
  8783. * @param activeCamera The camera we are returning the max for
  8784. * @returns the depth max z
  8785. */
  8786. getDepthMaxZ(activeCamera: Camera): number;
  8787. }
  8788. /**
  8789. * Base implementation IShadowLight
  8790. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8791. */
  8792. export abstract class ShadowLight extends Light implements IShadowLight {
  8793. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8794. protected _position: Vector3;
  8795. protected _setPosition(value: Vector3): void;
  8796. /**
  8797. * Sets the position the shadow will be casted from. Also use as the light position for both
  8798. * point and spot lights.
  8799. */
  8800. /**
  8801. * Sets the position the shadow will be casted from. Also use as the light position for both
  8802. * point and spot lights.
  8803. */
  8804. position: Vector3;
  8805. protected _direction: Vector3;
  8806. protected _setDirection(value: Vector3): void;
  8807. /**
  8808. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8809. * Also use as the light direction on spot and directional lights.
  8810. */
  8811. /**
  8812. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8813. * Also use as the light direction on spot and directional lights.
  8814. */
  8815. direction: Vector3;
  8816. private _shadowMinZ;
  8817. /**
  8818. * Gets the shadow projection clipping minimum z value.
  8819. */
  8820. /**
  8821. * Sets the shadow projection clipping minimum z value.
  8822. */
  8823. shadowMinZ: number;
  8824. private _shadowMaxZ;
  8825. /**
  8826. * Sets the shadow projection clipping maximum z value.
  8827. */
  8828. /**
  8829. * Gets the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Callback defining a custom Projection Matrix Builder.
  8834. * This can be used to override the default projection matrix computation.
  8835. */
  8836. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8837. /**
  8838. * The transformed position. Position of the light in world space taking parenting in account.
  8839. */
  8840. transformedPosition: Vector3;
  8841. /**
  8842. * The transformed direction. Direction of the light in world space taking parenting in account.
  8843. */
  8844. transformedDirection: Vector3;
  8845. private _needProjectionMatrixCompute;
  8846. /**
  8847. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8848. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8849. */
  8850. computeTransformedInformation(): boolean;
  8851. /**
  8852. * Return the depth scale used for the shadow map.
  8853. * @returns the depth scale.
  8854. */
  8855. getDepthScale(): number;
  8856. /**
  8857. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8858. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8859. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8860. */
  8861. getShadowDirection(faceIndex?: number): Vector3;
  8862. /**
  8863. * Returns the ShadowLight absolute position in the World.
  8864. * @returns the position vector in world space
  8865. */
  8866. getAbsolutePosition(): Vector3;
  8867. /**
  8868. * Sets the ShadowLight direction toward the passed target.
  8869. * @param target The point tot target in local space
  8870. * @returns the updated ShadowLight direction
  8871. */
  8872. setDirectionToTarget(target: Vector3): Vector3;
  8873. /**
  8874. * Returns the light rotation in euler definition.
  8875. * @returns the x y z rotation in local space.
  8876. */
  8877. getRotation(): Vector3;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /** @hidden */
  8893. _initCache(): void;
  8894. /** @hidden */
  8895. _isSynchronized(): boolean;
  8896. /**
  8897. * Computes the world matrix of the node
  8898. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8899. * @returns the world matrix
  8900. */
  8901. computeWorldMatrix(force?: boolean): Matrix;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. /**
  8915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8916. * @param matrix The materix to updated with the projection information
  8917. * @param viewMatrix The transform matrix of the light
  8918. * @param renderList The list of mesh to render in the map
  8919. * @returns The current light
  8920. */
  8921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8922. }
  8923. }
  8924. declare module "babylonjs/Materials/materialHelper" {
  8925. import { Nullable } from "babylonjs/types";
  8926. import { Scene } from "babylonjs/scene";
  8927. import { Engine } from "babylonjs/Engines/engine";
  8928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8929. import { Light } from "babylonjs/Lights/light";
  8930. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8931. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8933. /**
  8934. * "Static Class" containing the most commonly used helper while dealing with material for
  8935. * rendering purpose.
  8936. *
  8937. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8938. *
  8939. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8940. */
  8941. export class MaterialHelper {
  8942. /**
  8943. * Bind the current view position to an effect.
  8944. * @param effect The effect to be bound
  8945. * @param scene The scene the eyes position is used from
  8946. */
  8947. static BindEyePosition(effect: Effect, scene: Scene): void;
  8948. /**
  8949. * Helps preparing the defines values about the UVs in used in the effect.
  8950. * UVs are shared as much as we can accross channels in the shaders.
  8951. * @param texture The texture we are preparing the UVs for
  8952. * @param defines The defines to update
  8953. * @param key The channel key "diffuse", "specular"... used in the shader
  8954. */
  8955. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8956. /**
  8957. * Binds a texture matrix value to its corrsponding uniform
  8958. * @param texture The texture to bind the matrix for
  8959. * @param uniformBuffer The uniform buffer receivin the data
  8960. * @param key The channel key "diffuse", "specular"... used in the shader
  8961. */
  8962. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8963. /**
  8964. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8965. * @param mesh defines the current mesh
  8966. * @param scene defines the current scene
  8967. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8968. * @param pointsCloud defines if point cloud rendering has to be turned on
  8969. * @param fogEnabled defines if fog has to be turned on
  8970. * @param alphaTest defines if alpha testing has to be turned on
  8971. * @param defines defines the current list of defines
  8972. */
  8973. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8974. /**
  8975. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8976. * @param scene defines the current scene
  8977. * @param engine defines the current engine
  8978. * @param defines specifies the list of active defines
  8979. * @param useInstances defines if instances have to be turned on
  8980. * @param useClipPlane defines if clip plane have to be turned on
  8981. */
  8982. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8983. /**
  8984. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8985. * @param mesh The mesh containing the geometry data we will draw
  8986. * @param defines The defines to update
  8987. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8988. * @param useBones Precise whether bones should be used or not (override mesh info)
  8989. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8990. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8991. * @returns false if defines are considered not dirty and have not been checked
  8992. */
  8993. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8994. /**
  8995. * Prepares the defines related to the light information passed in parameter
  8996. * @param scene The scene we are intending to draw
  8997. * @param mesh The mesh the effect is compiling for
  8998. * @param defines The defines to update
  8999. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9000. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9001. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9002. * @returns true if normals will be required for the rest of the effect
  9003. */
  9004. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9007. * that won t be acctive due to defines being turned off.
  9008. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9009. * @param samplersList The samplers list
  9010. * @param defines The defines helping in the list generation
  9011. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9012. */
  9013. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9014. /**
  9015. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9016. * @param defines The defines to update while falling back
  9017. * @param fallbacks The authorized effect fallbacks
  9018. * @param maxSimultaneousLights The maximum number of lights allowed
  9019. * @param rank the current rank of the Effect
  9020. * @returns The newly affected rank
  9021. */
  9022. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Prepares the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current Defines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9044. /**
  9045. * Binds the light shadow information to the effect for the given mesh.
  9046. * @param light The light containing the generator
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param lightIndex The light index in the effect used to render the mesh
  9050. * @param effect The effect we are binding the data to
  9051. */
  9052. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9053. /**
  9054. * Binds the light information to the effect.
  9055. * @param light The light containing the generator
  9056. * @param effect The effect we are binding the data to
  9057. * @param lightIndex The light index in the effect used to render
  9058. */
  9059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param scene The scene the lights belongs to
  9063. * @param mesh The mesh we are binding the information to render
  9064. * @param effect The effect we are binding the data to
  9065. * @param defines The generated defines for the effect
  9066. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9067. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9068. */
  9069. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9070. private static _tempFogColor;
  9071. /**
  9072. * Binds the fog information from the scene to the effect for the given mesh.
  9073. * @param scene The scene the lights belongs to
  9074. * @param mesh The mesh we are binding the information to render
  9075. * @param effect The effect we are binding the data to
  9076. * @param linearSpace Defines if the fog effect is applied in linear space
  9077. */
  9078. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9079. /**
  9080. * Binds the bones information from the mesh to the effect.
  9081. * @param mesh The mesh we are binding the information to render
  9082. * @param effect The effect we are binding the data to
  9083. */
  9084. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9085. /**
  9086. * Binds the morph targets information from the mesh to the effect.
  9087. * @param abstractMesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. */
  9090. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9091. /**
  9092. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9093. * @param defines The generated defines used in the effect
  9094. * @param effect The effect we are binding the data to
  9095. * @param scene The scene we are willing to render with logarithmic scale for
  9096. */
  9097. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9098. /**
  9099. * Binds the clip plane information from the scene to the effect.
  9100. * @param scene The scene the clip plane information are extracted from
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindClipPlane(effect: Effect, scene: Scene): void;
  9104. }
  9105. }
  9106. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9107. /** @hidden */
  9108. export var kernelBlurVaryingDeclaration: {
  9109. name: string;
  9110. shader: string;
  9111. };
  9112. }
  9113. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9114. /** @hidden */
  9115. export var kernelBlurFragment: {
  9116. name: string;
  9117. shader: string;
  9118. };
  9119. }
  9120. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9121. /** @hidden */
  9122. export var kernelBlurFragment2: {
  9123. name: string;
  9124. shader: string;
  9125. };
  9126. }
  9127. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9128. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9129. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9130. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9131. /** @hidden */
  9132. export var kernelBlurPixelShader: {
  9133. name: string;
  9134. shader: string;
  9135. };
  9136. }
  9137. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9138. /** @hidden */
  9139. export var kernelBlurVertex: {
  9140. name: string;
  9141. shader: string;
  9142. };
  9143. }
  9144. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9145. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9146. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9147. /** @hidden */
  9148. export var kernelBlurVertexShader: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9154. import { Vector2 } from "babylonjs/Maths/math";
  9155. import { Nullable } from "babylonjs/types";
  9156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9157. import { Camera } from "babylonjs/Cameras/camera";
  9158. import { Effect } from "babylonjs/Materials/effect";
  9159. import { Engine } from "babylonjs/Engines/engine";
  9160. import "babylonjs/Shaders/kernelBlur.fragment";
  9161. import "babylonjs/Shaders/kernelBlur.vertex";
  9162. /**
  9163. * The Blur Post Process which blurs an image based on a kernel and direction.
  9164. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9165. */
  9166. export class BlurPostProcess extends PostProcess {
  9167. /** The direction in which to blur the image. */
  9168. direction: Vector2;
  9169. private blockCompilation;
  9170. protected _kernel: number;
  9171. protected _idealKernel: number;
  9172. protected _packedFloat: boolean;
  9173. private _staticDefines;
  9174. /**
  9175. * Sets the length in pixels of the blur sample region
  9176. */
  9177. /**
  9178. * Gets the length in pixels of the blur sample region
  9179. */
  9180. kernel: number;
  9181. /**
  9182. * Sets wether or not the blur needs to unpack/repack floats
  9183. */
  9184. /**
  9185. * Gets wether or not the blur is unpacking/repacking floats
  9186. */
  9187. packedFloat: boolean;
  9188. /**
  9189. * Creates a new instance BlurPostProcess
  9190. * @param name The name of the effect.
  9191. * @param direction The direction in which to blur the image.
  9192. * @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.
  9193. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9194. * @param camera The camera to apply the render pass to.
  9195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9196. * @param engine The engine which the post process will be applied. (default: current engine)
  9197. * @param reusable If the post process can be reused on the same frame. (default: false)
  9198. * @param textureType Type of textures used when performing the post process. (default: 0)
  9199. * @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)
  9200. */
  9201. constructor(name: string,
  9202. /** The direction in which to blur the image. */
  9203. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9204. /**
  9205. * Updates the effect with the current post process compile time values and recompiles the shader.
  9206. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9207. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9208. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9209. * @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
  9210. * @param onCompiled Called when the shader has been compiled.
  9211. * @param onError Called if there is an error when compiling a shader.
  9212. */
  9213. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9214. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9215. /**
  9216. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9217. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9218. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9219. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9220. * The gaps between physical kernels are compensated for in the weighting of the samples
  9221. * @param idealKernel Ideal blur kernel.
  9222. * @return Nearest best kernel.
  9223. */
  9224. protected _nearestBestKernel(idealKernel: number): number;
  9225. /**
  9226. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9227. * @param x The point on the Gaussian distribution to sample.
  9228. * @return the value of the Gaussian function at x.
  9229. */
  9230. protected _gaussianWeight(x: number): number;
  9231. /**
  9232. * Generates a string that can be used as a floating point number in GLSL.
  9233. * @param x Value to print.
  9234. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9235. * @return GLSL float string.
  9236. */
  9237. protected _glslFloat(x: number, decimalFigures?: number): string;
  9238. }
  9239. }
  9240. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9241. /** @hidden */
  9242. export var shadowMapPixelShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9248. /** @hidden */
  9249. export var bonesDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9255. /** @hidden */
  9256. export var morphTargetsVertexGlobalDeclaration: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9262. /** @hidden */
  9263. export var morphTargetsVertexDeclaration: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9269. /** @hidden */
  9270. export var instancesDeclaration: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9276. /** @hidden */
  9277. export var helperFunctions: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9283. /** @hidden */
  9284. export var morphTargetsVertex: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9290. /** @hidden */
  9291. export var instancesVertex: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9297. /** @hidden */
  9298. export var bonesVertex: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9310. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9311. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9312. /** @hidden */
  9313. export var shadowMapVertexShader: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9319. /** @hidden */
  9320. export var depthBoxBlurPixelShader: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9326. import { Nullable } from "babylonjs/types";
  9327. import { Scene } from "babylonjs/scene";
  9328. import { Matrix } from "babylonjs/Maths/math";
  9329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9331. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9332. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9333. import { Effect } from "babylonjs/Materials/effect";
  9334. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9335. import "babylonjs/Shaders/shadowMap.fragment";
  9336. import "babylonjs/Shaders/shadowMap.vertex";
  9337. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9338. import { Observable } from "babylonjs/Misc/observable";
  9339. /**
  9340. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9341. */
  9342. export interface ICustomShaderOptions {
  9343. /**
  9344. * Gets or sets the custom shader name to use
  9345. */
  9346. shaderName: string;
  9347. /**
  9348. * The list of attribute names used in the shader
  9349. */
  9350. attributes?: string[];
  9351. /**
  9352. * The list of unifrom names used in the shader
  9353. */
  9354. uniforms?: string[];
  9355. /**
  9356. * The list of sampler names used in the shader
  9357. */
  9358. samplers?: string[];
  9359. /**
  9360. * The list of defines used in the shader
  9361. */
  9362. defines?: string[];
  9363. }
  9364. /**
  9365. * Interface to implement to create a shadow generator compatible with BJS.
  9366. */
  9367. export interface IShadowGenerator {
  9368. /**
  9369. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9370. * @returns The render target texture if present otherwise, null
  9371. */
  9372. getShadowMap(): Nullable<RenderTargetTexture>;
  9373. /**
  9374. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9375. * @returns The render target texture if the shadow map is present otherwise, null
  9376. */
  9377. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9378. /**
  9379. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9380. * @param subMesh The submesh we want to render in the shadow map
  9381. * @param useInstances Defines wether will draw in the map using instances
  9382. * @returns true if ready otherwise, false
  9383. */
  9384. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9385. /**
  9386. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9387. * @param defines Defines of the material we want to update
  9388. * @param lightIndex Index of the light in the enabled light list of the material
  9389. */
  9390. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9391. /**
  9392. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9393. * defined in the generator but impacting the effect).
  9394. * It implies the unifroms available on the materials are the standard BJS ones.
  9395. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9396. * @param effect The effect we are binfing the information for
  9397. */
  9398. bindShadowLight(lightIndex: string, effect: Effect): void;
  9399. /**
  9400. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9401. * (eq to shadow prjection matrix * light transform matrix)
  9402. * @returns The transform matrix used to create the shadow map
  9403. */
  9404. getTransformMatrix(): Matrix;
  9405. /**
  9406. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9407. * Cube and 2D textures for instance.
  9408. */
  9409. recreateShadowMap(): void;
  9410. /**
  9411. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9412. * @param onCompiled Callback triggered at the and of the effects compilation
  9413. * @param options Sets of optional options forcing the compilation with different modes
  9414. */
  9415. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9416. useInstances: boolean;
  9417. }>): void;
  9418. /**
  9419. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9420. * @param options Sets of optional options forcing the compilation with different modes
  9421. * @returns A promise that resolves when the compilation completes
  9422. */
  9423. forceCompilationAsync(options?: Partial<{
  9424. useInstances: boolean;
  9425. }>): Promise<void>;
  9426. /**
  9427. * Serializes the shadow generator setup to a json object.
  9428. * @returns The serialized JSON object
  9429. */
  9430. serialize(): any;
  9431. /**
  9432. * Disposes the Shadow map and related Textures and effects.
  9433. */
  9434. dispose(): void;
  9435. }
  9436. /**
  9437. * Default implementation IShadowGenerator.
  9438. * This is the main object responsible of generating shadows in the framework.
  9439. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9440. */
  9441. export class ShadowGenerator implements IShadowGenerator {
  9442. /**
  9443. * Shadow generator mode None: no filtering applied.
  9444. */
  9445. static readonly FILTER_NONE: number;
  9446. /**
  9447. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9448. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9449. */
  9450. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9451. /**
  9452. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9453. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9454. */
  9455. static readonly FILTER_POISSONSAMPLING: number;
  9456. /**
  9457. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9458. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9459. */
  9460. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9461. /**
  9462. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9463. * edge artifacts on steep falloff.
  9464. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9465. */
  9466. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9467. /**
  9468. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9469. * edge artifacts on steep falloff.
  9470. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9471. */
  9472. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9473. /**
  9474. * Shadow generator mode PCF: Percentage Closer Filtering
  9475. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9476. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9477. */
  9478. static readonly FILTER_PCF: number;
  9479. /**
  9480. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9481. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9482. * Contact Hardening
  9483. */
  9484. static readonly FILTER_PCSS: number;
  9485. /**
  9486. * Reserved for PCF and PCSS
  9487. * Highest Quality.
  9488. *
  9489. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9490. *
  9491. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9492. */
  9493. static readonly QUALITY_HIGH: number;
  9494. /**
  9495. * Reserved for PCF and PCSS
  9496. * Good tradeoff for quality/perf cross devices
  9497. *
  9498. * Execute PCF on a 3*3 kernel.
  9499. *
  9500. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9501. */
  9502. static readonly QUALITY_MEDIUM: number;
  9503. /**
  9504. * Reserved for PCF and PCSS
  9505. * The lowest quality but the fastest.
  9506. *
  9507. * Execute PCF on a 1*1 kernel.
  9508. *
  9509. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9510. */
  9511. static readonly QUALITY_LOW: number;
  9512. /** Gets or sets the custom shader name to use */
  9513. customShaderOptions: ICustomShaderOptions;
  9514. /**
  9515. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9516. */
  9517. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9518. private _bias;
  9519. /**
  9520. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9521. */
  9522. /**
  9523. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9524. */
  9525. bias: number;
  9526. private _normalBias;
  9527. /**
  9528. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9529. */
  9530. /**
  9531. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9532. */
  9533. normalBias: number;
  9534. private _blurBoxOffset;
  9535. /**
  9536. * Gets the blur box offset: offset applied during the blur pass.
  9537. * Only useful if useKernelBlur = false
  9538. */
  9539. /**
  9540. * Sets the blur box offset: offset applied during the blur pass.
  9541. * Only useful if useKernelBlur = false
  9542. */
  9543. blurBoxOffset: number;
  9544. private _blurScale;
  9545. /**
  9546. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9547. * 2 means half of the size.
  9548. */
  9549. /**
  9550. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9551. * 2 means half of the size.
  9552. */
  9553. blurScale: number;
  9554. private _blurKernel;
  9555. /**
  9556. * Gets the blur kernel: kernel size of the blur pass.
  9557. * Only useful if useKernelBlur = true
  9558. */
  9559. /**
  9560. * Sets the blur kernel: kernel size of the blur pass.
  9561. * Only useful if useKernelBlur = true
  9562. */
  9563. blurKernel: number;
  9564. private _useKernelBlur;
  9565. /**
  9566. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9567. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9568. */
  9569. /**
  9570. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9571. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9572. */
  9573. useKernelBlur: boolean;
  9574. private _depthScale;
  9575. /**
  9576. * Gets the depth scale used in ESM mode.
  9577. */
  9578. /**
  9579. * Sets the depth scale used in ESM mode.
  9580. * This can override the scale stored on the light.
  9581. */
  9582. depthScale: number;
  9583. private _filter;
  9584. /**
  9585. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9586. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9587. */
  9588. /**
  9589. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9591. */
  9592. filter: number;
  9593. /**
  9594. * Gets if the current filter is set to Poisson Sampling.
  9595. */
  9596. /**
  9597. * Sets the current filter to Poisson Sampling.
  9598. */
  9599. usePoissonSampling: boolean;
  9600. /**
  9601. * Gets if the current filter is set to ESM.
  9602. */
  9603. /**
  9604. * Sets the current filter is to ESM.
  9605. */
  9606. useExponentialShadowMap: boolean;
  9607. /**
  9608. * Gets if the current filter is set to filtered ESM.
  9609. */
  9610. /**
  9611. * Gets if the current filter is set to filtered ESM.
  9612. */
  9613. useBlurExponentialShadowMap: boolean;
  9614. /**
  9615. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9616. * exponential to prevent steep falloff artifacts).
  9617. */
  9618. /**
  9619. * Sets the current filter to "close ESM" (using the inverse of the
  9620. * exponential to prevent steep falloff artifacts).
  9621. */
  9622. useCloseExponentialShadowMap: boolean;
  9623. /**
  9624. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9625. * exponential to prevent steep falloff artifacts).
  9626. */
  9627. /**
  9628. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9629. * exponential to prevent steep falloff artifacts).
  9630. */
  9631. useBlurCloseExponentialShadowMap: boolean;
  9632. /**
  9633. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9634. */
  9635. /**
  9636. * Sets the current filter to "PCF" (percentage closer filtering).
  9637. */
  9638. usePercentageCloserFiltering: boolean;
  9639. private _filteringQuality;
  9640. /**
  9641. * Gets the PCF or PCSS Quality.
  9642. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9643. */
  9644. /**
  9645. * Sets the PCF or PCSS Quality.
  9646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9647. */
  9648. filteringQuality: number;
  9649. /**
  9650. * Gets if the current filter is set to "PCSS" (contact hardening).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCSS" (contact hardening).
  9654. */
  9655. useContactHardeningShadow: boolean;
  9656. private _contactHardeningLightSizeUVRatio;
  9657. /**
  9658. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9659. * Using a ratio helps keeping shape stability independently of the map size.
  9660. *
  9661. * It does not account for the light projection as it was having too much
  9662. * instability during the light setup or during light position changes.
  9663. *
  9664. * Only valid if useContactHardeningShadow is true.
  9665. */
  9666. /**
  9667. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9668. * Using a ratio helps keeping shape stability independently of the map size.
  9669. *
  9670. * It does not account for the light projection as it was having too much
  9671. * instability during the light setup or during light position changes.
  9672. *
  9673. * Only valid if useContactHardeningShadow is true.
  9674. */
  9675. contactHardeningLightSizeUVRatio: number;
  9676. private _darkness;
  9677. /**
  9678. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9679. * 0 means strongest and 1 would means no shadow.
  9680. * @returns the darkness.
  9681. */
  9682. getDarkness(): number;
  9683. /**
  9684. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9685. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9686. * @returns the shadow generator allowing fluent coding.
  9687. */
  9688. setDarkness(darkness: number): ShadowGenerator;
  9689. private _transparencyShadow;
  9690. /**
  9691. * Sets the ability to have transparent shadow (boolean).
  9692. * @param transparent True if transparent else False
  9693. * @returns the shadow generator allowing fluent coding
  9694. */
  9695. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9696. private _shadowMap;
  9697. private _shadowMap2;
  9698. /**
  9699. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9700. * @returns The render target texture if present otherwise, null
  9701. */
  9702. getShadowMap(): Nullable<RenderTargetTexture>;
  9703. /**
  9704. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9705. * @returns The render target texture if the shadow map is present otherwise, null
  9706. */
  9707. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9708. /**
  9709. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9710. * @param mesh Mesh to add
  9711. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9712. * @returns the Shadow Generator itself
  9713. */
  9714. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9715. /**
  9716. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9717. * @param mesh Mesh to remove
  9718. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9719. * @returns the Shadow Generator itself
  9720. */
  9721. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9722. /**
  9723. * Controls the extent to which the shadows fade out at the edge of the frustum
  9724. * Used only by directionals and spots
  9725. */
  9726. frustumEdgeFalloff: number;
  9727. private _light;
  9728. /**
  9729. * Returns the associated light object.
  9730. * @returns the light generating the shadow
  9731. */
  9732. getLight(): IShadowLight;
  9733. /**
  9734. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9735. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9736. * It might on the other hand introduce peter panning.
  9737. */
  9738. forceBackFacesOnly: boolean;
  9739. private _scene;
  9740. private _lightDirection;
  9741. private _effect;
  9742. private _viewMatrix;
  9743. private _projectionMatrix;
  9744. private _transformMatrix;
  9745. private _cachedPosition;
  9746. private _cachedDirection;
  9747. private _cachedDefines;
  9748. private _currentRenderID;
  9749. private _boxBlurPostprocess;
  9750. private _kernelBlurXPostprocess;
  9751. private _kernelBlurYPostprocess;
  9752. private _blurPostProcesses;
  9753. private _mapSize;
  9754. private _currentFaceIndex;
  9755. private _currentFaceIndexCache;
  9756. private _textureType;
  9757. private _defaultTextureMatrix;
  9758. /** @hidden */
  9759. static _SceneComponentInitialization: (scene: Scene) => void;
  9760. /**
  9761. * Creates a ShadowGenerator object.
  9762. * A ShadowGenerator is the required tool to use the shadows.
  9763. * Each light casting shadows needs to use its own ShadowGenerator.
  9764. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9765. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9766. * @param light The light object generating the shadows.
  9767. * @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.
  9768. */
  9769. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9770. private _initializeGenerator;
  9771. private _initializeShadowMap;
  9772. private _initializeBlurRTTAndPostProcesses;
  9773. private _renderForShadowMap;
  9774. private _renderSubMeshForShadowMap;
  9775. private _applyFilterValues;
  9776. /**
  9777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9778. * @param onCompiled Callback triggered at the and of the effects compilation
  9779. * @param options Sets of optional options forcing the compilation with different modes
  9780. */
  9781. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9782. useInstances: boolean;
  9783. }>): void;
  9784. /**
  9785. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9786. * @param options Sets of optional options forcing the compilation with different modes
  9787. * @returns A promise that resolves when the compilation completes
  9788. */
  9789. forceCompilationAsync(options?: Partial<{
  9790. useInstances: boolean;
  9791. }>): Promise<void>;
  9792. /**
  9793. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9794. * @param subMesh The submesh we want to render in the shadow map
  9795. * @param useInstances Defines wether will draw in the map using instances
  9796. * @returns true if ready otherwise, false
  9797. */
  9798. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9799. /**
  9800. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9801. * @param defines Defines of the material we want to update
  9802. * @param lightIndex Index of the light in the enabled light list of the material
  9803. */
  9804. prepareDefines(defines: any, lightIndex: number): void;
  9805. /**
  9806. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9807. * defined in the generator but impacting the effect).
  9808. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9809. * @param effect The effect we are binfing the information for
  9810. */
  9811. bindShadowLight(lightIndex: string, effect: Effect): void;
  9812. /**
  9813. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9814. * (eq to shadow prjection matrix * light transform matrix)
  9815. * @returns The transform matrix used to create the shadow map
  9816. */
  9817. getTransformMatrix(): Matrix;
  9818. /**
  9819. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9820. * Cube and 2D textures for instance.
  9821. */
  9822. recreateShadowMap(): void;
  9823. private _disposeBlurPostProcesses;
  9824. private _disposeRTTandPostProcesses;
  9825. /**
  9826. * Disposes the ShadowGenerator.
  9827. * Returns nothing.
  9828. */
  9829. dispose(): void;
  9830. /**
  9831. * Serializes the shadow generator setup to a json object.
  9832. * @returns The serialized JSON object
  9833. */
  9834. serialize(): any;
  9835. /**
  9836. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9837. * @param parsedShadowGenerator The JSON object to parse
  9838. * @param scene The scene to create the shadow map for
  9839. * @returns The parsed shadow generator
  9840. */
  9841. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9842. }
  9843. }
  9844. declare module "babylonjs/Lights/light" {
  9845. import { Nullable } from "babylonjs/types";
  9846. import { Scene } from "babylonjs/scene";
  9847. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9848. import { Node } from "babylonjs/node";
  9849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9850. import { Effect } from "babylonjs/Materials/effect";
  9851. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9852. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9853. /**
  9854. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9855. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9856. * 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.
  9857. */
  9858. export abstract class Light extends Node {
  9859. /**
  9860. * Falloff Default: light is falling off following the material specification:
  9861. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9862. */
  9863. static readonly FALLOFF_DEFAULT: number;
  9864. /**
  9865. * Falloff Physical: light is falling off following the inverse squared distance law.
  9866. */
  9867. static readonly FALLOFF_PHYSICAL: number;
  9868. /**
  9869. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9870. * to enhance interoperability with other engines.
  9871. */
  9872. static readonly FALLOFF_GLTF: number;
  9873. /**
  9874. * Falloff Standard: light is falling off like in the standard material
  9875. * to enhance interoperability with other materials.
  9876. */
  9877. static readonly FALLOFF_STANDARD: number;
  9878. /**
  9879. * If every light affecting the material is in this lightmapMode,
  9880. * material.lightmapTexture adds or multiplies
  9881. * (depends on material.useLightmapAsShadowmap)
  9882. * after every other light calculations.
  9883. */
  9884. static readonly LIGHTMAP_DEFAULT: number;
  9885. /**
  9886. * material.lightmapTexture as only diffuse lighting from this light
  9887. * adds only specular lighting from this light
  9888. * adds dynamic shadows
  9889. */
  9890. static readonly LIGHTMAP_SPECULAR: number;
  9891. /**
  9892. * material.lightmapTexture as only lighting
  9893. * no light calculation from this light
  9894. * only adds dynamic shadows from this light
  9895. */
  9896. static readonly LIGHTMAP_SHADOWSONLY: number;
  9897. /**
  9898. * Each light type uses the default quantity according to its type:
  9899. * point/spot lights use luminous intensity
  9900. * directional lights use illuminance
  9901. */
  9902. static readonly INTENSITYMODE_AUTOMATIC: number;
  9903. /**
  9904. * lumen (lm)
  9905. */
  9906. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9907. /**
  9908. * candela (lm/sr)
  9909. */
  9910. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9911. /**
  9912. * lux (lm/m^2)
  9913. */
  9914. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9915. /**
  9916. * nit (cd/m^2)
  9917. */
  9918. static readonly INTENSITYMODE_LUMINANCE: number;
  9919. /**
  9920. * Light type const id of the point light.
  9921. */
  9922. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9923. /**
  9924. * Light type const id of the directional light.
  9925. */
  9926. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9927. /**
  9928. * Light type const id of the spot light.
  9929. */
  9930. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9931. /**
  9932. * Light type const id of the hemispheric light.
  9933. */
  9934. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9935. /**
  9936. * Diffuse gives the basic color to an object.
  9937. */
  9938. diffuse: Color3;
  9939. /**
  9940. * Specular produces a highlight color on an object.
  9941. * Note: This is note affecting PBR materials.
  9942. */
  9943. specular: Color3;
  9944. /**
  9945. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9946. * falling off base on range or angle.
  9947. * This can be set to any values in Light.FALLOFF_x.
  9948. *
  9949. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9950. * other types of materials.
  9951. */
  9952. falloffType: number;
  9953. /**
  9954. * Strength of the light.
  9955. * Note: By default it is define in the framework own unit.
  9956. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9957. */
  9958. intensity: number;
  9959. private _range;
  9960. protected _inverseSquaredRange: number;
  9961. /**
  9962. * Defines how far from the source the light is impacting in scene units.
  9963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9964. */
  9965. /**
  9966. * Defines how far from the source the light is impacting in scene units.
  9967. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9968. */
  9969. range: number;
  9970. /**
  9971. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9972. * of light.
  9973. */
  9974. private _photometricScale;
  9975. private _intensityMode;
  9976. /**
  9977. * Gets the photometric scale used to interpret the intensity.
  9978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9979. */
  9980. /**
  9981. * Sets the photometric scale used to interpret the intensity.
  9982. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9983. */
  9984. intensityMode: number;
  9985. private _radius;
  9986. /**
  9987. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9988. */
  9989. /**
  9990. * sets the light radius used by PBR Materials to simulate soft area lights.
  9991. */
  9992. radius: number;
  9993. private _renderPriority;
  9994. /**
  9995. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9996. * exceeding the number allowed of the materials.
  9997. */
  9998. renderPriority: number;
  9999. private _shadowEnabled;
  10000. /**
  10001. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10002. * the current shadow generator.
  10003. */
  10004. /**
  10005. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10006. * the current shadow generator.
  10007. */
  10008. shadowEnabled: boolean;
  10009. private _includedOnlyMeshes;
  10010. /**
  10011. * Gets the only meshes impacted by this light.
  10012. */
  10013. /**
  10014. * Sets the only meshes impacted by this light.
  10015. */
  10016. includedOnlyMeshes: AbstractMesh[];
  10017. private _excludedMeshes;
  10018. /**
  10019. * Gets the meshes not impacted by this light.
  10020. */
  10021. /**
  10022. * Sets the meshes not impacted by this light.
  10023. */
  10024. excludedMeshes: AbstractMesh[];
  10025. private _excludeWithLayerMask;
  10026. /**
  10027. * Gets the layer id use to find what meshes are not impacted by the light.
  10028. * Inactive if 0
  10029. */
  10030. /**
  10031. * Sets the layer id use to find what meshes are not impacted by the light.
  10032. * Inactive if 0
  10033. */
  10034. excludeWithLayerMask: number;
  10035. private _includeOnlyWithLayerMask;
  10036. /**
  10037. * Gets the layer id use to find what meshes are impacted by the light.
  10038. * Inactive if 0
  10039. */
  10040. /**
  10041. * Sets the layer id use to find what meshes are impacted by the light.
  10042. * Inactive if 0
  10043. */
  10044. includeOnlyWithLayerMask: number;
  10045. private _lightmapMode;
  10046. /**
  10047. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10048. */
  10049. /**
  10050. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10051. */
  10052. lightmapMode: number;
  10053. /**
  10054. * Shadow generator associted to the light.
  10055. * @hidden Internal use only.
  10056. */
  10057. _shadowGenerator: Nullable<IShadowGenerator>;
  10058. /**
  10059. * @hidden Internal use only.
  10060. */
  10061. _excludedMeshesIds: string[];
  10062. /**
  10063. * @hidden Internal use only.
  10064. */
  10065. _includedOnlyMeshesIds: string[];
  10066. /**
  10067. * The current light unifom buffer.
  10068. * @hidden Internal use only.
  10069. */
  10070. _uniformBuffer: UniformBuffer;
  10071. /**
  10072. * Creates a Light object in the scene.
  10073. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10074. * @param name The firendly name of the light
  10075. * @param scene The scene the light belongs too
  10076. */
  10077. constructor(name: string, scene: Scene);
  10078. protected abstract _buildUniformLayout(): void;
  10079. /**
  10080. * Sets the passed Effect "effect" with the Light information.
  10081. * @param effect The effect to update
  10082. * @param lightIndex The index of the light in the effect to update
  10083. * @returns The light
  10084. */
  10085. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10086. /**
  10087. * Returns the string "Light".
  10088. * @returns the class name
  10089. */
  10090. getClassName(): string;
  10091. /** @hidden */
  10092. readonly _isLight: boolean;
  10093. /**
  10094. * Converts the light information to a readable string for debug purpose.
  10095. * @param fullDetails Supports for multiple levels of logging within scene loading
  10096. * @returns the human readable light info
  10097. */
  10098. toString(fullDetails?: boolean): string;
  10099. /** @hidden */
  10100. protected _syncParentEnabledState(): void;
  10101. /**
  10102. * Set the enabled state of this node.
  10103. * @param value - the new enabled state
  10104. */
  10105. setEnabled(value: boolean): void;
  10106. /**
  10107. * Returns the Light associated shadow generator if any.
  10108. * @return the associated shadow generator.
  10109. */
  10110. getShadowGenerator(): Nullable<IShadowGenerator>;
  10111. /**
  10112. * Returns a Vector3, the absolute light position in the World.
  10113. * @returns the world space position of the light
  10114. */
  10115. getAbsolutePosition(): Vector3;
  10116. /**
  10117. * Specifies if the light will affect the passed mesh.
  10118. * @param mesh The mesh to test against the light
  10119. * @return true the mesh is affected otherwise, false.
  10120. */
  10121. canAffectMesh(mesh: AbstractMesh): boolean;
  10122. /**
  10123. * Sort function to order lights for rendering.
  10124. * @param a First Light object to compare to second.
  10125. * @param b Second Light object to compare first.
  10126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10127. */
  10128. static CompareLightsPriority(a: Light, b: Light): number;
  10129. /**
  10130. * Releases resources associated with this node.
  10131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10133. */
  10134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10135. /**
  10136. * Returns the light type ID (integer).
  10137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10138. */
  10139. getTypeID(): number;
  10140. /**
  10141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10142. * @returns the scaled intensity in intensity mode unit
  10143. */
  10144. getScaledIntensity(): number;
  10145. /**
  10146. * Returns a new Light object, named "name", from the current one.
  10147. * @param name The name of the cloned light
  10148. * @returns the new created light
  10149. */
  10150. clone(name: string): Nullable<Light>;
  10151. /**
  10152. * Serializes the current light into a Serialization object.
  10153. * @returns the serialized object.
  10154. */
  10155. serialize(): any;
  10156. /**
  10157. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10158. * This new light is named "name" and added to the passed scene.
  10159. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10160. * @param name The friendly name of the light
  10161. * @param scene The scene the new light will belong to
  10162. * @returns the constructor function
  10163. */
  10164. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10165. /**
  10166. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10167. * @param parsedLight The JSON representation of the light
  10168. * @param scene The scene to create the parsed light in
  10169. * @returns the created light after parsing
  10170. */
  10171. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10172. private _hookArrayForExcluded;
  10173. private _hookArrayForIncludedOnly;
  10174. private _resyncMeshes;
  10175. /**
  10176. * Forces the meshes to update their light related information in their rendering used effects
  10177. * @hidden Internal Use Only
  10178. */
  10179. _markMeshesAsLightDirty(): void;
  10180. /**
  10181. * Recomputes the cached photometric scale if needed.
  10182. */
  10183. private _computePhotometricScale;
  10184. /**
  10185. * Returns the Photometric Scale according to the light type and intensity mode.
  10186. */
  10187. private _getPhotometricScale;
  10188. /**
  10189. * Reorder the light in the scene according to their defined priority.
  10190. * @hidden Internal Use Only
  10191. */
  10192. _reorderLightsInScene(): void;
  10193. /**
  10194. * Prepares the list of defines specific to the light type.
  10195. * @param defines the list of defines
  10196. * @param lightIndex defines the index of the light for the effect
  10197. */
  10198. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10199. }
  10200. }
  10201. declare module "babylonjs/Actions/action" {
  10202. import { Observable } from "babylonjs/Misc/observable";
  10203. import { Condition } from "babylonjs/Actions/condition";
  10204. import { ActionManager } from "babylonjs/Actions/actionManager";
  10205. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10206. /**
  10207. * Interface used to define Action
  10208. */
  10209. export interface IAction {
  10210. /**
  10211. * Trigger for the action
  10212. */
  10213. trigger: number;
  10214. /** the trigger, with or without parameters, for the action */
  10215. triggerOptions: any;
  10216. /**
  10217. * Gets the trigger parameters
  10218. * @returns the trigger parameters
  10219. */
  10220. getTriggerParameter(): any;
  10221. /**
  10222. * Internal only - executes current action event
  10223. * @hidden
  10224. */
  10225. _executeCurrent(evt?: ActionEvent): void;
  10226. /**
  10227. * Serialize placeholder for child classes
  10228. * @param parent of child
  10229. * @returns the serialized object
  10230. */
  10231. serialize(parent: any): any;
  10232. }
  10233. /**
  10234. * The action to be carried out following a trigger
  10235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10236. */
  10237. export class Action implements IAction {
  10238. /** the trigger, with or without parameters, for the action */
  10239. triggerOptions: any;
  10240. /**
  10241. * Trigger for the action
  10242. */
  10243. trigger: number;
  10244. /**
  10245. * Internal only - manager for action
  10246. * @hidden
  10247. */
  10248. _actionManager: ActionManager;
  10249. private _nextActiveAction;
  10250. private _child;
  10251. private _condition?;
  10252. private _triggerParameter;
  10253. /**
  10254. * An event triggered prior to action being executed.
  10255. */
  10256. onBeforeExecuteObservable: Observable<Action>;
  10257. /**
  10258. * Creates a new Action
  10259. * @param triggerOptions the trigger, with or without parameters, for the action
  10260. * @param condition an optional determinant of action
  10261. */
  10262. constructor(
  10263. /** the trigger, with or without parameters, for the action */
  10264. triggerOptions: any, condition?: Condition);
  10265. /**
  10266. * Internal only
  10267. * @hidden
  10268. */
  10269. _prepare(): void;
  10270. /**
  10271. * Gets the trigger parameters
  10272. * @returns the trigger parameters
  10273. */
  10274. getTriggerParameter(): any;
  10275. /**
  10276. * Internal only - executes current action event
  10277. * @hidden
  10278. */
  10279. _executeCurrent(evt?: ActionEvent): void;
  10280. /**
  10281. * Execute placeholder for child classes
  10282. * @param evt optional action event
  10283. */
  10284. execute(evt?: ActionEvent): void;
  10285. /**
  10286. * Skips to next active action
  10287. */
  10288. skipToNextActiveAction(): void;
  10289. /**
  10290. * Adds action to chain of actions, may be a DoNothingAction
  10291. * @param action defines the next action to execute
  10292. * @returns The action passed in
  10293. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10294. */
  10295. then(action: Action): Action;
  10296. /**
  10297. * Internal only
  10298. * @hidden
  10299. */
  10300. _getProperty(propertyPath: string): string;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. _getEffectiveTarget(target: any, propertyPath: string): any;
  10306. /**
  10307. * Serialize placeholder for child classes
  10308. * @param parent of child
  10309. * @returns the serialized object
  10310. */
  10311. serialize(parent: any): any;
  10312. /**
  10313. * Internal only called by serialize
  10314. * @hidden
  10315. */
  10316. protected _serialize(serializedAction: any, parent?: any): any;
  10317. /**
  10318. * Internal only
  10319. * @hidden
  10320. */
  10321. static _SerializeValueAsString: (value: any) => string;
  10322. /**
  10323. * Internal only
  10324. * @hidden
  10325. */
  10326. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10327. name: string;
  10328. targetType: string;
  10329. value: string;
  10330. };
  10331. }
  10332. }
  10333. declare module "babylonjs/Actions/condition" {
  10334. import { ActionManager } from "babylonjs/Actions/actionManager";
  10335. /**
  10336. * A Condition applied to an Action
  10337. */
  10338. export class Condition {
  10339. /**
  10340. * Internal only - manager for action
  10341. * @hidden
  10342. */
  10343. _actionManager: ActionManager;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _evaluationId: number;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _currentResult: boolean;
  10354. /**
  10355. * Creates a new Condition
  10356. * @param actionManager the manager of the action the condition is applied to
  10357. */
  10358. constructor(actionManager: ActionManager);
  10359. /**
  10360. * Check if the current condition is valid
  10361. * @returns a boolean
  10362. */
  10363. isValid(): boolean;
  10364. /**
  10365. * Internal only
  10366. * @hidden
  10367. */
  10368. _getProperty(propertyPath: string): string;
  10369. /**
  10370. * Internal only
  10371. * @hidden
  10372. */
  10373. _getEffectiveTarget(target: any, propertyPath: string): any;
  10374. /**
  10375. * Serialize placeholder for child classes
  10376. * @returns the serialized object
  10377. */
  10378. serialize(): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. protected _serialize(serializedCondition: any): any;
  10384. }
  10385. /**
  10386. * Defines specific conditional operators as extensions of Condition
  10387. */
  10388. export class ValueCondition extends Condition {
  10389. /** path to specify the property of the target the conditional operator uses */
  10390. propertyPath: string;
  10391. /** the value compared by the conditional operator against the current value of the property */
  10392. value: any;
  10393. /** the conditional operator, default ValueCondition.IsEqual */
  10394. operator: number;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private static _IsEqual;
  10400. /**
  10401. * Internal only
  10402. * @hidden
  10403. */
  10404. private static _IsDifferent;
  10405. /**
  10406. * Internal only
  10407. * @hidden
  10408. */
  10409. private static _IsGreater;
  10410. /**
  10411. * Internal only
  10412. * @hidden
  10413. */
  10414. private static _IsLesser;
  10415. /**
  10416. * returns the number for IsEqual
  10417. */
  10418. static readonly IsEqual: number;
  10419. /**
  10420. * Returns the number for IsDifferent
  10421. */
  10422. static readonly IsDifferent: number;
  10423. /**
  10424. * Returns the number for IsGreater
  10425. */
  10426. static readonly IsGreater: number;
  10427. /**
  10428. * Returns the number for IsLesser
  10429. */
  10430. static readonly IsLesser: number;
  10431. /**
  10432. * Internal only The action manager for the condition
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. private _target;
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. private _effectiveTarget;
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. private _property;
  10451. /**
  10452. * Creates a new ValueCondition
  10453. * @param actionManager manager for the action the condition applies to
  10454. * @param target for the action
  10455. * @param propertyPath path to specify the property of the target the conditional operator uses
  10456. * @param value the value compared by the conditional operator against the current value of the property
  10457. * @param operator the conditional operator, default ValueCondition.IsEqual
  10458. */
  10459. constructor(actionManager: ActionManager, target: any,
  10460. /** path to specify the property of the target the conditional operator uses */
  10461. propertyPath: string,
  10462. /** the value compared by the conditional operator against the current value of the property */
  10463. value: any,
  10464. /** the conditional operator, default ValueCondition.IsEqual */
  10465. operator?: number);
  10466. /**
  10467. * Compares the given value with the property value for the specified conditional operator
  10468. * @returns the result of the comparison
  10469. */
  10470. isValid(): boolean;
  10471. /**
  10472. * Serialize the ValueCondition into a JSON compatible object
  10473. * @returns serialization object
  10474. */
  10475. serialize(): any;
  10476. /**
  10477. * Gets the name of the conditional operator for the ValueCondition
  10478. * @param operator the conditional operator
  10479. * @returns the name
  10480. */
  10481. static GetOperatorName(operator: number): string;
  10482. }
  10483. /**
  10484. * Defines a predicate condition as an extension of Condition
  10485. */
  10486. export class PredicateCondition extends Condition {
  10487. /** defines the predicate function used to validate the condition */
  10488. predicate: () => boolean;
  10489. /**
  10490. * Internal only - manager for action
  10491. * @hidden
  10492. */
  10493. _actionManager: ActionManager;
  10494. /**
  10495. * Creates a new PredicateCondition
  10496. * @param actionManager manager for the action the condition applies to
  10497. * @param predicate defines the predicate function used to validate the condition
  10498. */
  10499. constructor(actionManager: ActionManager,
  10500. /** defines the predicate function used to validate the condition */
  10501. predicate: () => boolean);
  10502. /**
  10503. * @returns the validity of the predicate condition
  10504. */
  10505. isValid(): boolean;
  10506. }
  10507. /**
  10508. * Defines a state condition as an extension of Condition
  10509. */
  10510. export class StateCondition extends Condition {
  10511. /** Value to compare with target state */
  10512. value: string;
  10513. /**
  10514. * Internal only - manager for action
  10515. * @hidden
  10516. */
  10517. _actionManager: ActionManager;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. private _target;
  10523. /**
  10524. * Creates a new StateCondition
  10525. * @param actionManager manager for the action the condition applies to
  10526. * @param target of the condition
  10527. * @param value to compare with target state
  10528. */
  10529. constructor(actionManager: ActionManager, target: any,
  10530. /** Value to compare with target state */
  10531. value: string);
  10532. /**
  10533. * Gets a boolean indicating if the current condition is met
  10534. * @returns the validity of the state
  10535. */
  10536. isValid(): boolean;
  10537. /**
  10538. * Serialize the StateCondition into a JSON compatible object
  10539. * @returns serialization object
  10540. */
  10541. serialize(): any;
  10542. }
  10543. }
  10544. declare module "babylonjs/Actions/directActions" {
  10545. import { Action } from "babylonjs/Actions/action";
  10546. import { Condition } from "babylonjs/Actions/condition";
  10547. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10548. /**
  10549. * This defines an action responsible to toggle a boolean once triggered.
  10550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10551. */
  10552. export class SwitchBooleanAction extends Action {
  10553. /**
  10554. * The path to the boolean property in the target object
  10555. */
  10556. propertyPath: string;
  10557. private _target;
  10558. private _effectiveTarget;
  10559. private _property;
  10560. /**
  10561. * Instantiate the action
  10562. * @param triggerOptions defines the trigger options
  10563. * @param target defines the object containing the boolean
  10564. * @param propertyPath defines the path to the boolean property in the target object
  10565. * @param condition defines the trigger related conditions
  10566. */
  10567. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10568. /** @hidden */
  10569. _prepare(): void;
  10570. /**
  10571. * Execute the action toggle the boolean value.
  10572. */
  10573. execute(): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to set a the state field of the target
  10583. * to a desired value once triggered.
  10584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10585. */
  10586. export class SetStateAction extends Action {
  10587. /**
  10588. * The value to store in the state field.
  10589. */
  10590. value: string;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the state property
  10596. * @param value defines the value to store in the state field
  10597. * @param condition defines the trigger related conditions
  10598. */
  10599. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10600. /**
  10601. * Execute the action and store the value on the target state property.
  10602. */
  10603. execute(): void;
  10604. /**
  10605. * Serializes the actions and its related information.
  10606. * @param parent defines the object to serialize in
  10607. * @returns the serialized object
  10608. */
  10609. serialize(parent: any): any;
  10610. }
  10611. /**
  10612. * This defines an action responsible to set a property of the target
  10613. * to a desired value once triggered.
  10614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10615. */
  10616. export class SetValueAction extends Action {
  10617. /**
  10618. * The path of the property to set in the target.
  10619. */
  10620. propertyPath: string;
  10621. /**
  10622. * The value to set in the property
  10623. */
  10624. value: any;
  10625. private _target;
  10626. private _effectiveTarget;
  10627. private _property;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the object containing the property
  10632. * @param propertyPath defines the path of the property to set in the target
  10633. * @param value defines the value to set in the property
  10634. * @param condition defines the trigger related conditions
  10635. */
  10636. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10637. /** @hidden */
  10638. _prepare(): void;
  10639. /**
  10640. * Execute the action and set the targetted property to the desired value.
  10641. */
  10642. execute(): void;
  10643. /**
  10644. * Serializes the actions and its related information.
  10645. * @param parent defines the object to serialize in
  10646. * @returns the serialized object
  10647. */
  10648. serialize(parent: any): any;
  10649. }
  10650. /**
  10651. * This defines an action responsible to increment the target value
  10652. * to a desired value once triggered.
  10653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10654. */
  10655. export class IncrementValueAction extends Action {
  10656. /**
  10657. * The path of the property to increment in the target.
  10658. */
  10659. propertyPath: string;
  10660. /**
  10661. * The value we should increment the property by.
  10662. */
  10663. value: any;
  10664. private _target;
  10665. private _effectiveTarget;
  10666. private _property;
  10667. /**
  10668. * Instantiate the action
  10669. * @param triggerOptions defines the trigger options
  10670. * @param target defines the object containing the property
  10671. * @param propertyPath defines the path of the property to increment in the target
  10672. * @param value defines the value value we should increment the property by
  10673. * @param condition defines the trigger related conditions
  10674. */
  10675. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10676. /** @hidden */
  10677. _prepare(): void;
  10678. /**
  10679. * Execute the action and increment the target of the value amount.
  10680. */
  10681. execute(): void;
  10682. /**
  10683. * Serializes the actions and its related information.
  10684. * @param parent defines the object to serialize in
  10685. * @returns the serialized object
  10686. */
  10687. serialize(parent: any): any;
  10688. }
  10689. /**
  10690. * This defines an action responsible to start an animation once triggered.
  10691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10692. */
  10693. export class PlayAnimationAction extends Action {
  10694. /**
  10695. * Where the animation should start (animation frame)
  10696. */
  10697. from: number;
  10698. /**
  10699. * Where the animation should stop (animation frame)
  10700. */
  10701. to: number;
  10702. /**
  10703. * Define if the animation should loop or stop after the first play.
  10704. */
  10705. loop?: boolean;
  10706. private _target;
  10707. /**
  10708. * Instantiate the action
  10709. * @param triggerOptions defines the trigger options
  10710. * @param target defines the target animation or animation name
  10711. * @param from defines from where the animation should start (animation frame)
  10712. * @param end defines where the animation should stop (animation frame)
  10713. * @param loop defines if the animation should loop or stop after the first play
  10714. * @param condition defines the trigger related conditions
  10715. */
  10716. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10717. /** @hidden */
  10718. _prepare(): void;
  10719. /**
  10720. * Execute the action and play the animation.
  10721. */
  10722. execute(): void;
  10723. /**
  10724. * Serializes the actions and its related information.
  10725. * @param parent defines the object to serialize in
  10726. * @returns the serialized object
  10727. */
  10728. serialize(parent: any): any;
  10729. }
  10730. /**
  10731. * This defines an action responsible to stop an animation once triggered.
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10733. */
  10734. export class StopAnimationAction extends Action {
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the target animation or animation name
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, target: any, condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and stop the animation.
  10747. */
  10748. execute(): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible that does nothing once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class DoNothingAction extends Action {
  10761. /**
  10762. * Instantiate the action
  10763. * @param triggerOptions defines the trigger options
  10764. * @param condition defines the trigger related conditions
  10765. */
  10766. constructor(triggerOptions?: any, condition?: Condition);
  10767. /**
  10768. * Execute the action and do nothing.
  10769. */
  10770. execute(): void;
  10771. /**
  10772. * Serializes the actions and its related information.
  10773. * @param parent defines the object to serialize in
  10774. * @returns the serialized object
  10775. */
  10776. serialize(parent: any): any;
  10777. }
  10778. /**
  10779. * This defines an action responsible to trigger several actions once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class CombineAction extends Action {
  10783. /**
  10784. * The list of aggregated animations to run.
  10785. */
  10786. children: Action[];
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param children defines the list of aggregated animations to run
  10791. * @param condition defines the trigger related conditions
  10792. */
  10793. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10794. /** @hidden */
  10795. _prepare(): void;
  10796. /**
  10797. * Execute the action and executes all the aggregated actions.
  10798. */
  10799. execute(evt: ActionEvent): void;
  10800. /**
  10801. * Serializes the actions and its related information.
  10802. * @param parent defines the object to serialize in
  10803. * @returns the serialized object
  10804. */
  10805. serialize(parent: any): any;
  10806. }
  10807. /**
  10808. * This defines an action responsible to run code (external event) once triggered.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ExecuteCodeAction extends Action {
  10812. /**
  10813. * The callback function to run.
  10814. */
  10815. func: (evt: ActionEvent) => void;
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param func defines the callback function to run
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10823. /**
  10824. * Execute the action and run the attached code.
  10825. */
  10826. execute(evt: ActionEvent): void;
  10827. }
  10828. /**
  10829. * This defines an action responsible to set the parent property of the target once triggered.
  10830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10831. */
  10832. export class SetParentAction extends Action {
  10833. private _parent;
  10834. private _target;
  10835. /**
  10836. * Instantiate the action
  10837. * @param triggerOptions defines the trigger options
  10838. * @param target defines the target containing the parent property
  10839. * @param parent defines from where the animation should start (animation frame)
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action and set the parent property.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. }
  10857. declare module "babylonjs/Actions/abstractActionManager" {
  10858. import { IDisposable } from "babylonjs/scene";
  10859. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10860. import { IAction } from "babylonjs/Actions/action";
  10861. /**
  10862. * Abstract class used to decouple action Manager from scene and meshes.
  10863. * Do not instantiate.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export abstract class AbstractActionManager implements IDisposable {
  10867. /** Gets the list of active triggers */
  10868. static Triggers: {
  10869. [key: string]: number;
  10870. };
  10871. /** Gets the cursor to use when hovering items */
  10872. hoverCursor: string;
  10873. /** Gets the list of actions */
  10874. actions: IAction[];
  10875. /**
  10876. * Releases all associated resources
  10877. */
  10878. abstract dispose(): void;
  10879. /**
  10880. * Does this action manager has pointer triggers
  10881. */
  10882. abstract readonly hasPointerTriggers: boolean;
  10883. /**
  10884. * Does this action manager has pick triggers
  10885. */
  10886. abstract readonly hasPickTriggers: boolean;
  10887. /**
  10888. * Process a specific trigger
  10889. * @param trigger defines the trigger to process
  10890. * @param evt defines the event details to be processed
  10891. */
  10892. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10893. /**
  10894. * Does this action manager handles actions of any of the given triggers
  10895. * @param triggers defines the triggers to be tested
  10896. * @return a boolean indicating whether one (or more) of the triggers is handled
  10897. */
  10898. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10899. /**
  10900. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10901. * speed.
  10902. * @param triggerA defines the trigger to be tested
  10903. * @param triggerB defines the trigger to be tested
  10904. * @return a boolean indicating whether one (or more) of the triggers is handled
  10905. */
  10906. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10907. /**
  10908. * Does this action manager handles actions of a given trigger
  10909. * @param trigger defines the trigger to be tested
  10910. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10911. * @return whether the trigger is handled
  10912. */
  10913. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10914. /**
  10915. * Serialize this manager to a JSON object
  10916. * @param name defines the property name to store this manager
  10917. * @returns a JSON representation of this manager
  10918. */
  10919. abstract serialize(name: string): any;
  10920. /**
  10921. * Does exist one action manager with at least one trigger
  10922. **/
  10923. static readonly HasTriggers: boolean;
  10924. /**
  10925. * Does exist one action manager with at least one pick trigger
  10926. **/
  10927. static readonly HasPickTriggers: boolean;
  10928. /**
  10929. * Does exist one action manager that handles actions of a given trigger
  10930. * @param trigger defines the trigger to be tested
  10931. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10932. **/
  10933. static HasSpecificTrigger(trigger: number): boolean;
  10934. }
  10935. }
  10936. declare module "babylonjs/Actions/actionManager" {
  10937. import { Nullable } from "babylonjs/types";
  10938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Action } from "babylonjs/Actions/action";
  10941. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10942. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10943. /**
  10944. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10945. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class ActionManager extends AbstractActionManager {
  10949. /**
  10950. * Nothing
  10951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10952. */
  10953. static readonly NothingTrigger: number;
  10954. /**
  10955. * On pick
  10956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10957. */
  10958. static readonly OnPickTrigger: number;
  10959. /**
  10960. * On left pick
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10962. */
  10963. static readonly OnLeftPickTrigger: number;
  10964. /**
  10965. * On right pick
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10967. */
  10968. static readonly OnRightPickTrigger: number;
  10969. /**
  10970. * On center pick
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10972. */
  10973. static readonly OnCenterPickTrigger: number;
  10974. /**
  10975. * On pick down
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10977. */
  10978. static readonly OnPickDownTrigger: number;
  10979. /**
  10980. * On double pick
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10982. */
  10983. static readonly OnDoublePickTrigger: number;
  10984. /**
  10985. * On pick up
  10986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10987. */
  10988. static readonly OnPickUpTrigger: number;
  10989. /**
  10990. * On pick out.
  10991. * This trigger will only be raised if you also declared a OnPickDown
  10992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10993. */
  10994. static readonly OnPickOutTrigger: number;
  10995. /**
  10996. * On long press
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10998. */
  10999. static readonly OnLongPressTrigger: number;
  11000. /**
  11001. * On pointer over
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11003. */
  11004. static readonly OnPointerOverTrigger: number;
  11005. /**
  11006. * On pointer out
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11008. */
  11009. static readonly OnPointerOutTrigger: number;
  11010. /**
  11011. * On every frame
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11013. */
  11014. static readonly OnEveryFrameTrigger: number;
  11015. /**
  11016. * On intersection enter
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnIntersectionEnterTrigger: number;
  11020. /**
  11021. * On intersection exit
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11023. */
  11024. static readonly OnIntersectionExitTrigger: number;
  11025. /**
  11026. * On key down
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11028. */
  11029. static readonly OnKeyDownTrigger: number;
  11030. /**
  11031. * On key up
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly OnKeyUpTrigger: number;
  11035. private _scene;
  11036. /**
  11037. * Creates a new action manager
  11038. * @param scene defines the hosting scene
  11039. */
  11040. constructor(scene: Scene);
  11041. /**
  11042. * Releases all associated resources
  11043. */
  11044. dispose(): void;
  11045. /**
  11046. * Gets hosting scene
  11047. * @returns the hosting scene
  11048. */
  11049. getScene(): Scene;
  11050. /**
  11051. * Does this action manager handles actions of any of the given triggers
  11052. * @param triggers defines the triggers to be tested
  11053. * @return a boolean indicating whether one (or more) of the triggers is handled
  11054. */
  11055. hasSpecificTriggers(triggers: number[]): boolean;
  11056. /**
  11057. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11058. * speed.
  11059. * @param triggerA defines the trigger to be tested
  11060. * @param triggerB defines the trigger to be tested
  11061. * @return a boolean indicating whether one (or more) of the triggers is handled
  11062. */
  11063. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11064. /**
  11065. * Does this action manager handles actions of a given trigger
  11066. * @param trigger defines the trigger to be tested
  11067. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11068. * @return whether the trigger is handled
  11069. */
  11070. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11071. /**
  11072. * Does this action manager has pointer triggers
  11073. */
  11074. readonly hasPointerTriggers: boolean;
  11075. /**
  11076. * Does this action manager has pick triggers
  11077. */
  11078. readonly hasPickTriggers: boolean;
  11079. /**
  11080. * Registers an action to this action manager
  11081. * @param action defines the action to be registered
  11082. * @return the action amended (prepared) after registration
  11083. */
  11084. registerAction(action: Action): Nullable<Action>;
  11085. /**
  11086. * Unregisters an action to this action manager
  11087. * @param action defines the action to be unregistered
  11088. * @return a boolean indicating whether the action has been unregistered
  11089. */
  11090. unregisterAction(action: Action): Boolean;
  11091. /**
  11092. * Process a specific trigger
  11093. * @param trigger defines the trigger to process
  11094. * @param evt defines the event details to be processed
  11095. */
  11096. processTrigger(trigger: number, evt?: IActionEvent): void;
  11097. /** @hidden */
  11098. _getEffectiveTarget(target: any, propertyPath: string): any;
  11099. /** @hidden */
  11100. _getProperty(propertyPath: string): string;
  11101. /**
  11102. * Serialize this manager to a JSON object
  11103. * @param name defines the property name to store this manager
  11104. * @returns a JSON representation of this manager
  11105. */
  11106. serialize(name: string): any;
  11107. /**
  11108. * Creates a new ActionManager from a JSON data
  11109. * @param parsedActions defines the JSON data to read from
  11110. * @param object defines the hosting mesh
  11111. * @param scene defines the hosting scene
  11112. */
  11113. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11114. /**
  11115. * Get a trigger name by index
  11116. * @param trigger defines the trigger index
  11117. * @returns a trigger name
  11118. */
  11119. static GetTriggerName(trigger: number): string;
  11120. }
  11121. }
  11122. declare module "babylonjs/Culling/ray" {
  11123. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11124. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11126. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11127. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11128. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11129. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11130. /**
  11131. * Class representing a ray with position and direction
  11132. */
  11133. export class Ray {
  11134. /** origin point */
  11135. origin: Vector3;
  11136. /** direction */
  11137. direction: Vector3;
  11138. /** length of the ray */
  11139. length: number;
  11140. private static readonly TmpVector3;
  11141. private _tmpRay;
  11142. /**
  11143. * Creates a new ray
  11144. * @param origin origin point
  11145. * @param direction direction
  11146. * @param length length of the ray
  11147. */
  11148. constructor(
  11149. /** origin point */
  11150. origin: Vector3,
  11151. /** direction */
  11152. direction: Vector3,
  11153. /** length of the ray */
  11154. length?: number);
  11155. /**
  11156. * Checks if the ray intersects a box
  11157. * @param minimum bound of the box
  11158. * @param maximum bound of the box
  11159. * @param intersectionTreshold extra extend to be added to the box in all direction
  11160. * @returns if the box was hit
  11161. */
  11162. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11163. /**
  11164. * Checks if the ray intersects a box
  11165. * @param box the bounding box to check
  11166. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11167. * @returns if the box was hit
  11168. */
  11169. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11170. /**
  11171. * If the ray hits a sphere
  11172. * @param sphere the bounding sphere to check
  11173. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11174. * @returns true if it hits the sphere
  11175. */
  11176. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11177. /**
  11178. * If the ray hits a triange
  11179. * @param vertex0 triangle vertex
  11180. * @param vertex1 triangle vertex
  11181. * @param vertex2 triangle vertex
  11182. * @returns intersection information if hit
  11183. */
  11184. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11185. /**
  11186. * Checks if ray intersects a plane
  11187. * @param plane the plane to check
  11188. * @returns the distance away it was hit
  11189. */
  11190. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11191. /**
  11192. * Checks if ray intersects a mesh
  11193. * @param mesh the mesh to check
  11194. * @param fastCheck if only the bounding box should checked
  11195. * @returns picking info of the intersecton
  11196. */
  11197. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11198. /**
  11199. * Checks if ray intersects a mesh
  11200. * @param meshes the meshes to check
  11201. * @param fastCheck if only the bounding box should checked
  11202. * @param results array to store result in
  11203. * @returns Array of picking infos
  11204. */
  11205. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11206. private _comparePickingInfo;
  11207. private static smallnum;
  11208. private static rayl;
  11209. /**
  11210. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11211. * @param sega the first point of the segment to test the intersection against
  11212. * @param segb the second point of the segment to test the intersection against
  11213. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11214. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11215. */
  11216. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11217. /**
  11218. * Update the ray from viewport position
  11219. * @param x position
  11220. * @param y y position
  11221. * @param viewportWidth viewport width
  11222. * @param viewportHeight viewport height
  11223. * @param world world matrix
  11224. * @param view view matrix
  11225. * @param projection projection matrix
  11226. * @returns this ray updated
  11227. */
  11228. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11229. /**
  11230. * Creates a ray with origin and direction of 0,0,0
  11231. * @returns the new ray
  11232. */
  11233. static Zero(): Ray;
  11234. /**
  11235. * Creates a new ray from screen space and viewport
  11236. * @param x position
  11237. * @param y y position
  11238. * @param viewportWidth viewport width
  11239. * @param viewportHeight viewport height
  11240. * @param world world matrix
  11241. * @param view view matrix
  11242. * @param projection projection matrix
  11243. * @returns new ray
  11244. */
  11245. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * 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
  11248. * transformed to the given world matrix.
  11249. * @param origin The origin point
  11250. * @param end The end point
  11251. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11252. * @returns the new ray
  11253. */
  11254. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11255. /**
  11256. * Transforms a ray by a matrix
  11257. * @param ray ray to transform
  11258. * @param matrix matrix to apply
  11259. * @returns the resulting new ray
  11260. */
  11261. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11262. /**
  11263. * Transforms a ray by a matrix
  11264. * @param ray ray to transform
  11265. * @param matrix matrix to apply
  11266. * @param result ray to store result in
  11267. */
  11268. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11269. /**
  11270. * Unproject a ray from screen space to object space
  11271. * @param sourceX defines the screen space x coordinate to use
  11272. * @param sourceY defines the screen space y coordinate to use
  11273. * @param viewportWidth defines the current width of the viewport
  11274. * @param viewportHeight defines the current height of the viewport
  11275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11276. * @param view defines the view matrix to use
  11277. * @param projection defines the projection matrix to use
  11278. */
  11279. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11280. }
  11281. module "babylonjs/scene" {
  11282. interface Scene {
  11283. /** @hidden */
  11284. _tempPickingRay: Nullable<Ray>;
  11285. /** @hidden */
  11286. _cachedRayForTransform: Ray;
  11287. /** @hidden */
  11288. _pickWithRayInverseMatrix: Matrix;
  11289. /** @hidden */
  11290. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11291. /** @hidden */
  11292. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11293. }
  11294. }
  11295. }
  11296. declare module "babylonjs/sceneComponent" {
  11297. import { Scene } from "babylonjs/scene";
  11298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11300. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11301. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11302. import { Nullable } from "babylonjs/types";
  11303. import { Camera } from "babylonjs/Cameras/camera";
  11304. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11306. import { AbstractScene } from "babylonjs/abstractScene";
  11307. /**
  11308. * Groups all the scene component constants in one place to ease maintenance.
  11309. * @hidden
  11310. */
  11311. export class SceneComponentConstants {
  11312. static readonly NAME_EFFECTLAYER: string;
  11313. static readonly NAME_LAYER: string;
  11314. static readonly NAME_LENSFLARESYSTEM: string;
  11315. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11316. static readonly NAME_PARTICLESYSTEM: string;
  11317. static readonly NAME_GAMEPAD: string;
  11318. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11319. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11320. static readonly NAME_DEPTHRENDERER: string;
  11321. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11322. static readonly NAME_SPRITE: string;
  11323. static readonly NAME_OUTLINERENDERER: string;
  11324. static readonly NAME_PROCEDURALTEXTURE: string;
  11325. static readonly NAME_SHADOWGENERATOR: string;
  11326. static readonly NAME_OCTREE: string;
  11327. static readonly NAME_PHYSICSENGINE: string;
  11328. static readonly NAME_AUDIO: string;
  11329. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11330. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11331. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11332. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11333. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11334. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11336. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11337. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11338. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11339. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11340. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11341. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11342. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11343. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11344. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11345. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11346. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11347. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11348. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11349. static readonly STEP_AFTERRENDER_AUDIO: number;
  11350. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11351. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11352. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11353. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11354. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11355. static readonly STEP_POINTERMOVE_SPRITE: number;
  11356. static readonly STEP_POINTERDOWN_SPRITE: number;
  11357. static readonly STEP_POINTERUP_SPRITE: number;
  11358. }
  11359. /**
  11360. * This represents a scene component.
  11361. *
  11362. * This is used to decouple the dependency the scene is having on the different workloads like
  11363. * layers, post processes...
  11364. */
  11365. export interface ISceneComponent {
  11366. /**
  11367. * The name of the component. Each component must have a unique name.
  11368. */
  11369. name: string;
  11370. /**
  11371. * The scene the component belongs to.
  11372. */
  11373. scene: Scene;
  11374. /**
  11375. * Register the component to one instance of a scene.
  11376. */
  11377. register(): void;
  11378. /**
  11379. * Rebuilds the elements related to this component in case of
  11380. * context lost for instance.
  11381. */
  11382. rebuild(): void;
  11383. /**
  11384. * Disposes the component and the associated ressources.
  11385. */
  11386. dispose(): void;
  11387. }
  11388. /**
  11389. * This represents a SERIALIZABLE scene component.
  11390. *
  11391. * This extends Scene Component to add Serialization methods on top.
  11392. */
  11393. export interface ISceneSerializableComponent extends ISceneComponent {
  11394. /**
  11395. * Adds all the element from the container to the scene
  11396. * @param container the container holding the elements
  11397. */
  11398. addFromContainer(container: AbstractScene): void;
  11399. /**
  11400. * Removes all the elements in the container from the scene
  11401. * @param container contains the elements to remove
  11402. */
  11403. removeFromContainer(container: AbstractScene): void;
  11404. /**
  11405. * Serializes the component data to the specified json object
  11406. * @param serializationObject The object to serialize to
  11407. */
  11408. serialize(serializationObject: any): void;
  11409. }
  11410. /**
  11411. * Strong typing of a Mesh related stage step action
  11412. */
  11413. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11414. /**
  11415. * Strong typing of a Evaluate Sub Mesh related stage step action
  11416. */
  11417. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11418. /**
  11419. * Strong typing of a Active Mesh related stage step action
  11420. */
  11421. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11422. /**
  11423. * Strong typing of a Camera related stage step action
  11424. */
  11425. export type CameraStageAction = (camera: Camera) => void;
  11426. /**
  11427. * Strong typing of a Render Target related stage step action
  11428. */
  11429. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11430. /**
  11431. * Strong typing of a RenderingGroup related stage step action
  11432. */
  11433. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11434. /**
  11435. * Strong typing of a Mesh Render related stage step action
  11436. */
  11437. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11438. /**
  11439. * Strong typing of a simple stage step action
  11440. */
  11441. export type SimpleStageAction = () => void;
  11442. /**
  11443. * Strong typing of a render target action.
  11444. */
  11445. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11446. /**
  11447. * Strong typing of a pointer move action.
  11448. */
  11449. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11450. /**
  11451. * Strong typing of a pointer up/down action.
  11452. */
  11453. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11454. /**
  11455. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11456. * @hidden
  11457. */
  11458. export class Stage<T extends Function> extends Array<{
  11459. index: number;
  11460. component: ISceneComponent;
  11461. action: T;
  11462. }> {
  11463. /**
  11464. * Hide ctor from the rest of the world.
  11465. * @param items The items to add.
  11466. */
  11467. private constructor();
  11468. /**
  11469. * Creates a new Stage.
  11470. * @returns A new instance of a Stage
  11471. */
  11472. static Create<T extends Function>(): Stage<T>;
  11473. /**
  11474. * Registers a step in an ordered way in the targeted stage.
  11475. * @param index Defines the position to register the step in
  11476. * @param component Defines the component attached to the step
  11477. * @param action Defines the action to launch during the step
  11478. */
  11479. registerStep(index: number, component: ISceneComponent, action: T): void;
  11480. /**
  11481. * Clears all the steps from the stage.
  11482. */
  11483. clear(): void;
  11484. }
  11485. }
  11486. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11487. import { Nullable } from "babylonjs/types";
  11488. import { Observable } from "babylonjs/Misc/observable";
  11489. import { Scene } from "babylonjs/scene";
  11490. import { Sprite } from "babylonjs/Sprites/sprite";
  11491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11492. import { Ray } from "babylonjs/Culling/ray";
  11493. import { Camera } from "babylonjs/Cameras/camera";
  11494. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11495. import { ISceneComponent } from "babylonjs/sceneComponent";
  11496. module "babylonjs/scene" {
  11497. interface Scene {
  11498. /** @hidden */
  11499. _pointerOverSprite: Nullable<Sprite>;
  11500. /** @hidden */
  11501. _pickedDownSprite: Nullable<Sprite>;
  11502. /** @hidden */
  11503. _tempSpritePickingRay: Nullable<Ray>;
  11504. /**
  11505. * All of the sprite managers added to this scene
  11506. * @see http://doc.babylonjs.com/babylon101/sprites
  11507. */
  11508. spriteManagers: Array<ISpriteManager>;
  11509. /**
  11510. * An event triggered when sprites rendering is about to start
  11511. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11512. */
  11513. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11514. /**
  11515. * An event triggered when sprites rendering is done
  11516. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11517. */
  11518. onAfterSpritesRenderingObservable: Observable<Scene>;
  11519. /** @hidden */
  11520. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11521. /** Launch a ray to try to pick a sprite in the scene
  11522. * @param x position on screen
  11523. * @param y position on screen
  11524. * @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
  11525. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11526. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11527. * @returns a PickingInfo
  11528. */
  11529. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11530. /** Use the given ray to pick a sprite in the scene
  11531. * @param ray The ray (in world space) to use to pick meshes
  11532. * @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
  11533. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11534. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11535. * @returns a PickingInfo
  11536. */
  11537. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11538. /**
  11539. * Force the sprite under the pointer
  11540. * @param sprite defines the sprite to use
  11541. */
  11542. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11543. /**
  11544. * Gets the sprite under the pointer
  11545. * @returns a Sprite or null if no sprite is under the pointer
  11546. */
  11547. getPointerOverSprite(): Nullable<Sprite>;
  11548. }
  11549. }
  11550. /**
  11551. * Defines the sprite scene component responsible to manage sprites
  11552. * in a given scene.
  11553. */
  11554. export class SpriteSceneComponent implements ISceneComponent {
  11555. /**
  11556. * The component name helpfull to identify the component in the list of scene components.
  11557. */
  11558. readonly name: string;
  11559. /**
  11560. * The scene the component belongs to.
  11561. */
  11562. scene: Scene;
  11563. /** @hidden */
  11564. private _spritePredicate;
  11565. /**
  11566. * Creates a new instance of the component for the given scene
  11567. * @param scene Defines the scene to register the component in
  11568. */
  11569. constructor(scene: Scene);
  11570. /**
  11571. * Registers the component in a given scene
  11572. */
  11573. register(): void;
  11574. /**
  11575. * Rebuilds the elements related to this component in case of
  11576. * context lost for instance.
  11577. */
  11578. rebuild(): void;
  11579. /**
  11580. * Disposes the component and the associated ressources.
  11581. */
  11582. dispose(): void;
  11583. private _pickSpriteButKeepRay;
  11584. private _pointerMove;
  11585. private _pointerDown;
  11586. private _pointerUp;
  11587. }
  11588. }
  11589. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11590. /** @hidden */
  11591. export var fogFragmentDeclaration: {
  11592. name: string;
  11593. shader: string;
  11594. };
  11595. }
  11596. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11597. /** @hidden */
  11598. export var fogFragment: {
  11599. name: string;
  11600. shader: string;
  11601. };
  11602. }
  11603. declare module "babylonjs/Shaders/sprites.fragment" {
  11604. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11605. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11606. /** @hidden */
  11607. export var spritesPixelShader: {
  11608. name: string;
  11609. shader: string;
  11610. };
  11611. }
  11612. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11613. /** @hidden */
  11614. export var fogVertexDeclaration: {
  11615. name: string;
  11616. shader: string;
  11617. };
  11618. }
  11619. declare module "babylonjs/Shaders/sprites.vertex" {
  11620. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11621. /** @hidden */
  11622. export var spritesVertexShader: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module "babylonjs/Sprites/spriteManager" {
  11628. import { IDisposable, Scene } from "babylonjs/scene";
  11629. import { Nullable } from "babylonjs/types";
  11630. import { Observable } from "babylonjs/Misc/observable";
  11631. import { Sprite } from "babylonjs/Sprites/sprite";
  11632. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11633. import { Camera } from "babylonjs/Cameras/camera";
  11634. import { Texture } from "babylonjs/Materials/Textures/texture";
  11635. import "babylonjs/Shaders/sprites.fragment";
  11636. import "babylonjs/Shaders/sprites.vertex";
  11637. import { Ray } from "babylonjs/Culling/ray";
  11638. /**
  11639. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11640. */
  11641. export interface ISpriteManager extends IDisposable {
  11642. /**
  11643. * Restricts the camera to viewing objects with the same layerMask.
  11644. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11645. */
  11646. layerMask: number;
  11647. /**
  11648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11649. */
  11650. isPickable: boolean;
  11651. /**
  11652. * Specifies the rendering group id for this mesh (0 by default)
  11653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11654. */
  11655. renderingGroupId: number;
  11656. /**
  11657. * Defines the list of sprites managed by the manager.
  11658. */
  11659. sprites: Array<Sprite>;
  11660. /**
  11661. * Tests the intersection of a sprite with a specific ray.
  11662. * @param ray The ray we are sending to test the collision
  11663. * @param camera The camera space we are sending rays in
  11664. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11665. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11666. * @returns picking info or null.
  11667. */
  11668. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11669. /**
  11670. * Renders the list of sprites on screen.
  11671. */
  11672. render(): void;
  11673. }
  11674. /**
  11675. * Class used to manage multiple sprites on the same spritesheet
  11676. * @see http://doc.babylonjs.com/babylon101/sprites
  11677. */
  11678. export class SpriteManager implements ISpriteManager {
  11679. /** defines the manager's name */
  11680. name: string;
  11681. /** Gets the list of sprites */
  11682. sprites: Sprite[];
  11683. /** Gets or sets the rendering group id (0 by default) */
  11684. renderingGroupId: number;
  11685. /** Gets or sets camera layer mask */
  11686. layerMask: number;
  11687. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11688. fogEnabled: boolean;
  11689. /** Gets or sets a boolean indicating if the sprites are pickable */
  11690. isPickable: boolean;
  11691. /** Defines the default width of a cell in the spritesheet */
  11692. cellWidth: number;
  11693. /** Defines the default height of a cell in the spritesheet */
  11694. cellHeight: number;
  11695. /**
  11696. * An event triggered when the manager is disposed.
  11697. */
  11698. onDisposeObservable: Observable<SpriteManager>;
  11699. private _onDisposeObserver;
  11700. /**
  11701. * Callback called when the manager is disposed
  11702. */
  11703. onDispose: () => void;
  11704. private _capacity;
  11705. private _spriteTexture;
  11706. private _epsilon;
  11707. private _scene;
  11708. private _vertexData;
  11709. private _buffer;
  11710. private _vertexBuffers;
  11711. private _indexBuffer;
  11712. private _effectBase;
  11713. private _effectFog;
  11714. /**
  11715. * Gets or sets the spritesheet texture
  11716. */
  11717. texture: Texture;
  11718. /**
  11719. * Creates a new sprite manager
  11720. * @param name defines the manager's name
  11721. * @param imgUrl defines the sprite sheet url
  11722. * @param capacity defines the maximum allowed number of sprites
  11723. * @param cellSize defines the size of a sprite cell
  11724. * @param scene defines the hosting scene
  11725. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11726. * @param samplingMode defines the smapling mode to use with spritesheet
  11727. */
  11728. constructor(
  11729. /** defines the manager's name */
  11730. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11731. private _appendSpriteVertex;
  11732. /**
  11733. * Intersects the sprites with a ray
  11734. * @param ray defines the ray to intersect with
  11735. * @param camera defines the current active camera
  11736. * @param predicate defines a predicate used to select candidate sprites
  11737. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11738. * @returns null if no hit or a PickingInfo
  11739. */
  11740. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11741. /**
  11742. * Render all child sprites
  11743. */
  11744. render(): void;
  11745. /**
  11746. * Release associated resources
  11747. */
  11748. dispose(): void;
  11749. }
  11750. }
  11751. declare module "babylonjs/Sprites/sprite" {
  11752. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11753. import { Nullable } from "babylonjs/types";
  11754. import { ActionManager } from "babylonjs/Actions/actionManager";
  11755. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11756. /**
  11757. * Class used to represent a sprite
  11758. * @see http://doc.babylonjs.com/babylon101/sprites
  11759. */
  11760. export class Sprite {
  11761. /** defines the name */
  11762. name: string;
  11763. /** Gets or sets the current world position */
  11764. position: Vector3;
  11765. /** Gets or sets the main color */
  11766. color: Color4;
  11767. /** Gets or sets the width */
  11768. width: number;
  11769. /** Gets or sets the height */
  11770. height: number;
  11771. /** Gets or sets rotation angle */
  11772. angle: number;
  11773. /** Gets or sets the cell index in the sprite sheet */
  11774. cellIndex: number;
  11775. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11776. invertU: number;
  11777. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11778. invertV: number;
  11779. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11780. disposeWhenFinishedAnimating: boolean;
  11781. /** Gets the list of attached animations */
  11782. animations: Animation[];
  11783. /** Gets or sets a boolean indicating if the sprite can be picked */
  11784. isPickable: boolean;
  11785. /**
  11786. * Gets or sets the associated action manager
  11787. */
  11788. actionManager: Nullable<ActionManager>;
  11789. private _animationStarted;
  11790. private _loopAnimation;
  11791. private _fromIndex;
  11792. private _toIndex;
  11793. private _delay;
  11794. private _direction;
  11795. private _manager;
  11796. private _time;
  11797. private _onAnimationEnd;
  11798. /**
  11799. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11800. */
  11801. isVisible: boolean;
  11802. /**
  11803. * Gets or sets the sprite size
  11804. */
  11805. size: number;
  11806. /**
  11807. * Creates a new Sprite
  11808. * @param name defines the name
  11809. * @param manager defines the manager
  11810. */
  11811. constructor(
  11812. /** defines the name */
  11813. name: string, manager: ISpriteManager);
  11814. /**
  11815. * Starts an animation
  11816. * @param from defines the initial key
  11817. * @param to defines the end key
  11818. * @param loop defines if the animation must loop
  11819. * @param delay defines the start delay (in ms)
  11820. * @param onAnimationEnd defines a callback to call when animation ends
  11821. */
  11822. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11823. /** Stops current animation (if any) */
  11824. stopAnimation(): void;
  11825. /** @hidden */
  11826. _animate(deltaTime: number): void;
  11827. /** Release associated resources */
  11828. dispose(): void;
  11829. }
  11830. }
  11831. declare module "babylonjs/Collisions/pickingInfo" {
  11832. import { Nullable } from "babylonjs/types";
  11833. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11835. import { Sprite } from "babylonjs/Sprites/sprite";
  11836. import { Ray } from "babylonjs/Culling/ray";
  11837. /**
  11838. * Information about the result of picking within a scene
  11839. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11840. */
  11841. export class PickingInfo {
  11842. /** @hidden */
  11843. _pickingUnavailable: boolean;
  11844. /**
  11845. * If the pick collided with an object
  11846. */
  11847. hit: boolean;
  11848. /**
  11849. * Distance away where the pick collided
  11850. */
  11851. distance: number;
  11852. /**
  11853. * The location of pick collision
  11854. */
  11855. pickedPoint: Nullable<Vector3>;
  11856. /**
  11857. * The mesh corresponding the the pick collision
  11858. */
  11859. pickedMesh: Nullable<AbstractMesh>;
  11860. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11861. bu: number;
  11862. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11863. bv: number;
  11864. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11865. faceId: number;
  11866. /** Id of the the submesh that was picked */
  11867. subMeshId: number;
  11868. /** If a sprite was picked, this will be the sprite the pick collided with */
  11869. pickedSprite: Nullable<Sprite>;
  11870. /**
  11871. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11872. */
  11873. originMesh: Nullable<AbstractMesh>;
  11874. /**
  11875. * The ray that was used to perform the picking.
  11876. */
  11877. ray: Nullable<Ray>;
  11878. /**
  11879. * Gets the normal correspodning to the face the pick collided with
  11880. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11881. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11882. * @returns The normal correspodning to the face the pick collided with
  11883. */
  11884. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11885. /**
  11886. * Gets the texture coordinates of where the pick occured
  11887. * @returns the vector containing the coordnates of the texture
  11888. */
  11889. getTextureCoordinates(): Nullable<Vector2>;
  11890. }
  11891. }
  11892. declare module "babylonjs/Events/pointerEvents" {
  11893. import { Nullable } from "babylonjs/types";
  11894. import { Vector2 } from "babylonjs/Maths/math";
  11895. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11896. import { Ray } from "babylonjs/Culling/ray";
  11897. /**
  11898. * Gather the list of pointer event types as constants.
  11899. */
  11900. export class PointerEventTypes {
  11901. /**
  11902. * 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.
  11903. */
  11904. static readonly POINTERDOWN: number;
  11905. /**
  11906. * The pointerup event is fired when a pointer is no longer active.
  11907. */
  11908. static readonly POINTERUP: number;
  11909. /**
  11910. * The pointermove event is fired when a pointer changes coordinates.
  11911. */
  11912. static readonly POINTERMOVE: number;
  11913. /**
  11914. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11915. */
  11916. static readonly POINTERWHEEL: number;
  11917. /**
  11918. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11919. */
  11920. static readonly POINTERPICK: number;
  11921. /**
  11922. * The pointertap event is fired when a the object has been touched and released without drag.
  11923. */
  11924. static readonly POINTERTAP: number;
  11925. /**
  11926. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11927. */
  11928. static readonly POINTERDOUBLETAP: number;
  11929. }
  11930. /**
  11931. * Base class of pointer info types.
  11932. */
  11933. export class PointerInfoBase {
  11934. /**
  11935. * Defines the type of event (PointerEventTypes)
  11936. */
  11937. type: number;
  11938. /**
  11939. * Defines the related dom event
  11940. */
  11941. event: PointerEvent | MouseWheelEvent;
  11942. /**
  11943. * Instantiates the base class of pointers info.
  11944. * @param type Defines the type of event (PointerEventTypes)
  11945. * @param event Defines the related dom event
  11946. */
  11947. constructor(
  11948. /**
  11949. * Defines the type of event (PointerEventTypes)
  11950. */
  11951. type: number,
  11952. /**
  11953. * Defines the related dom event
  11954. */
  11955. event: PointerEvent | MouseWheelEvent);
  11956. }
  11957. /**
  11958. * This class is used to store pointer related info for the onPrePointerObservable event.
  11959. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11960. */
  11961. export class PointerInfoPre extends PointerInfoBase {
  11962. /**
  11963. * Ray from a pointer if availible (eg. 6dof controller)
  11964. */
  11965. ray: Nullable<Ray>;
  11966. /**
  11967. * Defines the local position of the pointer on the canvas.
  11968. */
  11969. localPosition: Vector2;
  11970. /**
  11971. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11972. */
  11973. skipOnPointerObservable: boolean;
  11974. /**
  11975. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11976. * @param type Defines the type of event (PointerEventTypes)
  11977. * @param event Defines the related dom event
  11978. * @param localX Defines the local x coordinates of the pointer when the event occured
  11979. * @param localY Defines the local y coordinates of the pointer when the event occured
  11980. */
  11981. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11982. }
  11983. /**
  11984. * This type contains all the data related to a pointer event in Babylon.js.
  11985. * 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.
  11986. */
  11987. export class PointerInfo extends PointerInfoBase {
  11988. /**
  11989. * Defines the picking info associated to the info (if any)\
  11990. */
  11991. pickInfo: Nullable<PickingInfo>;
  11992. /**
  11993. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11994. * @param type Defines the type of event (PointerEventTypes)
  11995. * @param event Defines the related dom event
  11996. * @param pickInfo Defines the picking info associated to the info (if any)\
  11997. */
  11998. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11999. /**
  12000. * Defines the picking info associated to the info (if any)\
  12001. */
  12002. pickInfo: Nullable<PickingInfo>);
  12003. }
  12004. }
  12005. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12006. import { Nullable } from "babylonjs/types";
  12007. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12009. /**
  12010. * Manage the mouse inputs to control the movement of a free camera.
  12011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12012. */
  12013. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12014. /**
  12015. * Define if touch is enabled in the mouse input
  12016. */
  12017. touchEnabled: boolean;
  12018. /**
  12019. * Defines the camera the input is attached to.
  12020. */
  12021. camera: FreeCamera;
  12022. /**
  12023. * Defines the buttons associated with the input to handle camera move.
  12024. */
  12025. buttons: number[];
  12026. /**
  12027. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12028. */
  12029. angularSensibility: number;
  12030. private _pointerInput;
  12031. private _onMouseMove;
  12032. private _observer;
  12033. private previousPosition;
  12034. /**
  12035. * Manage the mouse inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. * @param touchEnabled Defines if touch is enabled or not
  12038. */
  12039. constructor(
  12040. /**
  12041. * Define if touch is enabled in the mouse input
  12042. */
  12043. touchEnabled?: boolean);
  12044. /**
  12045. * Attach the input controls to a specific dom element to get the input from.
  12046. * @param element Defines the element the controls should be listened from
  12047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12048. */
  12049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12050. /**
  12051. * Detach the current controls from the specified dom element.
  12052. * @param element Defines the element to stop listening the inputs from
  12053. */
  12054. detachControl(element: Nullable<HTMLElement>): void;
  12055. /**
  12056. * Gets the class name of the current intput.
  12057. * @returns the class name
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Get the friendly name associated with the input class.
  12062. * @returns the input friendly name
  12063. */
  12064. getSimpleName(): string;
  12065. }
  12066. }
  12067. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the touch inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Defines the camera the input is attached to.
  12078. */
  12079. camera: FreeCamera;
  12080. /**
  12081. * Defines the touch sensibility for rotation.
  12082. * The higher the faster.
  12083. */
  12084. touchAngularSensibility: number;
  12085. /**
  12086. * Defines the touch sensibility for move.
  12087. * The higher the faster.
  12088. */
  12089. touchMoveSensibility: number;
  12090. private _offsetX;
  12091. private _offsetY;
  12092. private _pointerPressed;
  12093. private _pointerInput;
  12094. private _observer;
  12095. private _onLostFocus;
  12096. /**
  12097. * Attach the input controls to a specific dom element to get the input from.
  12098. * @param element Defines the element the controls should be listened from
  12099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12100. */
  12101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12102. /**
  12103. * Detach the current controls from the specified dom element.
  12104. * @param element Defines the element to stop listening the inputs from
  12105. */
  12106. detachControl(element: Nullable<HTMLElement>): void;
  12107. /**
  12108. * Update the current camera state depending on the inputs that have been used this frame.
  12109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12110. */
  12111. checkInputs(): void;
  12112. /**
  12113. * Gets the class name of the current intput.
  12114. * @returns the class name
  12115. */
  12116. getClassName(): string;
  12117. /**
  12118. * Get the friendly name associated with the input class.
  12119. * @returns the input friendly name
  12120. */
  12121. getSimpleName(): string;
  12122. }
  12123. }
  12124. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12127. /**
  12128. * Default Inputs manager for the FreeCamera.
  12129. * It groups all the default supported inputs for ease of use.
  12130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12131. */
  12132. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12133. /**
  12134. * Instantiates a new FreeCameraInputsManager.
  12135. * @param camera Defines the camera the inputs belong to
  12136. */
  12137. constructor(camera: FreeCamera);
  12138. /**
  12139. * Add keyboard input support to the input manager.
  12140. * @returns the current input manager
  12141. */
  12142. addKeyboard(): FreeCameraInputsManager;
  12143. /**
  12144. * Add mouse input support to the input manager.
  12145. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12146. * @returns the current input manager
  12147. */
  12148. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12149. /**
  12150. * Add touch input support to the input manager.
  12151. * @returns the current input manager
  12152. */
  12153. addTouch(): FreeCameraInputsManager;
  12154. }
  12155. }
  12156. declare module "babylonjs/Cameras/freeCamera" {
  12157. import { Vector3 } from "babylonjs/Maths/math";
  12158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12159. import { Scene } from "babylonjs/scene";
  12160. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12161. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12162. /**
  12163. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12164. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12166. */
  12167. export class FreeCamera extends TargetCamera {
  12168. /**
  12169. * Define the collision ellipsoid of the camera.
  12170. * This is helpful to simulate a camera body like the player body around the camera
  12171. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12172. */
  12173. ellipsoid: Vector3;
  12174. /**
  12175. * Define an offset for the position of the ellipsoid around the camera.
  12176. * This can be helpful to determine the center of the body near the gravity center of the body
  12177. * instead of its head.
  12178. */
  12179. ellipsoidOffset: Vector3;
  12180. /**
  12181. * Enable or disable collisions of the camera with the rest of the scene objects.
  12182. */
  12183. checkCollisions: boolean;
  12184. /**
  12185. * Enable or disable gravity on the camera.
  12186. */
  12187. applyGravity: boolean;
  12188. /**
  12189. * Define the input manager associated to the camera.
  12190. */
  12191. inputs: FreeCameraInputsManager;
  12192. /**
  12193. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12194. * Higher values reduce sensitivity.
  12195. */
  12196. /**
  12197. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12198. * Higher values reduce sensitivity.
  12199. */
  12200. angularSensibility: number;
  12201. /**
  12202. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12203. */
  12204. keysUp: number[];
  12205. /**
  12206. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12207. */
  12208. keysDown: number[];
  12209. /**
  12210. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12211. */
  12212. keysLeft: number[];
  12213. /**
  12214. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12215. */
  12216. keysRight: number[];
  12217. /**
  12218. * Event raised when the camera collide with a mesh in the scene.
  12219. */
  12220. onCollide: (collidedMesh: AbstractMesh) => void;
  12221. private _collider;
  12222. private _needMoveForGravity;
  12223. private _oldPosition;
  12224. private _diffPosition;
  12225. private _newPosition;
  12226. /** @hidden */
  12227. _localDirection: Vector3;
  12228. /** @hidden */
  12229. _transformedDirection: Vector3;
  12230. /**
  12231. * Instantiates a Free Camera.
  12232. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12233. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12235. * @param name Define the name of the camera in the scene
  12236. * @param position Define the start position of the camera in the scene
  12237. * @param scene Define the scene the camera belongs to
  12238. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12239. */
  12240. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12241. /**
  12242. * Attached controls to the current camera.
  12243. * @param element Defines the element the controls should be listened from
  12244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12245. */
  12246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12247. /**
  12248. * Detach the current controls from the camera.
  12249. * The camera will stop reacting to inputs.
  12250. * @param element Defines the element to stop listening the inputs from
  12251. */
  12252. detachControl(element: HTMLElement): void;
  12253. private _collisionMask;
  12254. /**
  12255. * Define a collision mask to limit the list of object the camera can collide with
  12256. */
  12257. collisionMask: number;
  12258. /** @hidden */
  12259. _collideWithWorld(displacement: Vector3): void;
  12260. private _onCollisionPositionChange;
  12261. /** @hidden */
  12262. _checkInputs(): void;
  12263. /** @hidden */
  12264. _decideIfNeedsToMove(): boolean;
  12265. /** @hidden */
  12266. _updatePosition(): void;
  12267. /**
  12268. * Destroy the camera and release the current resources hold by it.
  12269. */
  12270. dispose(): void;
  12271. /**
  12272. * Gets the current object class name.
  12273. * @return the class name
  12274. */
  12275. getClassName(): string;
  12276. }
  12277. }
  12278. declare module "babylonjs/Gamepads/gamepad" {
  12279. import { Observable } from "babylonjs/Misc/observable";
  12280. /**
  12281. * Represents a gamepad control stick position
  12282. */
  12283. export class StickValues {
  12284. /**
  12285. * The x component of the control stick
  12286. */
  12287. x: number;
  12288. /**
  12289. * The y component of the control stick
  12290. */
  12291. y: number;
  12292. /**
  12293. * Initializes the gamepad x and y control stick values
  12294. * @param x The x component of the gamepad control stick value
  12295. * @param y The y component of the gamepad control stick value
  12296. */
  12297. constructor(
  12298. /**
  12299. * The x component of the control stick
  12300. */
  12301. x: number,
  12302. /**
  12303. * The y component of the control stick
  12304. */
  12305. y: number);
  12306. }
  12307. /**
  12308. * An interface which manages callbacks for gamepad button changes
  12309. */
  12310. export interface GamepadButtonChanges {
  12311. /**
  12312. * Called when a gamepad has been changed
  12313. */
  12314. changed: boolean;
  12315. /**
  12316. * Called when a gamepad press event has been triggered
  12317. */
  12318. pressChanged: boolean;
  12319. /**
  12320. * Called when a touch event has been triggered
  12321. */
  12322. touchChanged: boolean;
  12323. /**
  12324. * Called when a value has changed
  12325. */
  12326. valueChanged: boolean;
  12327. }
  12328. /**
  12329. * Represents a gamepad
  12330. */
  12331. export class Gamepad {
  12332. /**
  12333. * The id of the gamepad
  12334. */
  12335. id: string;
  12336. /**
  12337. * The index of the gamepad
  12338. */
  12339. index: number;
  12340. /**
  12341. * The browser gamepad
  12342. */
  12343. browserGamepad: any;
  12344. /**
  12345. * Specifies what type of gamepad this represents
  12346. */
  12347. type: number;
  12348. private _leftStick;
  12349. private _rightStick;
  12350. /** @hidden */
  12351. _isConnected: boolean;
  12352. private _leftStickAxisX;
  12353. private _leftStickAxisY;
  12354. private _rightStickAxisX;
  12355. private _rightStickAxisY;
  12356. /**
  12357. * Triggered when the left control stick has been changed
  12358. */
  12359. private _onleftstickchanged;
  12360. /**
  12361. * Triggered when the right control stick has been changed
  12362. */
  12363. private _onrightstickchanged;
  12364. /**
  12365. * Represents a gamepad controller
  12366. */
  12367. static GAMEPAD: number;
  12368. /**
  12369. * Represents a generic controller
  12370. */
  12371. static GENERIC: number;
  12372. /**
  12373. * Represents an XBox controller
  12374. */
  12375. static XBOX: number;
  12376. /**
  12377. * Represents a pose-enabled controller
  12378. */
  12379. static POSE_ENABLED: number;
  12380. /**
  12381. * Specifies whether the left control stick should be Y-inverted
  12382. */
  12383. protected _invertLeftStickY: boolean;
  12384. /**
  12385. * Specifies if the gamepad has been connected
  12386. */
  12387. readonly isConnected: boolean;
  12388. /**
  12389. * Initializes the gamepad
  12390. * @param id The id of the gamepad
  12391. * @param index The index of the gamepad
  12392. * @param browserGamepad The browser gamepad
  12393. * @param leftStickX The x component of the left joystick
  12394. * @param leftStickY The y component of the left joystick
  12395. * @param rightStickX The x component of the right joystick
  12396. * @param rightStickY The y component of the right joystick
  12397. */
  12398. constructor(
  12399. /**
  12400. * The id of the gamepad
  12401. */
  12402. id: string,
  12403. /**
  12404. * The index of the gamepad
  12405. */
  12406. index: number,
  12407. /**
  12408. * The browser gamepad
  12409. */
  12410. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12411. /**
  12412. * Callback triggered when the left joystick has changed
  12413. * @param callback
  12414. */
  12415. onleftstickchanged(callback: (values: StickValues) => void): void;
  12416. /**
  12417. * Callback triggered when the right joystick has changed
  12418. * @param callback
  12419. */
  12420. onrightstickchanged(callback: (values: StickValues) => void): void;
  12421. /**
  12422. * Gets the left joystick
  12423. */
  12424. /**
  12425. * Sets the left joystick values
  12426. */
  12427. leftStick: StickValues;
  12428. /**
  12429. * Gets the right joystick
  12430. */
  12431. /**
  12432. * Sets the right joystick value
  12433. */
  12434. rightStick: StickValues;
  12435. /**
  12436. * Updates the gamepad joystick positions
  12437. */
  12438. update(): void;
  12439. /**
  12440. * Disposes the gamepad
  12441. */
  12442. dispose(): void;
  12443. }
  12444. /**
  12445. * Represents a generic gamepad
  12446. */
  12447. export class GenericPad extends Gamepad {
  12448. private _buttons;
  12449. private _onbuttondown;
  12450. private _onbuttonup;
  12451. /**
  12452. * Observable triggered when a button has been pressed
  12453. */
  12454. onButtonDownObservable: Observable<number>;
  12455. /**
  12456. * Observable triggered when a button has been released
  12457. */
  12458. onButtonUpObservable: Observable<number>;
  12459. /**
  12460. * Callback triggered when a button has been pressed
  12461. * @param callback Called when a button has been pressed
  12462. */
  12463. onbuttondown(callback: (buttonPressed: number) => void): void;
  12464. /**
  12465. * Callback triggered when a button has been released
  12466. * @param callback Called when a button has been released
  12467. */
  12468. onbuttonup(callback: (buttonReleased: number) => void): void;
  12469. /**
  12470. * Initializes the generic gamepad
  12471. * @param id The id of the generic gamepad
  12472. * @param index The index of the generic gamepad
  12473. * @param browserGamepad The browser gamepad
  12474. */
  12475. constructor(id: string, index: number, browserGamepad: any);
  12476. private _setButtonValue;
  12477. /**
  12478. * Updates the generic gamepad
  12479. */
  12480. update(): void;
  12481. /**
  12482. * Disposes the generic gamepad
  12483. */
  12484. dispose(): void;
  12485. }
  12486. }
  12487. declare module "babylonjs/Meshes/transformNode" {
  12488. import { DeepImmutable } from "babylonjs/types";
  12489. import { Observable } from "babylonjs/Misc/observable";
  12490. import { Nullable } from "babylonjs/types";
  12491. import { Camera } from "babylonjs/Cameras/camera";
  12492. import { Scene } from "babylonjs/scene";
  12493. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  12494. import { Node } from "babylonjs/node";
  12495. import { Bone } from "babylonjs/Bones/bone";
  12496. /**
  12497. * 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.
  12498. * @see https://doc.babylonjs.com/how_to/transformnode
  12499. */
  12500. export class TransformNode extends Node {
  12501. /**
  12502. * Object will not rotate to face the camera
  12503. */
  12504. static BILLBOARDMODE_NONE: number;
  12505. /**
  12506. * Object will rotate to face the camera but only on the x axis
  12507. */
  12508. static BILLBOARDMODE_X: number;
  12509. /**
  12510. * Object will rotate to face the camera but only on the y axis
  12511. */
  12512. static BILLBOARDMODE_Y: number;
  12513. /**
  12514. * Object will rotate to face the camera but only on the z axis
  12515. */
  12516. static BILLBOARDMODE_Z: number;
  12517. /**
  12518. * Object will rotate to face the camera
  12519. */
  12520. static BILLBOARDMODE_ALL: number;
  12521. private _forward;
  12522. private _forwardInverted;
  12523. private _up;
  12524. private _right;
  12525. private _rightInverted;
  12526. private _position;
  12527. private _rotation;
  12528. private _rotationQuaternion;
  12529. protected _scaling: Vector3;
  12530. protected _isDirty: boolean;
  12531. private _transformToBoneReferal;
  12532. /**
  12533. * Set the billboard mode. Default is 0.
  12534. *
  12535. * | Value | Type | Description |
  12536. * | --- | --- | --- |
  12537. * | 0 | BILLBOARDMODE_NONE | |
  12538. * | 1 | BILLBOARDMODE_X | |
  12539. * | 2 | BILLBOARDMODE_Y | |
  12540. * | 4 | BILLBOARDMODE_Z | |
  12541. * | 7 | BILLBOARDMODE_ALL | |
  12542. *
  12543. */
  12544. billboardMode: number;
  12545. /**
  12546. * 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
  12547. */
  12548. scalingDeterminant: number;
  12549. /**
  12550. * Sets the distance of the object to max, often used by skybox
  12551. */
  12552. infiniteDistance: boolean;
  12553. /**
  12554. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12555. * By default the system will update normals to compensate
  12556. */
  12557. ignoreNonUniformScaling: boolean;
  12558. /** @hidden */
  12559. _poseMatrix: Matrix;
  12560. /** @hidden */
  12561. _localMatrix: Matrix;
  12562. private _absolutePosition;
  12563. private _pivotMatrix;
  12564. private _pivotMatrixInverse;
  12565. protected _postMultiplyPivotMatrix: boolean;
  12566. protected _isWorldMatrixFrozen: boolean;
  12567. /** @hidden */
  12568. _indexInSceneTransformNodesArray: number;
  12569. /**
  12570. * An event triggered after the world matrix is updated
  12571. */
  12572. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12573. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12574. /**
  12575. * Gets a string identifying the name of the class
  12576. * @returns "TransformNode" string
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12581. */
  12582. position: Vector3;
  12583. /**
  12584. * 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)).
  12585. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12586. */
  12587. rotation: Vector3;
  12588. /**
  12589. * 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)).
  12590. */
  12591. scaling: Vector3;
  12592. /**
  12593. * 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).
  12594. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12595. */
  12596. rotationQuaternion: Nullable<Quaternion>;
  12597. /**
  12598. * The forward direction of that transform in world space.
  12599. */
  12600. readonly forward: Vector3;
  12601. /**
  12602. * The up direction of that transform in world space.
  12603. */
  12604. readonly up: Vector3;
  12605. /**
  12606. * The right direction of that transform in world space.
  12607. */
  12608. readonly right: Vector3;
  12609. /**
  12610. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12611. * @param matrix the matrix to copy the pose from
  12612. * @returns this TransformNode.
  12613. */
  12614. updatePoseMatrix(matrix: Matrix): TransformNode;
  12615. /**
  12616. * Returns the mesh Pose matrix.
  12617. * @returns the pose matrix
  12618. */
  12619. getPoseMatrix(): Matrix;
  12620. /** @hidden */
  12621. _isSynchronized(): boolean;
  12622. /** @hidden */
  12623. _initCache(): void;
  12624. /**
  12625. * Flag the transform node as dirty (Forcing it to update everything)
  12626. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12627. * @returns this transform node
  12628. */
  12629. markAsDirty(property: string): TransformNode;
  12630. /**
  12631. * Returns the current mesh absolute position.
  12632. * Returns a Vector3.
  12633. */
  12634. readonly absolutePosition: Vector3;
  12635. /**
  12636. * Sets a new matrix to apply before all other transformation
  12637. * @param matrix defines the transform matrix
  12638. * @returns the current TransformNode
  12639. */
  12640. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12641. /**
  12642. * Sets a new pivot matrix to the current node
  12643. * @param matrix defines the new pivot matrix to use
  12644. * @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
  12645. * @returns the current TransformNode
  12646. */
  12647. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12648. /**
  12649. * Returns the mesh pivot matrix.
  12650. * Default : Identity.
  12651. * @returns the matrix
  12652. */
  12653. getPivotMatrix(): Matrix;
  12654. /**
  12655. * Prevents the World matrix to be computed any longer.
  12656. * @returns the TransformNode.
  12657. */
  12658. freezeWorldMatrix(): TransformNode;
  12659. /**
  12660. * Allows back the World matrix computation.
  12661. * @returns the TransformNode.
  12662. */
  12663. unfreezeWorldMatrix(): this;
  12664. /**
  12665. * True if the World matrix has been frozen.
  12666. */
  12667. readonly isWorldMatrixFrozen: boolean;
  12668. /**
  12669. * Retuns the mesh absolute position in the World.
  12670. * @returns a Vector3.
  12671. */
  12672. getAbsolutePosition(): Vector3;
  12673. /**
  12674. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12675. * @param absolutePosition the absolute position to set
  12676. * @returns the TransformNode.
  12677. */
  12678. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12679. /**
  12680. * Sets the mesh position in its local space.
  12681. * @param vector3 the position to set in localspace
  12682. * @returns the TransformNode.
  12683. */
  12684. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12685. /**
  12686. * Returns the mesh position in the local space from the current World matrix values.
  12687. * @returns a new Vector3.
  12688. */
  12689. getPositionExpressedInLocalSpace(): Vector3;
  12690. /**
  12691. * Translates the mesh along the passed Vector3 in its local space.
  12692. * @param vector3 the distance to translate in localspace
  12693. * @returns the TransformNode.
  12694. */
  12695. locallyTranslate(vector3: Vector3): TransformNode;
  12696. private static _lookAtVectorCache;
  12697. /**
  12698. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12699. * @param targetPoint the position (must be in same space as current mesh) to look at
  12700. * @param yawCor optional yaw (y-axis) correction in radians
  12701. * @param pitchCor optional pitch (x-axis) correction in radians
  12702. * @param rollCor optional roll (z-axis) correction in radians
  12703. * @param space the choosen space of the target
  12704. * @returns the TransformNode.
  12705. */
  12706. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12707. /**
  12708. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12709. * This Vector3 is expressed in the World space.
  12710. * @param localAxis axis to rotate
  12711. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12712. */
  12713. getDirection(localAxis: Vector3): Vector3;
  12714. /**
  12715. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12716. * localAxis is expressed in the mesh local space.
  12717. * result is computed in the Wordl space from the mesh World matrix.
  12718. * @param localAxis axis to rotate
  12719. * @param result the resulting transformnode
  12720. * @returns this TransformNode.
  12721. */
  12722. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12723. /**
  12724. * Sets this transform node rotation to the given local axis.
  12725. * @param localAxis the axis in local space
  12726. * @param yawCor optional yaw (y-axis) correction in radians
  12727. * @param pitchCor optional pitch (x-axis) correction in radians
  12728. * @param rollCor optional roll (z-axis) correction in radians
  12729. * @returns this TransformNode
  12730. */
  12731. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12732. /**
  12733. * Sets a new pivot point to the current node
  12734. * @param point defines the new pivot point to use
  12735. * @param space defines if the point is in world or local space (local by default)
  12736. * @returns the current TransformNode
  12737. */
  12738. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12739. /**
  12740. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12741. * @returns the pivot point
  12742. */
  12743. getPivotPoint(): Vector3;
  12744. /**
  12745. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12746. * @param result the vector3 to store the result
  12747. * @returns this TransformNode.
  12748. */
  12749. getPivotPointToRef(result: Vector3): TransformNode;
  12750. /**
  12751. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12752. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12753. */
  12754. getAbsolutePivotPoint(): Vector3;
  12755. /**
  12756. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12757. * @param result vector3 to store the result
  12758. * @returns this TransformNode.
  12759. */
  12760. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12761. /**
  12762. * Defines the passed node as the parent of the current node.
  12763. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12764. * @param node the node ot set as the parent
  12765. * @returns this TransformNode.
  12766. */
  12767. setParent(node: Nullable<Node>): TransformNode;
  12768. private _nonUniformScaling;
  12769. /**
  12770. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12771. */
  12772. readonly nonUniformScaling: boolean;
  12773. /** @hidden */
  12774. _updateNonUniformScalingState(value: boolean): boolean;
  12775. /**
  12776. * Attach the current TransformNode to another TransformNode associated with a bone
  12777. * @param bone Bone affecting the TransformNode
  12778. * @param affectedTransformNode TransformNode associated with the bone
  12779. * @returns this object
  12780. */
  12781. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12782. /**
  12783. * Detach the transform node if its associated with a bone
  12784. * @returns this object
  12785. */
  12786. detachFromBone(): TransformNode;
  12787. private static _rotationAxisCache;
  12788. /**
  12789. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12790. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12791. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12792. * The passed axis is also normalized.
  12793. * @param axis the axis to rotate around
  12794. * @param amount the amount to rotate in radians
  12795. * @param space Space to rotate in (Default: local)
  12796. * @returns the TransformNode.
  12797. */
  12798. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12799. /**
  12800. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12801. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12802. * The passed axis is also normalized. .
  12803. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12804. * @param point the point to rotate around
  12805. * @param axis the axis to rotate around
  12806. * @param amount the amount to rotate in radians
  12807. * @returns the TransformNode
  12808. */
  12809. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12810. /**
  12811. * Translates the mesh along the axis vector for the passed distance in the given space.
  12812. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12813. * @param axis the axis to translate in
  12814. * @param distance the distance to translate
  12815. * @param space Space to rotate in (Default: local)
  12816. * @returns the TransformNode.
  12817. */
  12818. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12819. /**
  12820. * Adds a rotation step to the mesh current rotation.
  12821. * x, y, z are Euler angles expressed in radians.
  12822. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12823. * This means this rotation is made in the mesh local space only.
  12824. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12825. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12826. * ```javascript
  12827. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12828. * ```
  12829. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12830. * 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.
  12831. * @param x Rotation to add
  12832. * @param y Rotation to add
  12833. * @param z Rotation to add
  12834. * @returns the TransformNode.
  12835. */
  12836. addRotation(x: number, y: number, z: number): TransformNode;
  12837. /**
  12838. * Computes the world matrix of the node
  12839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12840. * @returns the world matrix
  12841. */
  12842. computeWorldMatrix(force?: boolean): Matrix;
  12843. protected _afterComputeWorldMatrix(): void;
  12844. /**
  12845. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12846. * @param func callback function to add
  12847. *
  12848. * @returns the TransformNode.
  12849. */
  12850. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12851. /**
  12852. * Removes a registered callback function.
  12853. * @param func callback function to remove
  12854. * @returns the TransformNode.
  12855. */
  12856. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12857. /**
  12858. * Gets the position of the current mesh in camera space
  12859. * @param camera defines the camera to use
  12860. * @returns a position
  12861. */
  12862. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12863. /**
  12864. * Returns the distance from the mesh to the active camera
  12865. * @param camera defines the camera to use
  12866. * @returns the distance
  12867. */
  12868. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12869. /**
  12870. * Clone the current transform node
  12871. * @param name Name of the new clone
  12872. * @param newParent New parent for the clone
  12873. * @param doNotCloneChildren Do not clone children hierarchy
  12874. * @returns the new transform node
  12875. */
  12876. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12877. /**
  12878. * Serializes the objects information.
  12879. * @param currentSerializationObject defines the object to serialize in
  12880. * @returns the serialized object
  12881. */
  12882. serialize(currentSerializationObject?: any): any;
  12883. /**
  12884. * Returns a new TransformNode object parsed from the source provided.
  12885. * @param parsedTransformNode is the source.
  12886. * @param scene the scne the object belongs to
  12887. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12888. * @returns a new TransformNode object parsed from the source provided.
  12889. */
  12890. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12891. /**
  12892. * Get all child-transformNodes of this node
  12893. * @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
  12894. * @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
  12895. * @returns an array of TransformNode
  12896. */
  12897. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12898. /**
  12899. * Releases resources associated with this transform node.
  12900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12902. */
  12903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12904. }
  12905. }
  12906. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12907. import { Observable } from "babylonjs/Misc/observable";
  12908. import { Nullable } from "babylonjs/types";
  12909. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12910. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12912. import { Ray } from "babylonjs/Culling/ray";
  12913. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12914. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12915. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12916. /**
  12917. * Defines the types of pose enabled controllers that are supported
  12918. */
  12919. export enum PoseEnabledControllerType {
  12920. /**
  12921. * HTC Vive
  12922. */
  12923. VIVE = 0,
  12924. /**
  12925. * Oculus Rift
  12926. */
  12927. OCULUS = 1,
  12928. /**
  12929. * Windows mixed reality
  12930. */
  12931. WINDOWS = 2,
  12932. /**
  12933. * Samsung gear VR
  12934. */
  12935. GEAR_VR = 3,
  12936. /**
  12937. * Google Daydream
  12938. */
  12939. DAYDREAM = 4,
  12940. /**
  12941. * Generic
  12942. */
  12943. GENERIC = 5
  12944. }
  12945. /**
  12946. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12947. */
  12948. export interface MutableGamepadButton {
  12949. /**
  12950. * Value of the button/trigger
  12951. */
  12952. value: number;
  12953. /**
  12954. * If the button/trigger is currently touched
  12955. */
  12956. touched: boolean;
  12957. /**
  12958. * If the button/trigger is currently pressed
  12959. */
  12960. pressed: boolean;
  12961. }
  12962. /**
  12963. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12964. * @hidden
  12965. */
  12966. export interface ExtendedGamepadButton extends GamepadButton {
  12967. /**
  12968. * If the button/trigger is currently pressed
  12969. */
  12970. readonly pressed: boolean;
  12971. /**
  12972. * If the button/trigger is currently touched
  12973. */
  12974. readonly touched: boolean;
  12975. /**
  12976. * Value of the button/trigger
  12977. */
  12978. readonly value: number;
  12979. }
  12980. /** @hidden */
  12981. export interface _GamePadFactory {
  12982. /**
  12983. * Returns wether or not the current gamepad can be created for this type of controller.
  12984. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12985. * @returns true if it can be created, otherwise false
  12986. */
  12987. canCreate(gamepadInfo: any): boolean;
  12988. /**
  12989. * Creates a new instance of the Gamepad.
  12990. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12991. * @returns the new gamepad instance
  12992. */
  12993. create(gamepadInfo: any): Gamepad;
  12994. }
  12995. /**
  12996. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12997. */
  12998. export class PoseEnabledControllerHelper {
  12999. /** @hidden */
  13000. static _ControllerFactories: _GamePadFactory[];
  13001. /** @hidden */
  13002. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13003. /**
  13004. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13005. * @param vrGamepad the gamepad to initialized
  13006. * @returns a vr controller of the type the gamepad identified as
  13007. */
  13008. static InitiateController(vrGamepad: any): Gamepad;
  13009. }
  13010. /**
  13011. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13012. */
  13013. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13014. private _deviceRoomPosition;
  13015. private _deviceRoomRotationQuaternion;
  13016. /**
  13017. * The device position in babylon space
  13018. */
  13019. devicePosition: Vector3;
  13020. /**
  13021. * The device rotation in babylon space
  13022. */
  13023. deviceRotationQuaternion: Quaternion;
  13024. /**
  13025. * The scale factor of the device in babylon space
  13026. */
  13027. deviceScaleFactor: number;
  13028. /**
  13029. * (Likely devicePosition should be used instead) The device position in its room space
  13030. */
  13031. position: Vector3;
  13032. /**
  13033. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13034. */
  13035. rotationQuaternion: Quaternion;
  13036. /**
  13037. * The type of controller (Eg. Windows mixed reality)
  13038. */
  13039. controllerType: PoseEnabledControllerType;
  13040. protected _calculatedPosition: Vector3;
  13041. private _calculatedRotation;
  13042. /**
  13043. * The raw pose from the device
  13044. */
  13045. rawPose: DevicePose;
  13046. private _trackPosition;
  13047. private _maxRotationDistFromHeadset;
  13048. private _draggedRoomRotation;
  13049. /**
  13050. * @hidden
  13051. */
  13052. _disableTrackPosition(fixedPosition: Vector3): void;
  13053. /**
  13054. * Internal, the mesh attached to the controller
  13055. * @hidden
  13056. */
  13057. _mesh: Nullable<AbstractMesh>;
  13058. private _poseControlledCamera;
  13059. private _leftHandSystemQuaternion;
  13060. /**
  13061. * Internal, matrix used to convert room space to babylon space
  13062. * @hidden
  13063. */
  13064. _deviceToWorld: Matrix;
  13065. /**
  13066. * Node to be used when casting a ray from the controller
  13067. * @hidden
  13068. */
  13069. _pointingPoseNode: Nullable<TransformNode>;
  13070. /**
  13071. * Name of the child mesh that can be used to cast a ray from the controller
  13072. */
  13073. static readonly POINTING_POSE: string;
  13074. /**
  13075. * Creates a new PoseEnabledController from a gamepad
  13076. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13077. */
  13078. constructor(browserGamepad: any);
  13079. private _workingMatrix;
  13080. /**
  13081. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13082. */
  13083. update(): void;
  13084. /**
  13085. * Updates only the pose device and mesh without doing any button event checking
  13086. */
  13087. protected _updatePoseAndMesh(): void;
  13088. /**
  13089. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13090. * @param poseData raw pose fromthe device
  13091. */
  13092. updateFromDevice(poseData: DevicePose): void;
  13093. /**
  13094. * @hidden
  13095. */
  13096. _meshAttachedObservable: Observable<AbstractMesh>;
  13097. /**
  13098. * Attaches a mesh to the controller
  13099. * @param mesh the mesh to be attached
  13100. */
  13101. attachToMesh(mesh: AbstractMesh): void;
  13102. /**
  13103. * Attaches the controllers mesh to a camera
  13104. * @param camera the camera the mesh should be attached to
  13105. */
  13106. attachToPoseControlledCamera(camera: TargetCamera): void;
  13107. /**
  13108. * Disposes of the controller
  13109. */
  13110. dispose(): void;
  13111. /**
  13112. * The mesh that is attached to the controller
  13113. */
  13114. readonly mesh: Nullable<AbstractMesh>;
  13115. /**
  13116. * Gets the ray of the controller in the direction the controller is pointing
  13117. * @param length the length the resulting ray should be
  13118. * @returns a ray in the direction the controller is pointing
  13119. */
  13120. getForwardRay(length?: number): Ray;
  13121. }
  13122. }
  13123. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13124. import { Observable } from "babylonjs/Misc/observable";
  13125. import { Scene } from "babylonjs/scene";
  13126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13127. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13128. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13129. /**
  13130. * Defines the WebVRController object that represents controllers tracked in 3D space
  13131. */
  13132. export abstract class WebVRController extends PoseEnabledController {
  13133. /**
  13134. * Internal, the default controller model for the controller
  13135. */
  13136. protected _defaultModel: AbstractMesh;
  13137. /**
  13138. * Fired when the trigger state has changed
  13139. */
  13140. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13141. /**
  13142. * Fired when the main button state has changed
  13143. */
  13144. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13145. /**
  13146. * Fired when the secondary button state has changed
  13147. */
  13148. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13149. /**
  13150. * Fired when the pad state has changed
  13151. */
  13152. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13153. /**
  13154. * Fired when controllers stick values have changed
  13155. */
  13156. onPadValuesChangedObservable: Observable<StickValues>;
  13157. /**
  13158. * Array of button availible on the controller
  13159. */
  13160. protected _buttons: Array<MutableGamepadButton>;
  13161. private _onButtonStateChange;
  13162. /**
  13163. * Fired when a controller button's state has changed
  13164. * @param callback the callback containing the button that was modified
  13165. */
  13166. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13167. /**
  13168. * X and Y axis corrisponding to the controllers joystick
  13169. */
  13170. pad: StickValues;
  13171. /**
  13172. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13173. */
  13174. hand: string;
  13175. /**
  13176. * The default controller model for the controller
  13177. */
  13178. readonly defaultModel: AbstractMesh;
  13179. /**
  13180. * Creates a new WebVRController from a gamepad
  13181. * @param vrGamepad the gamepad that the WebVRController should be created from
  13182. */
  13183. constructor(vrGamepad: any);
  13184. /**
  13185. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13186. */
  13187. update(): void;
  13188. /**
  13189. * Function to be called when a button is modified
  13190. */
  13191. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13192. /**
  13193. * Loads a mesh and attaches it to the controller
  13194. * @param scene the scene the mesh should be added to
  13195. * @param meshLoaded callback for when the mesh has been loaded
  13196. */
  13197. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13198. private _setButtonValue;
  13199. private _changes;
  13200. private _checkChanges;
  13201. /**
  13202. * Disposes of th webVRCOntroller
  13203. */
  13204. dispose(): void;
  13205. }
  13206. }
  13207. declare module "babylonjs/Lights/hemisphericLight" {
  13208. import { Nullable } from "babylonjs/types";
  13209. import { Scene } from "babylonjs/scene";
  13210. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13211. import { Effect } from "babylonjs/Materials/effect";
  13212. import { Light } from "babylonjs/Lights/light";
  13213. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13214. /**
  13215. * The HemisphericLight simulates the ambient environment light,
  13216. * so the passed direction is the light reflection direction, not the incoming direction.
  13217. */
  13218. export class HemisphericLight extends Light {
  13219. /**
  13220. * The groundColor is the light in the opposite direction to the one specified during creation.
  13221. * 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.
  13222. */
  13223. groundColor: Color3;
  13224. /**
  13225. * The light reflection direction, not the incoming direction.
  13226. */
  13227. direction: Vector3;
  13228. /**
  13229. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13230. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13231. * The HemisphericLight can't cast shadows.
  13232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13233. * @param name The friendly name of the light
  13234. * @param direction The direction of the light reflection
  13235. * @param scene The scene the light belongs to
  13236. */
  13237. constructor(name: string, direction: Vector3, scene: Scene);
  13238. protected _buildUniformLayout(): void;
  13239. /**
  13240. * Returns the string "HemisphericLight".
  13241. * @return The class name
  13242. */
  13243. getClassName(): string;
  13244. /**
  13245. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13246. * Returns the updated direction.
  13247. * @param target The target the direction should point to
  13248. * @return The computed direction
  13249. */
  13250. setDirectionToTarget(target: Vector3): Vector3;
  13251. /**
  13252. * Returns the shadow generator associated to the light.
  13253. * @returns Always null for hemispheric lights because it does not support shadows.
  13254. */
  13255. getShadowGenerator(): Nullable<IShadowGenerator>;
  13256. /**
  13257. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13258. * @param effect The effect to update
  13259. * @param lightIndex The index of the light in the effect to update
  13260. * @returns The hemispheric light
  13261. */
  13262. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13263. /**
  13264. * Computes the world matrix of the node
  13265. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13266. * @param useWasUpdatedFlag defines a reserved property
  13267. * @returns the world matrix
  13268. */
  13269. computeWorldMatrix(): Matrix;
  13270. /**
  13271. * Returns the integer 3.
  13272. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13273. */
  13274. getTypeID(): number;
  13275. /**
  13276. * Prepares the list of defines specific to the light type.
  13277. * @param defines the list of defines
  13278. * @param lightIndex defines the index of the light for the effect
  13279. */
  13280. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13281. }
  13282. }
  13283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13284. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13285. import { Nullable } from "babylonjs/types";
  13286. import { Observable } from "babylonjs/Misc/observable";
  13287. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13288. import { Scene } from "babylonjs/scene";
  13289. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13290. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13291. import { Node } from "babylonjs/node";
  13292. import { Ray } from "babylonjs/Culling/ray";
  13293. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13294. /**
  13295. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13296. * IMPORTANT!! The data is right-hand data.
  13297. * @export
  13298. * @interface DevicePose
  13299. */
  13300. export interface DevicePose {
  13301. /**
  13302. * The position of the device, values in array are [x,y,z].
  13303. */
  13304. readonly position: Nullable<Float32Array>;
  13305. /**
  13306. * The linearVelocity of the device, values in array are [x,y,z].
  13307. */
  13308. readonly linearVelocity: Nullable<Float32Array>;
  13309. /**
  13310. * The linearAcceleration of the device, values in array are [x,y,z].
  13311. */
  13312. readonly linearAcceleration: Nullable<Float32Array>;
  13313. /**
  13314. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13315. */
  13316. readonly orientation: Nullable<Float32Array>;
  13317. /**
  13318. * The angularVelocity of the device, values in array are [x,y,z].
  13319. */
  13320. readonly angularVelocity: Nullable<Float32Array>;
  13321. /**
  13322. * The angularAcceleration of the device, values in array are [x,y,z].
  13323. */
  13324. readonly angularAcceleration: Nullable<Float32Array>;
  13325. }
  13326. /**
  13327. * Interface representing a pose controlled object in Babylon.
  13328. * A pose controlled object has both regular pose values as well as pose values
  13329. * from an external device such as a VR head mounted display
  13330. */
  13331. export interface PoseControlled {
  13332. /**
  13333. * The position of the object in babylon space.
  13334. */
  13335. position: Vector3;
  13336. /**
  13337. * The rotation quaternion of the object in babylon space.
  13338. */
  13339. rotationQuaternion: Quaternion;
  13340. /**
  13341. * The position of the device in babylon space.
  13342. */
  13343. devicePosition?: Vector3;
  13344. /**
  13345. * The rotation quaternion of the device in babylon space.
  13346. */
  13347. deviceRotationQuaternion: Quaternion;
  13348. /**
  13349. * The raw pose coming from the device.
  13350. */
  13351. rawPose: Nullable<DevicePose>;
  13352. /**
  13353. * The scale of the device to be used when translating from device space to babylon space.
  13354. */
  13355. deviceScaleFactor: number;
  13356. /**
  13357. * Updates the poseControlled values based on the input device pose.
  13358. * @param poseData the pose data to update the object with
  13359. */
  13360. updateFromDevice(poseData: DevicePose): void;
  13361. }
  13362. /**
  13363. * Set of options to customize the webVRCamera
  13364. */
  13365. export interface WebVROptions {
  13366. /**
  13367. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13368. */
  13369. trackPosition?: boolean;
  13370. /**
  13371. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13372. */
  13373. positionScale?: number;
  13374. /**
  13375. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13376. */
  13377. displayName?: string;
  13378. /**
  13379. * Should the native controller meshes be initialized. (default: true)
  13380. */
  13381. controllerMeshes?: boolean;
  13382. /**
  13383. * Creating a default HemiLight only on controllers. (default: true)
  13384. */
  13385. defaultLightingOnControllers?: boolean;
  13386. /**
  13387. * If you don't want to use the default VR button of the helper. (default: false)
  13388. */
  13389. useCustomVRButton?: boolean;
  13390. /**
  13391. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13392. */
  13393. customVRButton?: HTMLButtonElement;
  13394. /**
  13395. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13396. */
  13397. rayLength?: number;
  13398. /**
  13399. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13400. */
  13401. defaultHeight?: number;
  13402. }
  13403. /**
  13404. * This represents a WebVR camera.
  13405. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13406. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13407. */
  13408. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13409. private webVROptions;
  13410. /**
  13411. * @hidden
  13412. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13413. */
  13414. _vrDevice: any;
  13415. /**
  13416. * The rawPose of the vrDevice.
  13417. */
  13418. rawPose: Nullable<DevicePose>;
  13419. private _onVREnabled;
  13420. private _specsVersion;
  13421. private _attached;
  13422. private _frameData;
  13423. protected _descendants: Array<Node>;
  13424. private _deviceRoomPosition;
  13425. /** @hidden */
  13426. _deviceRoomRotationQuaternion: Quaternion;
  13427. private _standingMatrix;
  13428. /**
  13429. * Represents device position in babylon space.
  13430. */
  13431. devicePosition: Vector3;
  13432. /**
  13433. * Represents device rotation in babylon space.
  13434. */
  13435. deviceRotationQuaternion: Quaternion;
  13436. /**
  13437. * The scale of the device to be used when translating from device space to babylon space.
  13438. */
  13439. deviceScaleFactor: number;
  13440. private _deviceToWorld;
  13441. private _worldToDevice;
  13442. /**
  13443. * References to the webVR controllers for the vrDevice.
  13444. */
  13445. controllers: Array<WebVRController>;
  13446. /**
  13447. * Emits an event when a controller is attached.
  13448. */
  13449. onControllersAttachedObservable: Observable<WebVRController[]>;
  13450. /**
  13451. * Emits an event when a controller's mesh has been loaded;
  13452. */
  13453. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13454. /**
  13455. * Emits an event when the HMD's pose has been updated.
  13456. */
  13457. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13458. private _poseSet;
  13459. /**
  13460. * If the rig cameras be used as parent instead of this camera.
  13461. */
  13462. rigParenting: boolean;
  13463. private _lightOnControllers;
  13464. private _defaultHeight?;
  13465. /**
  13466. * Instantiates a WebVRFreeCamera.
  13467. * @param name The name of the WebVRFreeCamera
  13468. * @param position The starting anchor position for the camera
  13469. * @param scene The scene the camera belongs to
  13470. * @param webVROptions a set of customizable options for the webVRCamera
  13471. */
  13472. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13473. /**
  13474. * Gets the device distance from the ground in meters.
  13475. * @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.
  13476. */
  13477. deviceDistanceToRoomGround(): number;
  13478. /**
  13479. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13480. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13481. */
  13482. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13483. /**
  13484. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13485. * @returns A promise with a boolean set to if the standing matrix is supported.
  13486. */
  13487. useStandingMatrixAsync(): Promise<boolean>;
  13488. /**
  13489. * Disposes the camera
  13490. */
  13491. dispose(): void;
  13492. /**
  13493. * Gets a vrController by name.
  13494. * @param name The name of the controller to retreive
  13495. * @returns the controller matching the name specified or null if not found
  13496. */
  13497. getControllerByName(name: string): Nullable<WebVRController>;
  13498. private _leftController;
  13499. /**
  13500. * The controller corrisponding to the users left hand.
  13501. */
  13502. readonly leftController: Nullable<WebVRController>;
  13503. private _rightController;
  13504. /**
  13505. * The controller corrisponding to the users right hand.
  13506. */
  13507. readonly rightController: Nullable<WebVRController>;
  13508. /**
  13509. * Casts a ray forward from the vrCamera's gaze.
  13510. * @param length Length of the ray (default: 100)
  13511. * @returns the ray corrisponding to the gaze
  13512. */
  13513. getForwardRay(length?: number): Ray;
  13514. /**
  13515. * @hidden
  13516. * Updates the camera based on device's frame data
  13517. */
  13518. _checkInputs(): void;
  13519. /**
  13520. * Updates the poseControlled values based on the input device pose.
  13521. * @param poseData Pose coming from the device
  13522. */
  13523. updateFromDevice(poseData: DevicePose): void;
  13524. private _htmlElementAttached;
  13525. private _detachIfAttached;
  13526. /**
  13527. * WebVR's attach control will start broadcasting frames to the device.
  13528. * Note that in certain browsers (chrome for example) this function must be called
  13529. * within a user-interaction callback. Example:
  13530. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13531. *
  13532. * @param element html element to attach the vrDevice to
  13533. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13534. */
  13535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13536. /**
  13537. * Detaches the camera from the html element and disables VR
  13538. *
  13539. * @param element html element to detach from
  13540. */
  13541. detachControl(element: HTMLElement): void;
  13542. /**
  13543. * @returns the name of this class
  13544. */
  13545. getClassName(): string;
  13546. /**
  13547. * Calls resetPose on the vrDisplay
  13548. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13549. */
  13550. resetToCurrentRotation(): void;
  13551. /**
  13552. * @hidden
  13553. * Updates the rig cameras (left and right eye)
  13554. */
  13555. _updateRigCameras(): void;
  13556. private _workingVector;
  13557. private _oneVector;
  13558. private _workingMatrix;
  13559. private updateCacheCalled;
  13560. private _correctPositionIfNotTrackPosition;
  13561. /**
  13562. * @hidden
  13563. * Updates the cached values of the camera
  13564. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13565. */
  13566. _updateCache(ignoreParentClass?: boolean): void;
  13567. /**
  13568. * @hidden
  13569. * Get current device position in babylon world
  13570. */
  13571. _computeDevicePosition(): void;
  13572. /**
  13573. * Updates the current device position and rotation in the babylon world
  13574. */
  13575. update(): void;
  13576. /**
  13577. * @hidden
  13578. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13579. * @returns an identity matrix
  13580. */
  13581. _getViewMatrix(): Matrix;
  13582. private _tmpMatrix;
  13583. /**
  13584. * This function is called by the two RIG cameras.
  13585. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13586. * @hidden
  13587. */
  13588. _getWebVRViewMatrix(): Matrix;
  13589. /** @hidden */
  13590. _getWebVRProjectionMatrix(): Matrix;
  13591. private _onGamepadConnectedObserver;
  13592. private _onGamepadDisconnectedObserver;
  13593. private _updateCacheWhenTrackingDisabledObserver;
  13594. /**
  13595. * Initializes the controllers and their meshes
  13596. */
  13597. initControllers(): void;
  13598. }
  13599. }
  13600. declare module "babylonjs/PostProcesses/postProcess" {
  13601. import { Nullable } from "babylonjs/types";
  13602. import { SmartArray } from "babylonjs/Misc/smartArray";
  13603. import { Observable } from "babylonjs/Misc/observable";
  13604. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13605. import { Camera } from "babylonjs/Cameras/camera";
  13606. import { Effect } from "babylonjs/Materials/effect";
  13607. import "babylonjs/Shaders/postprocess.vertex";
  13608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13609. import { Engine } from "babylonjs/Engines/engine";
  13610. /**
  13611. * Size options for a post process
  13612. */
  13613. export type PostProcessOptions = {
  13614. width: number;
  13615. height: number;
  13616. };
  13617. /**
  13618. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13619. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13620. */
  13621. export class PostProcess {
  13622. /** Name of the PostProcess. */
  13623. name: string;
  13624. /**
  13625. * Width of the texture to apply the post process on
  13626. */
  13627. width: number;
  13628. /**
  13629. * Height of the texture to apply the post process on
  13630. */
  13631. height: number;
  13632. /**
  13633. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13634. * @hidden
  13635. */
  13636. _outputTexture: Nullable<InternalTexture>;
  13637. /**
  13638. * Sampling mode used by the shader
  13639. * See https://doc.babylonjs.com/classes/3.1/texture
  13640. */
  13641. renderTargetSamplingMode: number;
  13642. /**
  13643. * Clear color to use when screen clearing
  13644. */
  13645. clearColor: Color4;
  13646. /**
  13647. * If the buffer needs to be cleared before applying the post process. (default: true)
  13648. * Should be set to false if shader will overwrite all previous pixels.
  13649. */
  13650. autoClear: boolean;
  13651. /**
  13652. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13653. */
  13654. alphaMode: number;
  13655. /**
  13656. * Sets the setAlphaBlendConstants of the babylon engine
  13657. */
  13658. alphaConstants: Color4;
  13659. /**
  13660. * Animations to be used for the post processing
  13661. */
  13662. animations: import("babylonjs/Animations/animation").Animation[];
  13663. /**
  13664. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13665. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13666. */
  13667. enablePixelPerfectMode: boolean;
  13668. /**
  13669. * Force the postprocess to be applied without taking in account viewport
  13670. */
  13671. forceFullscreenViewport: boolean;
  13672. /**
  13673. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13674. *
  13675. * | Value | Type | Description |
  13676. * | ----- | ----------------------------------- | ----------- |
  13677. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13678. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13679. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13680. *
  13681. */
  13682. scaleMode: number;
  13683. /**
  13684. * Force textures to be a power of two (default: false)
  13685. */
  13686. alwaysForcePOT: boolean;
  13687. private _samples;
  13688. /**
  13689. * Number of sample textures (default: 1)
  13690. */
  13691. samples: number;
  13692. /**
  13693. * Modify the scale of the post process to be the same as the viewport (default: false)
  13694. */
  13695. adaptScaleToCurrentViewport: boolean;
  13696. private _camera;
  13697. private _scene;
  13698. private _engine;
  13699. private _options;
  13700. private _reusable;
  13701. private _textureType;
  13702. /**
  13703. * Smart array of input and output textures for the post process.
  13704. * @hidden
  13705. */
  13706. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13707. /**
  13708. * The index in _textures that corresponds to the output texture.
  13709. * @hidden
  13710. */
  13711. _currentRenderTextureInd: number;
  13712. private _effect;
  13713. private _samplers;
  13714. private _fragmentUrl;
  13715. private _vertexUrl;
  13716. private _parameters;
  13717. private _scaleRatio;
  13718. protected _indexParameters: any;
  13719. private _shareOutputWithPostProcess;
  13720. private _texelSize;
  13721. private _forcedOutputTexture;
  13722. /**
  13723. * Returns the fragment url or shader name used in the post process.
  13724. * @returns the fragment url or name in the shader store.
  13725. */
  13726. getEffectName(): string;
  13727. /**
  13728. * An event triggered when the postprocess is activated.
  13729. */
  13730. onActivateObservable: Observable<Camera>;
  13731. private _onActivateObserver;
  13732. /**
  13733. * A function that is added to the onActivateObservable
  13734. */
  13735. onActivate: Nullable<(camera: Camera) => void>;
  13736. /**
  13737. * An event triggered when the postprocess changes its size.
  13738. */
  13739. onSizeChangedObservable: Observable<PostProcess>;
  13740. private _onSizeChangedObserver;
  13741. /**
  13742. * A function that is added to the onSizeChangedObservable
  13743. */
  13744. onSizeChanged: (postProcess: PostProcess) => void;
  13745. /**
  13746. * An event triggered when the postprocess applies its effect.
  13747. */
  13748. onApplyObservable: Observable<Effect>;
  13749. private _onApplyObserver;
  13750. /**
  13751. * A function that is added to the onApplyObservable
  13752. */
  13753. onApply: (effect: Effect) => void;
  13754. /**
  13755. * An event triggered before rendering the postprocess
  13756. */
  13757. onBeforeRenderObservable: Observable<Effect>;
  13758. private _onBeforeRenderObserver;
  13759. /**
  13760. * A function that is added to the onBeforeRenderObservable
  13761. */
  13762. onBeforeRender: (effect: Effect) => void;
  13763. /**
  13764. * An event triggered after rendering the postprocess
  13765. */
  13766. onAfterRenderObservable: Observable<Effect>;
  13767. private _onAfterRenderObserver;
  13768. /**
  13769. * A function that is added to the onAfterRenderObservable
  13770. */
  13771. onAfterRender: (efect: Effect) => void;
  13772. /**
  13773. * 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
  13774. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13775. */
  13776. inputTexture: InternalTexture;
  13777. /**
  13778. * Gets the camera which post process is applied to.
  13779. * @returns The camera the post process is applied to.
  13780. */
  13781. getCamera(): Camera;
  13782. /**
  13783. * Gets the texel size of the postprocess.
  13784. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13785. */
  13786. readonly texelSize: Vector2;
  13787. /**
  13788. * Creates a new instance PostProcess
  13789. * @param name The name of the PostProcess.
  13790. * @param fragmentUrl The url of the fragment shader to be used.
  13791. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13792. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13793. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13794. * @param camera The camera to apply the render pass to.
  13795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13796. * @param engine The engine which the post process will be applied. (default: current engine)
  13797. * @param reusable If the post process can be reused on the same frame. (default: false)
  13798. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13799. * @param textureType Type of textures used when performing the post process. (default: 0)
  13800. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13801. * @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
  13802. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13803. */
  13804. constructor(
  13805. /** Name of the PostProcess. */
  13806. 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);
  13807. /**
  13808. * Gets the engine which this post process belongs to.
  13809. * @returns The engine the post process was enabled with.
  13810. */
  13811. getEngine(): Engine;
  13812. /**
  13813. * The effect that is created when initializing the post process.
  13814. * @returns The created effect corrisponding the the postprocess.
  13815. */
  13816. getEffect(): Effect;
  13817. /**
  13818. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13819. * @param postProcess The post process to share the output with.
  13820. * @returns This post process.
  13821. */
  13822. shareOutputWith(postProcess: PostProcess): PostProcess;
  13823. /**
  13824. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13825. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13826. */
  13827. useOwnOutput(): void;
  13828. /**
  13829. * Updates the effect with the current post process compile time values and recompiles the shader.
  13830. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13831. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13832. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13833. * @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
  13834. * @param onCompiled Called when the shader has been compiled.
  13835. * @param onError Called if there is an error when compiling a shader.
  13836. */
  13837. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13838. /**
  13839. * The post process is reusable if it can be used multiple times within one frame.
  13840. * @returns If the post process is reusable
  13841. */
  13842. isReusable(): boolean;
  13843. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13844. markTextureDirty(): void;
  13845. /**
  13846. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13847. * 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.
  13848. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13849. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13850. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13851. * @returns The target texture that was bound to be written to.
  13852. */
  13853. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13854. /**
  13855. * If the post process is supported.
  13856. */
  13857. readonly isSupported: boolean;
  13858. /**
  13859. * The aspect ratio of the output texture.
  13860. */
  13861. readonly aspectRatio: number;
  13862. /**
  13863. * Get a value indicating if the post-process is ready to be used
  13864. * @returns true if the post-process is ready (shader is compiled)
  13865. */
  13866. isReady(): boolean;
  13867. /**
  13868. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13869. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13870. */
  13871. apply(): Nullable<Effect>;
  13872. private _disposeTextures;
  13873. /**
  13874. * Disposes the post process.
  13875. * @param camera The camera to dispose the post process on.
  13876. */
  13877. dispose(camera?: Camera): void;
  13878. }
  13879. }
  13880. declare module "babylonjs/PostProcesses/postProcessManager" {
  13881. import { Nullable } from "babylonjs/types";
  13882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13884. import { Scene } from "babylonjs/scene";
  13885. /**
  13886. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13887. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13888. */
  13889. export class PostProcessManager {
  13890. private _scene;
  13891. private _indexBuffer;
  13892. private _vertexBuffers;
  13893. /**
  13894. * Creates a new instance PostProcess
  13895. * @param scene The scene that the post process is associated with.
  13896. */
  13897. constructor(scene: Scene);
  13898. private _prepareBuffers;
  13899. private _buildIndexBuffer;
  13900. /**
  13901. * Rebuilds the vertex buffers of the manager.
  13902. * @hidden
  13903. */
  13904. _rebuild(): void;
  13905. /**
  13906. * Prepares a frame to be run through a post process.
  13907. * @param sourceTexture The input texture to the post procesess. (default: null)
  13908. * @param postProcesses An array of post processes to be run. (default: null)
  13909. * @returns True if the post processes were able to be run.
  13910. * @hidden
  13911. */
  13912. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13913. /**
  13914. * Manually render a set of post processes to a texture.
  13915. * @param postProcesses An array of post processes to be run.
  13916. * @param targetTexture The target texture to render to.
  13917. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13918. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13919. * @param lodLevel defines which lod of the texture to render to
  13920. */
  13921. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13922. /**
  13923. * Finalize the result of the output of the postprocesses.
  13924. * @param doNotPresent If true the result will not be displayed to the screen.
  13925. * @param targetTexture The target texture to render to.
  13926. * @param faceIndex The index of the face to bind the target texture to.
  13927. * @param postProcesses The array of post processes to render.
  13928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13929. * @hidden
  13930. */
  13931. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13932. /**
  13933. * Disposes of the post process manager.
  13934. */
  13935. dispose(): void;
  13936. }
  13937. }
  13938. declare module "babylonjs/Materials/Textures/rawTexture" {
  13939. import { Scene } from "babylonjs/scene";
  13940. import { Texture } from "babylonjs/Materials/Textures/texture";
  13941. /**
  13942. * Raw texture can help creating a texture directly from an array of data.
  13943. * This can be super useful if you either get the data from an uncompressed source or
  13944. * if you wish to create your texture pixel by pixel.
  13945. */
  13946. export class RawTexture extends Texture {
  13947. /**
  13948. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13949. */
  13950. format: number;
  13951. private _engine;
  13952. /**
  13953. * Instantiates a new RawTexture.
  13954. * Raw texture can help creating a texture directly from an array of data.
  13955. * This can be super useful if you either get the data from an uncompressed source or
  13956. * if you wish to create your texture pixel by pixel.
  13957. * @param data define the array of data to use to create the texture
  13958. * @param width define the width of the texture
  13959. * @param height define the height of the texture
  13960. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13961. * @param scene define the scene the texture belongs to
  13962. * @param generateMipMaps define whether mip maps should be generated or not
  13963. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13964. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13965. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13966. */
  13967. constructor(data: ArrayBufferView, width: number, height: number,
  13968. /**
  13969. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13970. */
  13971. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13972. /**
  13973. * Updates the texture underlying data.
  13974. * @param data Define the new data of the texture
  13975. */
  13976. update(data: ArrayBufferView): void;
  13977. /**
  13978. * Creates a luminance texture from some data.
  13979. * @param data Define the texture data
  13980. * @param width Define the width of the texture
  13981. * @param height Define the height of the texture
  13982. * @param scene Define the scene the texture belongs to
  13983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13986. * @returns the luminance texture
  13987. */
  13988. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13989. /**
  13990. * Creates a luminance alpha texture from some data.
  13991. * @param data Define the texture data
  13992. * @param width Define the width of the texture
  13993. * @param height Define the height of the texture
  13994. * @param scene Define the scene the texture belongs to
  13995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13998. * @returns the luminance alpha texture
  13999. */
  14000. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14001. /**
  14002. * Creates an alpha texture from some data.
  14003. * @param data Define the texture data
  14004. * @param width Define the width of the texture
  14005. * @param height Define the height of the texture
  14006. * @param scene Define the scene the texture belongs to
  14007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14010. * @returns the alpha texture
  14011. */
  14012. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14013. /**
  14014. * Creates a RGB texture from some data.
  14015. * @param data Define the texture data
  14016. * @param width Define the width of the texture
  14017. * @param height Define the height of the texture
  14018. * @param scene Define the scene the texture belongs to
  14019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14023. * @returns the RGB alpha texture
  14024. */
  14025. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14026. /**
  14027. * Creates a RGBA texture from some data.
  14028. * @param data Define the texture data
  14029. * @param width Define the width of the texture
  14030. * @param height Define the height of the texture
  14031. * @param scene Define the scene the texture belongs to
  14032. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14033. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14034. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14035. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14036. * @returns the RGBA texture
  14037. */
  14038. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14039. /**
  14040. * Creates a R texture from some data.
  14041. * @param data Define the texture data
  14042. * @param width Define the width of the texture
  14043. * @param height Define the height of the texture
  14044. * @param scene Define the scene the texture belongs to
  14045. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14046. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14047. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14048. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14049. * @returns the R texture
  14050. */
  14051. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14052. }
  14053. }
  14054. declare module "babylonjs/Layers/layerSceneComponent" {
  14055. import { Scene } from "babylonjs/scene";
  14056. import { ISceneComponent } from "babylonjs/sceneComponent";
  14057. import { Layer } from "babylonjs/Layers/layer";
  14058. module "babylonjs/abstractScene" {
  14059. interface AbstractScene {
  14060. /**
  14061. * The list of layers (background and foreground) of the scene
  14062. */
  14063. layers: Array<Layer>;
  14064. }
  14065. }
  14066. /**
  14067. * Defines the layer scene component responsible to manage any layers
  14068. * in a given scene.
  14069. */
  14070. export class LayerSceneComponent implements ISceneComponent {
  14071. /**
  14072. * The component name helpfull to identify the component in the list of scene components.
  14073. */
  14074. readonly name: string;
  14075. /**
  14076. * The scene the component belongs to.
  14077. */
  14078. scene: Scene;
  14079. private _engine;
  14080. /**
  14081. * Creates a new instance of the component for the given scene
  14082. * @param scene Defines the scene to register the component in
  14083. */
  14084. constructor(scene: Scene);
  14085. /**
  14086. * Registers the component in a given scene
  14087. */
  14088. register(): void;
  14089. /**
  14090. * Rebuilds the elements related to this component in case of
  14091. * context lost for instance.
  14092. */
  14093. rebuild(): void;
  14094. /**
  14095. * Disposes the component and the associated ressources.
  14096. */
  14097. dispose(): void;
  14098. private _draw;
  14099. private _drawCameraPredicate;
  14100. private _drawCameraBackground;
  14101. private _drawCameraForeground;
  14102. private _drawRenderTargetPredicate;
  14103. private _drawRenderTargetBackground;
  14104. private _drawRenderTargetForeground;
  14105. }
  14106. }
  14107. declare module "babylonjs/Shaders/layer.fragment" {
  14108. /** @hidden */
  14109. export var layerPixelShader: {
  14110. name: string;
  14111. shader: string;
  14112. };
  14113. }
  14114. declare module "babylonjs/Shaders/layer.vertex" {
  14115. /** @hidden */
  14116. export var layerVertexShader: {
  14117. name: string;
  14118. shader: string;
  14119. };
  14120. }
  14121. declare module "babylonjs/Layers/layer" {
  14122. import { Observable } from "babylonjs/Misc/observable";
  14123. import { Nullable } from "babylonjs/types";
  14124. import { Scene } from "babylonjs/scene";
  14125. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14126. import { Texture } from "babylonjs/Materials/Textures/texture";
  14127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14128. import "babylonjs/Shaders/layer.fragment";
  14129. import "babylonjs/Shaders/layer.vertex";
  14130. /**
  14131. * This represents a full screen 2d layer.
  14132. * This can be useful to display a picture in the background of your scene for instance.
  14133. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14134. */
  14135. export class Layer {
  14136. /**
  14137. * Define the name of the layer.
  14138. */
  14139. name: string;
  14140. /**
  14141. * Define the texture the layer should display.
  14142. */
  14143. texture: Nullable<Texture>;
  14144. /**
  14145. * Is the layer in background or foreground.
  14146. */
  14147. isBackground: boolean;
  14148. /**
  14149. * Define the color of the layer (instead of texture).
  14150. */
  14151. color: Color4;
  14152. /**
  14153. * Define the scale of the layer in order to zoom in out of the texture.
  14154. */
  14155. scale: Vector2;
  14156. /**
  14157. * Define an offset for the layer in order to shift the texture.
  14158. */
  14159. offset: Vector2;
  14160. /**
  14161. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14162. */
  14163. alphaBlendingMode: number;
  14164. /**
  14165. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14166. * Alpha test will not mix with the background color in case of transparency.
  14167. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14168. */
  14169. alphaTest: boolean;
  14170. /**
  14171. * Define a mask to restrict the layer to only some of the scene cameras.
  14172. */
  14173. layerMask: number;
  14174. /**
  14175. * Define the list of render target the layer is visible into.
  14176. */
  14177. renderTargetTextures: RenderTargetTexture[];
  14178. /**
  14179. * Define if the layer is only used in renderTarget or if it also
  14180. * renders in the main frame buffer of the canvas.
  14181. */
  14182. renderOnlyInRenderTargetTextures: boolean;
  14183. private _scene;
  14184. private _vertexBuffers;
  14185. private _indexBuffer;
  14186. private _effect;
  14187. private _alphaTestEffect;
  14188. /**
  14189. * An event triggered when the layer is disposed.
  14190. */
  14191. onDisposeObservable: Observable<Layer>;
  14192. private _onDisposeObserver;
  14193. /**
  14194. * Back compatibility with callback before the onDisposeObservable existed.
  14195. * The set callback will be triggered when the layer has been disposed.
  14196. */
  14197. onDispose: () => void;
  14198. /**
  14199. * An event triggered before rendering the scene
  14200. */
  14201. onBeforeRenderObservable: Observable<Layer>;
  14202. private _onBeforeRenderObserver;
  14203. /**
  14204. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14205. * The set callback will be triggered just before rendering the layer.
  14206. */
  14207. onBeforeRender: () => void;
  14208. /**
  14209. * An event triggered after rendering the scene
  14210. */
  14211. onAfterRenderObservable: Observable<Layer>;
  14212. private _onAfterRenderObserver;
  14213. /**
  14214. * Back compatibility with callback before the onAfterRenderObservable existed.
  14215. * The set callback will be triggered just after rendering the layer.
  14216. */
  14217. onAfterRender: () => void;
  14218. /**
  14219. * Instantiates a new layer.
  14220. * This represents a full screen 2d layer.
  14221. * This can be useful to display a picture in the background of your scene for instance.
  14222. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14223. * @param name Define the name of the layer in the scene
  14224. * @param imgUrl Define the url of the texture to display in the layer
  14225. * @param scene Define the scene the layer belongs to
  14226. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14227. * @param color Defines a color for the layer
  14228. */
  14229. constructor(
  14230. /**
  14231. * Define the name of the layer.
  14232. */
  14233. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14234. private _createIndexBuffer;
  14235. /** @hidden */
  14236. _rebuild(): void;
  14237. /**
  14238. * Renders the layer in the scene.
  14239. */
  14240. render(): void;
  14241. /**
  14242. * Disposes and releases the associated ressources.
  14243. */
  14244. dispose(): void;
  14245. }
  14246. }
  14247. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14248. import { Scene } from "babylonjs/scene";
  14249. import { ISceneComponent } from "babylonjs/sceneComponent";
  14250. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14251. module "babylonjs/abstractScene" {
  14252. interface AbstractScene {
  14253. /**
  14254. * The list of procedural textures added to the scene
  14255. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14256. */
  14257. proceduralTextures: Array<ProceduralTexture>;
  14258. }
  14259. }
  14260. /**
  14261. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14262. * in a given scene.
  14263. */
  14264. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14265. /**
  14266. * The component name helpfull to identify the component in the list of scene components.
  14267. */
  14268. readonly name: string;
  14269. /**
  14270. * The scene the component belongs to.
  14271. */
  14272. scene: Scene;
  14273. /**
  14274. * Creates a new instance of the component for the given scene
  14275. * @param scene Defines the scene to register the component in
  14276. */
  14277. constructor(scene: Scene);
  14278. /**
  14279. * Registers the component in a given scene
  14280. */
  14281. register(): void;
  14282. /**
  14283. * Rebuilds the elements related to this component in case of
  14284. * context lost for instance.
  14285. */
  14286. rebuild(): void;
  14287. /**
  14288. * Disposes the component and the associated ressources.
  14289. */
  14290. dispose(): void;
  14291. private _beforeClear;
  14292. }
  14293. }
  14294. declare module "babylonjs/Shaders/procedural.vertex" {
  14295. /** @hidden */
  14296. export var proceduralVertexShader: {
  14297. name: string;
  14298. shader: string;
  14299. };
  14300. }
  14301. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14302. import { Observable } from "babylonjs/Misc/observable";
  14303. import { Nullable } from "babylonjs/types";
  14304. import { Scene } from "babylonjs/scene";
  14305. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14306. import { Effect } from "babylonjs/Materials/effect";
  14307. import { Texture } from "babylonjs/Materials/Textures/texture";
  14308. import "babylonjs/Shaders/procedural.vertex";
  14309. /**
  14310. * 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.
  14311. * This is the base class of any Procedural texture and contains most of the shareable code.
  14312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14313. */
  14314. export class ProceduralTexture extends Texture {
  14315. isCube: boolean;
  14316. /**
  14317. * Define if the texture is enabled or not (disabled texture will not render)
  14318. */
  14319. isEnabled: boolean;
  14320. /**
  14321. * Define if the texture must be cleared before rendering (default is true)
  14322. */
  14323. autoClear: boolean;
  14324. /**
  14325. * Callback called when the texture is generated
  14326. */
  14327. onGenerated: () => void;
  14328. /**
  14329. * Event raised when the texture is generated
  14330. */
  14331. onGeneratedObservable: Observable<ProceduralTexture>;
  14332. /** @hidden */
  14333. _generateMipMaps: boolean;
  14334. /** @hidden **/
  14335. _effect: Effect;
  14336. /** @hidden */
  14337. _textures: {
  14338. [key: string]: Texture;
  14339. };
  14340. private _size;
  14341. private _currentRefreshId;
  14342. private _refreshRate;
  14343. private _vertexBuffers;
  14344. private _indexBuffer;
  14345. private _uniforms;
  14346. private _samplers;
  14347. private _fragment;
  14348. private _floats;
  14349. private _ints;
  14350. private _floatsArrays;
  14351. private _colors3;
  14352. private _colors4;
  14353. private _vectors2;
  14354. private _vectors3;
  14355. private _matrices;
  14356. private _fallbackTexture;
  14357. private _fallbackTextureUsed;
  14358. private _engine;
  14359. private _cachedDefines;
  14360. private _contentUpdateId;
  14361. private _contentData;
  14362. /**
  14363. * Instantiates a new procedural texture.
  14364. * 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.
  14365. * This is the base class of any Procedural texture and contains most of the shareable code.
  14366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14367. * @param name Define the name of the texture
  14368. * @param size Define the size of the texture to create
  14369. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14370. * @param scene Define the scene the texture belongs to
  14371. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14372. * @param generateMipMaps Define if the texture should creates mip maps or not
  14373. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14374. */
  14375. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14376. /**
  14377. * The effect that is created when initializing the post process.
  14378. * @returns The created effect corrisponding the the postprocess.
  14379. */
  14380. getEffect(): Effect;
  14381. /**
  14382. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14383. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14384. */
  14385. getContent(): Nullable<ArrayBufferView>;
  14386. private _createIndexBuffer;
  14387. /** @hidden */
  14388. _rebuild(): void;
  14389. /**
  14390. * Resets the texture in order to recreate its associated resources.
  14391. * This can be called in case of context loss
  14392. */
  14393. reset(): void;
  14394. protected _getDefines(): string;
  14395. /**
  14396. * Is the texture ready to be used ? (rendered at least once)
  14397. * @returns true if ready, otherwise, false.
  14398. */
  14399. isReady(): boolean;
  14400. /**
  14401. * Resets the refresh counter of the texture and start bak from scratch.
  14402. * Could be useful to regenerate the texture if it is setup to render only once.
  14403. */
  14404. resetRefreshCounter(): void;
  14405. /**
  14406. * Set the fragment shader to use in order to render the texture.
  14407. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14408. */
  14409. setFragment(fragment: any): void;
  14410. /**
  14411. * Define the refresh rate of the texture or the rendering frequency.
  14412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14413. */
  14414. refreshRate: number;
  14415. /** @hidden */
  14416. _shouldRender(): boolean;
  14417. /**
  14418. * Get the size the texture is rendering at.
  14419. * @returns the size (texture is always squared)
  14420. */
  14421. getRenderSize(): number;
  14422. /**
  14423. * Resize the texture to new value.
  14424. * @param size Define the new size the texture should have
  14425. * @param generateMipMaps Define whether the new texture should create mip maps
  14426. */
  14427. resize(size: number, generateMipMaps: boolean): void;
  14428. private _checkUniform;
  14429. /**
  14430. * Set a texture in the shader program used to render.
  14431. * @param name Define the name of the uniform samplers as defined in the shader
  14432. * @param texture Define the texture to bind to this sampler
  14433. * @return the texture itself allowing "fluent" like uniform updates
  14434. */
  14435. setTexture(name: string, texture: Texture): ProceduralTexture;
  14436. /**
  14437. * Set a float in the shader.
  14438. * @param name Define the name of the uniform as defined in the shader
  14439. * @param value Define the value to give to the uniform
  14440. * @return the texture itself allowing "fluent" like uniform updates
  14441. */
  14442. setFloat(name: string, value: number): ProceduralTexture;
  14443. /**
  14444. * Set a int in the shader.
  14445. * @param name Define the name of the uniform as defined in the shader
  14446. * @param value Define the value to give to the uniform
  14447. * @return the texture itself allowing "fluent" like uniform updates
  14448. */
  14449. setInt(name: string, value: number): ProceduralTexture;
  14450. /**
  14451. * Set an array of floats in the shader.
  14452. * @param name Define the name of the uniform as defined in the shader
  14453. * @param value Define the value to give to the uniform
  14454. * @return the texture itself allowing "fluent" like uniform updates
  14455. */
  14456. setFloats(name: string, value: number[]): ProceduralTexture;
  14457. /**
  14458. * Set a vec3 in the shader from a Color3.
  14459. * @param name Define the name of the uniform as defined in the shader
  14460. * @param value Define the value to give to the uniform
  14461. * @return the texture itself allowing "fluent" like uniform updates
  14462. */
  14463. setColor3(name: string, value: Color3): ProceduralTexture;
  14464. /**
  14465. * Set a vec4 in the shader from a Color4.
  14466. * @param name Define the name of the uniform as defined in the shader
  14467. * @param value Define the value to give to the uniform
  14468. * @return the texture itself allowing "fluent" like uniform updates
  14469. */
  14470. setColor4(name: string, value: Color4): ProceduralTexture;
  14471. /**
  14472. * Set a vec2 in the shader from a Vector2.
  14473. * @param name Define the name of the uniform as defined in the shader
  14474. * @param value Define the value to give to the uniform
  14475. * @return the texture itself allowing "fluent" like uniform updates
  14476. */
  14477. setVector2(name: string, value: Vector2): ProceduralTexture;
  14478. /**
  14479. * Set a vec3 in the shader from a Vector3.
  14480. * @param name Define the name of the uniform as defined in the shader
  14481. * @param value Define the value to give to the uniform
  14482. * @return the texture itself allowing "fluent" like uniform updates
  14483. */
  14484. setVector3(name: string, value: Vector3): ProceduralTexture;
  14485. /**
  14486. * Set a mat4 in the shader from a MAtrix.
  14487. * @param name Define the name of the uniform as defined in the shader
  14488. * @param value Define the value to give to the uniform
  14489. * @return the texture itself allowing "fluent" like uniform updates
  14490. */
  14491. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14492. /**
  14493. * Render the texture to its associated render target.
  14494. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14495. */
  14496. render(useCameraPostProcess?: boolean): void;
  14497. /**
  14498. * Clone the texture.
  14499. * @returns the cloned texture
  14500. */
  14501. clone(): ProceduralTexture;
  14502. /**
  14503. * Dispose the texture and release its asoociated resources.
  14504. */
  14505. dispose(): void;
  14506. }
  14507. }
  14508. declare module "babylonjs/Particles/baseParticleSystem" {
  14509. import { Nullable } from "babylonjs/types";
  14510. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14512. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14513. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14514. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14515. import { Scene } from "babylonjs/scene";
  14516. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14517. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14518. import { Texture } from "babylonjs/Materials/Textures/texture";
  14519. import { Animation } from "babylonjs/Animations/animation";
  14520. /**
  14521. * This represents the base class for particle system in Babylon.
  14522. * 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.
  14523. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14524. * @example https://doc.babylonjs.com/babylon101/particles
  14525. */
  14526. export class BaseParticleSystem {
  14527. /**
  14528. * Source color is added to the destination color without alpha affecting the result
  14529. */
  14530. static BLENDMODE_ONEONE: number;
  14531. /**
  14532. * Blend current color and particle color using particle’s alpha
  14533. */
  14534. static BLENDMODE_STANDARD: number;
  14535. /**
  14536. * Add current color and particle color multiplied by particle’s alpha
  14537. */
  14538. static BLENDMODE_ADD: number;
  14539. /**
  14540. * Multiply current color with particle color
  14541. */
  14542. static BLENDMODE_MULTIPLY: number;
  14543. /**
  14544. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14545. */
  14546. static BLENDMODE_MULTIPLYADD: number;
  14547. /**
  14548. * List of animations used by the particle system.
  14549. */
  14550. animations: Animation[];
  14551. /**
  14552. * The id of the Particle system.
  14553. */
  14554. id: string;
  14555. /**
  14556. * The friendly name of the Particle system.
  14557. */
  14558. name: string;
  14559. /**
  14560. * The rendering group used by the Particle system to chose when to render.
  14561. */
  14562. renderingGroupId: number;
  14563. /**
  14564. * The emitter represents the Mesh or position we are attaching the particle system to.
  14565. */
  14566. emitter: Nullable<AbstractMesh | Vector3>;
  14567. /**
  14568. * The maximum number of particles to emit per frame
  14569. */
  14570. emitRate: number;
  14571. /**
  14572. * If you want to launch only a few particles at once, that can be done, as well.
  14573. */
  14574. manualEmitCount: number;
  14575. /**
  14576. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14577. */
  14578. updateSpeed: number;
  14579. /**
  14580. * The amount of time the particle system is running (depends of the overall update speed).
  14581. */
  14582. targetStopDuration: number;
  14583. /**
  14584. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14585. */
  14586. disposeOnStop: boolean;
  14587. /**
  14588. * Minimum power of emitting particles.
  14589. */
  14590. minEmitPower: number;
  14591. /**
  14592. * Maximum power of emitting particles.
  14593. */
  14594. maxEmitPower: number;
  14595. /**
  14596. * Minimum life time of emitting particles.
  14597. */
  14598. minLifeTime: number;
  14599. /**
  14600. * Maximum life time of emitting particles.
  14601. */
  14602. maxLifeTime: number;
  14603. /**
  14604. * Minimum Size of emitting particles.
  14605. */
  14606. minSize: number;
  14607. /**
  14608. * Maximum Size of emitting particles.
  14609. */
  14610. maxSize: number;
  14611. /**
  14612. * Minimum scale of emitting particles on X axis.
  14613. */
  14614. minScaleX: number;
  14615. /**
  14616. * Maximum scale of emitting particles on X axis.
  14617. */
  14618. maxScaleX: number;
  14619. /**
  14620. * Minimum scale of emitting particles on Y axis.
  14621. */
  14622. minScaleY: number;
  14623. /**
  14624. * Maximum scale of emitting particles on Y axis.
  14625. */
  14626. maxScaleY: number;
  14627. /**
  14628. * Gets or sets the minimal initial rotation in radians.
  14629. */
  14630. minInitialRotation: number;
  14631. /**
  14632. * Gets or sets the maximal initial rotation in radians.
  14633. */
  14634. maxInitialRotation: number;
  14635. /**
  14636. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14637. */
  14638. minAngularSpeed: number;
  14639. /**
  14640. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14641. */
  14642. maxAngularSpeed: number;
  14643. /**
  14644. * The texture used to render each particle. (this can be a spritesheet)
  14645. */
  14646. particleTexture: Nullable<Texture>;
  14647. /**
  14648. * The layer mask we are rendering the particles through.
  14649. */
  14650. layerMask: number;
  14651. /**
  14652. * This can help using your own shader to render the particle system.
  14653. * The according effect will be created
  14654. */
  14655. customShader: any;
  14656. /**
  14657. * By default particle system starts as soon as they are created. This prevents the
  14658. * automatic start to happen and let you decide when to start emitting particles.
  14659. */
  14660. preventAutoStart: boolean;
  14661. private _noiseTexture;
  14662. /**
  14663. * Gets or sets a texture used to add random noise to particle positions
  14664. */
  14665. noiseTexture: Nullable<ProceduralTexture>;
  14666. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14667. noiseStrength: Vector3;
  14668. /**
  14669. * Callback triggered when the particle animation is ending.
  14670. */
  14671. onAnimationEnd: Nullable<() => void>;
  14672. /**
  14673. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14674. */
  14675. blendMode: number;
  14676. /**
  14677. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14678. * to override the particles.
  14679. */
  14680. forceDepthWrite: boolean;
  14681. /** 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 */
  14682. preWarmCycles: number;
  14683. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14684. preWarmStepOffset: number;
  14685. /**
  14686. * 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)
  14687. */
  14688. spriteCellChangeSpeed: number;
  14689. /**
  14690. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14691. */
  14692. startSpriteCellID: number;
  14693. /**
  14694. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14695. */
  14696. endSpriteCellID: number;
  14697. /**
  14698. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14699. */
  14700. spriteCellWidth: number;
  14701. /**
  14702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14703. */
  14704. spriteCellHeight: number;
  14705. /**
  14706. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14707. */
  14708. spriteRandomStartCell: boolean;
  14709. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14710. translationPivot: Vector2;
  14711. /** @hidden */
  14712. protected _isAnimationSheetEnabled: boolean;
  14713. /**
  14714. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14715. */
  14716. beginAnimationOnStart: boolean;
  14717. /**
  14718. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14719. */
  14720. beginAnimationFrom: number;
  14721. /**
  14722. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14723. */
  14724. beginAnimationTo: number;
  14725. /**
  14726. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14727. */
  14728. beginAnimationLoop: boolean;
  14729. /**
  14730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14731. */
  14732. isAnimationSheetEnabled: boolean;
  14733. /**
  14734. * Get hosting scene
  14735. * @returns the scene
  14736. */
  14737. getScene(): Scene;
  14738. /**
  14739. * You can use gravity if you want to give an orientation to your particles.
  14740. */
  14741. gravity: Vector3;
  14742. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14743. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14744. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14745. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14746. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14747. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14748. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14749. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14750. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14751. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14752. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14753. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14754. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14755. /**
  14756. * Defines the delay in milliseconds before starting the system (0 by default)
  14757. */
  14758. startDelay: number;
  14759. /**
  14760. * Gets the current list of drag gradients.
  14761. * You must use addDragGradient and removeDragGradient to udpate this list
  14762. * @returns the list of drag gradients
  14763. */
  14764. getDragGradients(): Nullable<Array<FactorGradient>>;
  14765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14766. limitVelocityDamping: number;
  14767. /**
  14768. * Gets the current list of limit velocity gradients.
  14769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14770. * @returns the list of limit velocity gradients
  14771. */
  14772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14773. /**
  14774. * Gets the current list of color gradients.
  14775. * You must use addColorGradient and removeColorGradient to udpate this list
  14776. * @returns the list of color gradients
  14777. */
  14778. getColorGradients(): Nullable<Array<ColorGradient>>;
  14779. /**
  14780. * Gets the current list of size gradients.
  14781. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14782. * @returns the list of size gradients
  14783. */
  14784. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14785. /**
  14786. * Gets the current list of color remap gradients.
  14787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14788. * @returns the list of color remap gradients
  14789. */
  14790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14791. /**
  14792. * Gets the current list of alpha remap gradients.
  14793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14794. * @returns the list of alpha remap gradients
  14795. */
  14796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14797. /**
  14798. * Gets the current list of life time gradients.
  14799. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14800. * @returns the list of life time gradients
  14801. */
  14802. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14803. /**
  14804. * Gets the current list of angular speed gradients.
  14805. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14806. * @returns the list of angular speed gradients
  14807. */
  14808. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14809. /**
  14810. * Gets the current list of velocity gradients.
  14811. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14812. * @returns the list of velocity gradients
  14813. */
  14814. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14815. /**
  14816. * Gets the current list of start size gradients.
  14817. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14818. * @returns the list of start size gradients
  14819. */
  14820. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14821. /**
  14822. * Gets the current list of emit rate gradients.
  14823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14824. * @returns the list of emit rate gradients
  14825. */
  14826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14827. /**
  14828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14829. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14830. */
  14831. direction1: Vector3;
  14832. /**
  14833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14834. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14835. */
  14836. direction2: Vector3;
  14837. /**
  14838. * 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.
  14839. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14840. */
  14841. minEmitBox: Vector3;
  14842. /**
  14843. * 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.
  14844. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14845. */
  14846. maxEmitBox: Vector3;
  14847. /**
  14848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14849. */
  14850. color1: Color4;
  14851. /**
  14852. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14853. */
  14854. color2: Color4;
  14855. /**
  14856. * Color the particle will have at the end of its lifetime
  14857. */
  14858. colorDead: Color4;
  14859. /**
  14860. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14861. */
  14862. textureMask: Color4;
  14863. /**
  14864. * The particle emitter type defines the emitter used by the particle system.
  14865. * It can be for example box, sphere, or cone...
  14866. */
  14867. particleEmitterType: IParticleEmitterType;
  14868. /** @hidden */
  14869. _isSubEmitter: boolean;
  14870. /**
  14871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14873. */
  14874. billboardMode: number;
  14875. protected _isBillboardBased: boolean;
  14876. /**
  14877. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14878. */
  14879. isBillboardBased: boolean;
  14880. /**
  14881. * The scene the particle system belongs to.
  14882. */
  14883. protected _scene: Scene;
  14884. /**
  14885. * Local cache of defines for image processing.
  14886. */
  14887. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14888. /**
  14889. * Default configuration related to image processing available in the standard Material.
  14890. */
  14891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14892. /**
  14893. * Gets the image processing configuration used either in this material.
  14894. */
  14895. /**
  14896. * Sets the Default image processing configuration used either in the this material.
  14897. *
  14898. * If sets to null, the scene one is in use.
  14899. */
  14900. imageProcessingConfiguration: ImageProcessingConfiguration;
  14901. /**
  14902. * Attaches a new image processing configuration to the Standard Material.
  14903. * @param configuration
  14904. */
  14905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14906. /** @hidden */
  14907. protected _reset(): void;
  14908. /** @hidden */
  14909. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14910. /**
  14911. * Instantiates a particle system.
  14912. * 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.
  14913. * @param name The name of the particle system
  14914. */
  14915. constructor(name: string);
  14916. /**
  14917. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14920. * @returns the emitter
  14921. */
  14922. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14923. /**
  14924. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14925. * @param radius The radius of the hemisphere to emit from
  14926. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14927. * @returns the emitter
  14928. */
  14929. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14930. /**
  14931. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14932. * @param radius The radius of the sphere to emit from
  14933. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14934. * @returns the emitter
  14935. */
  14936. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14937. /**
  14938. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14939. * @param radius The radius of the sphere to emit from
  14940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14942. * @returns the emitter
  14943. */
  14944. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14945. /**
  14946. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14947. * @param radius The radius of the emission cylinder
  14948. * @param height The height of the emission cylinder
  14949. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14950. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14951. * @returns the emitter
  14952. */
  14953. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14954. /**
  14955. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14956. * @param radius The radius of the cylinder to emit from
  14957. * @param height The height of the emission cylinder
  14958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14961. * @returns the emitter
  14962. */
  14963. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14964. /**
  14965. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14966. * @param radius The radius of the cone to emit from
  14967. * @param angle The base angle of the cone
  14968. * @returns the emitter
  14969. */
  14970. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14971. /**
  14972. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14975. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14976. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14977. * @returns the emitter
  14978. */
  14979. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14980. }
  14981. }
  14982. declare module "babylonjs/Particles/subEmitter" {
  14983. import { Scene } from "babylonjs/scene";
  14984. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14985. /**
  14986. * Type of sub emitter
  14987. */
  14988. export enum SubEmitterType {
  14989. /**
  14990. * Attached to the particle over it's lifetime
  14991. */
  14992. ATTACHED = 0,
  14993. /**
  14994. * Created when the particle dies
  14995. */
  14996. END = 1
  14997. }
  14998. /**
  14999. * Sub emitter class used to emit particles from an existing particle
  15000. */
  15001. export class SubEmitter {
  15002. /**
  15003. * the particle system to be used by the sub emitter
  15004. */
  15005. particleSystem: ParticleSystem;
  15006. /**
  15007. * Type of the submitter (Default: END)
  15008. */
  15009. type: SubEmitterType;
  15010. /**
  15011. * 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)
  15012. * Note: This only is supported when using an emitter of type Mesh
  15013. */
  15014. inheritDirection: boolean;
  15015. /**
  15016. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15017. */
  15018. inheritedVelocityAmount: number;
  15019. /**
  15020. * Creates a sub emitter
  15021. * @param particleSystem the particle system to be used by the sub emitter
  15022. */
  15023. constructor(
  15024. /**
  15025. * the particle system to be used by the sub emitter
  15026. */
  15027. particleSystem: ParticleSystem);
  15028. /**
  15029. * Clones the sub emitter
  15030. * @returns the cloned sub emitter
  15031. */
  15032. clone(): SubEmitter;
  15033. /**
  15034. * Serialize current object to a JSON object
  15035. * @returns the serialized object
  15036. */
  15037. serialize(): any;
  15038. /** @hidden */
  15039. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15040. /**
  15041. * Creates a new SubEmitter from a serialized JSON version
  15042. * @param serializationObject defines the JSON object to read from
  15043. * @param scene defines the hosting scene
  15044. * @param rootUrl defines the rootUrl for data loading
  15045. * @returns a new SubEmitter
  15046. */
  15047. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15048. /** Release associated resources */
  15049. dispose(): void;
  15050. }
  15051. }
  15052. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15053. /** @hidden */
  15054. export var clipPlaneFragmentDeclaration: {
  15055. name: string;
  15056. shader: string;
  15057. };
  15058. }
  15059. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15060. /** @hidden */
  15061. export var imageProcessingDeclaration: {
  15062. name: string;
  15063. shader: string;
  15064. };
  15065. }
  15066. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15067. /** @hidden */
  15068. export var imageProcessingFunctions: {
  15069. name: string;
  15070. shader: string;
  15071. };
  15072. }
  15073. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15074. /** @hidden */
  15075. export var clipPlaneFragment: {
  15076. name: string;
  15077. shader: string;
  15078. };
  15079. }
  15080. declare module "babylonjs/Shaders/particles.fragment" {
  15081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15086. /** @hidden */
  15087. export var particlesPixelShader: {
  15088. name: string;
  15089. shader: string;
  15090. };
  15091. }
  15092. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15093. /** @hidden */
  15094. export var clipPlaneVertexDeclaration: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15100. /** @hidden */
  15101. export var clipPlaneVertex: {
  15102. name: string;
  15103. shader: string;
  15104. };
  15105. }
  15106. declare module "babylonjs/Shaders/particles.vertex" {
  15107. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15108. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15109. /** @hidden */
  15110. export var particlesVertexShader: {
  15111. name: string;
  15112. shader: string;
  15113. };
  15114. }
  15115. declare module "babylonjs/Particles/particleSystem" {
  15116. import { Nullable } from "babylonjs/types";
  15117. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15118. import { Observable } from "babylonjs/Misc/observable";
  15119. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15120. import { Effect } from "babylonjs/Materials/effect";
  15121. import { Scene, IDisposable } from "babylonjs/scene";
  15122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15123. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15124. import { Particle } from "babylonjs/Particles/particle";
  15125. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15126. import "babylonjs/Shaders/particles.fragment";
  15127. import "babylonjs/Shaders/particles.vertex";
  15128. /**
  15129. * This represents a particle system in Babylon.
  15130. * 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.
  15131. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15132. * @example https://doc.babylonjs.com/babylon101/particles
  15133. */
  15134. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15135. /**
  15136. * Billboard mode will only apply to Y axis
  15137. */
  15138. static readonly BILLBOARDMODE_Y: number;
  15139. /**
  15140. * Billboard mode will apply to all axes
  15141. */
  15142. static readonly BILLBOARDMODE_ALL: number;
  15143. /**
  15144. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15145. */
  15146. static readonly BILLBOARDMODE_STRETCHED: number;
  15147. /**
  15148. * This function can be defined to provide custom update for active particles.
  15149. * This function will be called instead of regular update (age, position, color, etc.).
  15150. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15151. */
  15152. updateFunction: (particles: Particle[]) => void;
  15153. private _emitterWorldMatrix;
  15154. /**
  15155. * This function can be defined to specify initial direction for every new particle.
  15156. * It by default use the emitterType defined function
  15157. */
  15158. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15159. /**
  15160. * This function can be defined to specify initial position for every new particle.
  15161. * It by default use the emitterType defined function
  15162. */
  15163. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15164. /**
  15165. * @hidden
  15166. */
  15167. _inheritedVelocityOffset: Vector3;
  15168. /**
  15169. * An event triggered when the system is disposed
  15170. */
  15171. onDisposeObservable: Observable<ParticleSystem>;
  15172. private _onDisposeObserver;
  15173. /**
  15174. * Sets a callback that will be triggered when the system is disposed
  15175. */
  15176. onDispose: () => void;
  15177. private _particles;
  15178. private _epsilon;
  15179. private _capacity;
  15180. private _stockParticles;
  15181. private _newPartsExcess;
  15182. private _vertexData;
  15183. private _vertexBuffer;
  15184. private _vertexBuffers;
  15185. private _spriteBuffer;
  15186. private _indexBuffer;
  15187. private _effect;
  15188. private _customEffect;
  15189. private _cachedDefines;
  15190. private _scaledColorStep;
  15191. private _colorDiff;
  15192. private _scaledDirection;
  15193. private _scaledGravity;
  15194. private _currentRenderId;
  15195. private _alive;
  15196. private _useInstancing;
  15197. private _started;
  15198. private _stopped;
  15199. private _actualFrame;
  15200. private _scaledUpdateSpeed;
  15201. private _vertexBufferSize;
  15202. /** @hidden */
  15203. _currentEmitRateGradient: Nullable<FactorGradient>;
  15204. /** @hidden */
  15205. _currentEmitRate1: number;
  15206. /** @hidden */
  15207. _currentEmitRate2: number;
  15208. /** @hidden */
  15209. _currentStartSizeGradient: Nullable<FactorGradient>;
  15210. /** @hidden */
  15211. _currentStartSize1: number;
  15212. /** @hidden */
  15213. _currentStartSize2: number;
  15214. private readonly _rawTextureWidth;
  15215. private _rampGradientsTexture;
  15216. private _useRampGradients;
  15217. /** Gets or sets a boolean indicating that ramp gradients must be used
  15218. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15219. */
  15220. useRampGradients: boolean;
  15221. /**
  15222. * 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.
  15223. * 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: [])
  15224. */
  15225. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15226. private _subEmitters;
  15227. /**
  15228. * @hidden
  15229. * If the particle systems emitter should be disposed when the particle system is disposed
  15230. */
  15231. _disposeEmitterOnDispose: boolean;
  15232. /**
  15233. * The current active Sub-systems, this property is used by the root particle system only.
  15234. */
  15235. activeSubSystems: Array<ParticleSystem>;
  15236. private _rootParticleSystem;
  15237. /**
  15238. * Gets the current list of active particles
  15239. */
  15240. readonly particles: Particle[];
  15241. /**
  15242. * Returns the string "ParticleSystem"
  15243. * @returns a string containing the class name
  15244. */
  15245. getClassName(): string;
  15246. /**
  15247. * Instantiates a particle system.
  15248. * 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.
  15249. * @param name The name of the particle system
  15250. * @param capacity The max number of particles alive at the same time
  15251. * @param scene The scene the particle system belongs to
  15252. * @param customEffect a custom effect used to change the way particles are rendered by default
  15253. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15254. * @param epsilon Offset used to render the particles
  15255. */
  15256. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15257. private _addFactorGradient;
  15258. private _removeFactorGradient;
  15259. /**
  15260. * Adds a new life time gradient
  15261. * @param gradient defines the gradient to use (between 0 and 1)
  15262. * @param factor defines the life time factor to affect to the specified gradient
  15263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15264. * @returns the current particle system
  15265. */
  15266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15267. /**
  15268. * Remove a specific life time gradient
  15269. * @param gradient defines the gradient to remove
  15270. * @returns the current particle system
  15271. */
  15272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15273. /**
  15274. * Adds a new size gradient
  15275. * @param gradient defines the gradient to use (between 0 and 1)
  15276. * @param factor defines the size factor to affect to the specified gradient
  15277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15278. * @returns the current particle system
  15279. */
  15280. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15281. /**
  15282. * Remove a specific size gradient
  15283. * @param gradient defines the gradient to remove
  15284. * @returns the current particle system
  15285. */
  15286. removeSizeGradient(gradient: number): IParticleSystem;
  15287. /**
  15288. * Adds a new color remap gradient
  15289. * @param gradient defines the gradient to use (between 0 and 1)
  15290. * @param min defines the color remap minimal range
  15291. * @param max defines the color remap maximal range
  15292. * @returns the current particle system
  15293. */
  15294. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15295. /**
  15296. * Remove a specific color remap gradient
  15297. * @param gradient defines the gradient to remove
  15298. * @returns the current particle system
  15299. */
  15300. removeColorRemapGradient(gradient: number): IParticleSystem;
  15301. /**
  15302. * Adds a new alpha remap gradient
  15303. * @param gradient defines the gradient to use (between 0 and 1)
  15304. * @param min defines the alpha remap minimal range
  15305. * @param max defines the alpha remap maximal range
  15306. * @returns the current particle system
  15307. */
  15308. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15309. /**
  15310. * Remove a specific alpha remap gradient
  15311. * @param gradient defines the gradient to remove
  15312. * @returns the current particle system
  15313. */
  15314. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15315. /**
  15316. * Adds a new angular speed gradient
  15317. * @param gradient defines the gradient to use (between 0 and 1)
  15318. * @param factor defines the angular speed to affect to the specified gradient
  15319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15320. * @returns the current particle system
  15321. */
  15322. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15323. /**
  15324. * Remove a specific angular speed gradient
  15325. * @param gradient defines the gradient to remove
  15326. * @returns the current particle system
  15327. */
  15328. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15329. /**
  15330. * Adds a new velocity gradient
  15331. * @param gradient defines the gradient to use (between 0 and 1)
  15332. * @param factor defines the velocity to affect to the specified gradient
  15333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15334. * @returns the current particle system
  15335. */
  15336. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15337. /**
  15338. * Remove a specific velocity gradient
  15339. * @param gradient defines the gradient to remove
  15340. * @returns the current particle system
  15341. */
  15342. removeVelocityGradient(gradient: number): IParticleSystem;
  15343. /**
  15344. * Adds a new limit velocity gradient
  15345. * @param gradient defines the gradient to use (between 0 and 1)
  15346. * @param factor defines the limit velocity value to affect to the specified gradient
  15347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15348. * @returns the current particle system
  15349. */
  15350. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15351. /**
  15352. * Remove a specific limit velocity gradient
  15353. * @param gradient defines the gradient to remove
  15354. * @returns the current particle system
  15355. */
  15356. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15357. /**
  15358. * Adds a new drag gradient
  15359. * @param gradient defines the gradient to use (between 0 and 1)
  15360. * @param factor defines the drag value to affect to the specified gradient
  15361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15362. * @returns the current particle system
  15363. */
  15364. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15365. /**
  15366. * Remove a specific drag gradient
  15367. * @param gradient defines the gradient to remove
  15368. * @returns the current particle system
  15369. */
  15370. removeDragGradient(gradient: number): IParticleSystem;
  15371. /**
  15372. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15373. * @param gradient defines the gradient to use (between 0 and 1)
  15374. * @param factor defines the emit rate value to affect to the specified gradient
  15375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15376. * @returns the current particle system
  15377. */
  15378. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15379. /**
  15380. * Remove a specific emit rate gradient
  15381. * @param gradient defines the gradient to remove
  15382. * @returns the current particle system
  15383. */
  15384. removeEmitRateGradient(gradient: number): IParticleSystem;
  15385. /**
  15386. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15387. * @param gradient defines the gradient to use (between 0 and 1)
  15388. * @param factor defines the start size value to affect to the specified gradient
  15389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15390. * @returns the current particle system
  15391. */
  15392. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15393. /**
  15394. * Remove a specific start size gradient
  15395. * @param gradient defines the gradient to remove
  15396. * @returns the current particle system
  15397. */
  15398. removeStartSizeGradient(gradient: number): IParticleSystem;
  15399. private _createRampGradientTexture;
  15400. /**
  15401. * Gets the current list of ramp gradients.
  15402. * You must use addRampGradient and removeRampGradient to udpate this list
  15403. * @returns the list of ramp gradients
  15404. */
  15405. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15406. /**
  15407. * Adds a new ramp gradient used to remap particle colors
  15408. * @param gradient defines the gradient to use (between 0 and 1)
  15409. * @param color defines the color to affect to the specified gradient
  15410. * @returns the current particle system
  15411. */
  15412. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15413. /**
  15414. * Remove a specific ramp gradient
  15415. * @param gradient defines the gradient to remove
  15416. * @returns the current particle system
  15417. */
  15418. removeRampGradient(gradient: number): ParticleSystem;
  15419. /**
  15420. * Adds a new color gradient
  15421. * @param gradient defines the gradient to use (between 0 and 1)
  15422. * @param color1 defines the color to affect to the specified gradient
  15423. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15424. * @returns this particle system
  15425. */
  15426. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15427. /**
  15428. * Remove a specific color gradient
  15429. * @param gradient defines the gradient to remove
  15430. * @returns this particle system
  15431. */
  15432. removeColorGradient(gradient: number): IParticleSystem;
  15433. private _fetchR;
  15434. protected _reset(): void;
  15435. private _resetEffect;
  15436. private _createVertexBuffers;
  15437. private _createIndexBuffer;
  15438. /**
  15439. * Gets the maximum number of particles active at the same time.
  15440. * @returns The max number of active particles.
  15441. */
  15442. getCapacity(): number;
  15443. /**
  15444. * Gets whether there are still active particles in the system.
  15445. * @returns True if it is alive, otherwise false.
  15446. */
  15447. isAlive(): boolean;
  15448. /**
  15449. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15450. * @returns True if it has been started, otherwise false.
  15451. */
  15452. isStarted(): boolean;
  15453. private _prepareSubEmitterInternalArray;
  15454. /**
  15455. * Starts the particle system and begins to emit
  15456. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15457. */
  15458. start(delay?: number): void;
  15459. /**
  15460. * Stops the particle system.
  15461. * @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.
  15462. */
  15463. stop(stopSubEmitters?: boolean): void;
  15464. /**
  15465. * Remove all active particles
  15466. */
  15467. reset(): void;
  15468. /**
  15469. * @hidden (for internal use only)
  15470. */
  15471. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15472. /**
  15473. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15474. * Its lifetime will start back at 0.
  15475. */
  15476. recycleParticle: (particle: Particle) => void;
  15477. private _stopSubEmitters;
  15478. private _createParticle;
  15479. private _removeFromRoot;
  15480. private _emitFromParticle;
  15481. private _update;
  15482. /** @hidden */
  15483. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15484. /** @hidden */
  15485. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15486. /** @hidden */
  15487. private _getEffect;
  15488. /**
  15489. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15490. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15491. */
  15492. animate(preWarmOnly?: boolean): void;
  15493. private _appendParticleVertices;
  15494. /**
  15495. * Rebuilds the particle system.
  15496. */
  15497. rebuild(): void;
  15498. /**
  15499. * Is this system ready to be used/rendered
  15500. * @return true if the system is ready
  15501. */
  15502. isReady(): boolean;
  15503. private _render;
  15504. /**
  15505. * Renders the particle system in its current state.
  15506. * @returns the current number of particles
  15507. */
  15508. render(): number;
  15509. /**
  15510. * Disposes the particle system and free the associated resources
  15511. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15512. */
  15513. dispose(disposeTexture?: boolean): void;
  15514. /**
  15515. * Clones the particle system.
  15516. * @param name The name of the cloned object
  15517. * @param newEmitter The new emitter to use
  15518. * @returns the cloned particle system
  15519. */
  15520. clone(name: string, newEmitter: any): ParticleSystem;
  15521. /**
  15522. * Serializes the particle system to a JSON object.
  15523. * @returns the JSON object
  15524. */
  15525. serialize(): any;
  15526. /** @hidden */
  15527. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15528. /** @hidden */
  15529. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15530. /**
  15531. * Parses a JSON object to create a particle system.
  15532. * @param parsedParticleSystem The JSON object to parse
  15533. * @param scene The scene to create the particle system in
  15534. * @param rootUrl The root url to use to load external dependencies like texture
  15535. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15536. * @returns the Parsed particle system
  15537. */
  15538. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15539. }
  15540. }
  15541. declare module "babylonjs/Particles/particle" {
  15542. import { Nullable } from "babylonjs/types";
  15543. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15544. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15545. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15546. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15547. /**
  15548. * A particle represents one of the element emitted by a particle system.
  15549. * This is mainly define by its coordinates, direction, velocity and age.
  15550. */
  15551. export class Particle {
  15552. /**
  15553. * The particle system the particle belongs to.
  15554. */
  15555. particleSystem: ParticleSystem;
  15556. private static _Count;
  15557. /**
  15558. * Unique ID of the particle
  15559. */
  15560. id: number;
  15561. /**
  15562. * The world position of the particle in the scene.
  15563. */
  15564. position: Vector3;
  15565. /**
  15566. * The world direction of the particle in the scene.
  15567. */
  15568. direction: Vector3;
  15569. /**
  15570. * The color of the particle.
  15571. */
  15572. color: Color4;
  15573. /**
  15574. * The color change of the particle per step.
  15575. */
  15576. colorStep: Color4;
  15577. /**
  15578. * Defines how long will the life of the particle be.
  15579. */
  15580. lifeTime: number;
  15581. /**
  15582. * The current age of the particle.
  15583. */
  15584. age: number;
  15585. /**
  15586. * The current size of the particle.
  15587. */
  15588. size: number;
  15589. /**
  15590. * The current scale of the particle.
  15591. */
  15592. scale: Vector2;
  15593. /**
  15594. * The current angle of the particle.
  15595. */
  15596. angle: number;
  15597. /**
  15598. * Defines how fast is the angle changing.
  15599. */
  15600. angularSpeed: number;
  15601. /**
  15602. * Defines the cell index used by the particle to be rendered from a sprite.
  15603. */
  15604. cellIndex: number;
  15605. /**
  15606. * The information required to support color remapping
  15607. */
  15608. remapData: Vector4;
  15609. /** @hidden */
  15610. _randomCellOffset?: number;
  15611. /** @hidden */
  15612. _initialDirection: Nullable<Vector3>;
  15613. /** @hidden */
  15614. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15615. /** @hidden */
  15616. _initialStartSpriteCellID: number;
  15617. /** @hidden */
  15618. _initialEndSpriteCellID: number;
  15619. /** @hidden */
  15620. _currentColorGradient: Nullable<ColorGradient>;
  15621. /** @hidden */
  15622. _currentColor1: Color4;
  15623. /** @hidden */
  15624. _currentColor2: Color4;
  15625. /** @hidden */
  15626. _currentSizeGradient: Nullable<FactorGradient>;
  15627. /** @hidden */
  15628. _currentSize1: number;
  15629. /** @hidden */
  15630. _currentSize2: number;
  15631. /** @hidden */
  15632. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15633. /** @hidden */
  15634. _currentAngularSpeed1: number;
  15635. /** @hidden */
  15636. _currentAngularSpeed2: number;
  15637. /** @hidden */
  15638. _currentVelocityGradient: Nullable<FactorGradient>;
  15639. /** @hidden */
  15640. _currentVelocity1: number;
  15641. /** @hidden */
  15642. _currentVelocity2: number;
  15643. /** @hidden */
  15644. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15645. /** @hidden */
  15646. _currentLimitVelocity1: number;
  15647. /** @hidden */
  15648. _currentLimitVelocity2: number;
  15649. /** @hidden */
  15650. _currentDragGradient: Nullable<FactorGradient>;
  15651. /** @hidden */
  15652. _currentDrag1: number;
  15653. /** @hidden */
  15654. _currentDrag2: number;
  15655. /** @hidden */
  15656. _randomNoiseCoordinates1: Vector3;
  15657. /** @hidden */
  15658. _randomNoiseCoordinates2: Vector3;
  15659. /**
  15660. * Creates a new instance Particle
  15661. * @param particleSystem the particle system the particle belongs to
  15662. */
  15663. constructor(
  15664. /**
  15665. * The particle system the particle belongs to.
  15666. */
  15667. particleSystem: ParticleSystem);
  15668. private updateCellInfoFromSystem;
  15669. /**
  15670. * Defines how the sprite cell index is updated for the particle
  15671. */
  15672. updateCellIndex(): void;
  15673. /** @hidden */
  15674. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15675. /** @hidden */
  15676. _inheritParticleInfoToSubEmitters(): void;
  15677. /** @hidden */
  15678. _reset(): void;
  15679. /**
  15680. * Copy the properties of particle to another one.
  15681. * @param other the particle to copy the information to.
  15682. */
  15683. copyTo(other: Particle): void;
  15684. }
  15685. }
  15686. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15687. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15688. import { Effect } from "babylonjs/Materials/effect";
  15689. import { Particle } from "babylonjs/Particles/particle";
  15690. /**
  15691. * Particle emitter represents a volume emitting particles.
  15692. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15693. */
  15694. export interface IParticleEmitterType {
  15695. /**
  15696. * Called by the particle System when the direction is computed for the created particle.
  15697. * @param worldMatrix is the world matrix of the particle system
  15698. * @param directionToUpdate is the direction vector to update with the result
  15699. * @param particle is the particle we are computed the direction for
  15700. */
  15701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15702. /**
  15703. * Called by the particle System when the position is computed for the created particle.
  15704. * @param worldMatrix is the world matrix of the particle system
  15705. * @param positionToUpdate is the position vector to update with the result
  15706. * @param particle is the particle we are computed the position for
  15707. */
  15708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15709. /**
  15710. * Clones the current emitter and returns a copy of it
  15711. * @returns the new emitter
  15712. */
  15713. clone(): IParticleEmitterType;
  15714. /**
  15715. * Called by the GPUParticleSystem to setup the update shader
  15716. * @param effect defines the update shader
  15717. */
  15718. applyToShader(effect: Effect): void;
  15719. /**
  15720. * Returns a string to use to update the GPU particles update shader
  15721. * @returns the effect defines string
  15722. */
  15723. getEffectDefines(): string;
  15724. /**
  15725. * Returns a string representing the class name
  15726. * @returns a string containing the class name
  15727. */
  15728. getClassName(): string;
  15729. /**
  15730. * Serializes the particle system to a JSON object.
  15731. * @returns the JSON object
  15732. */
  15733. serialize(): any;
  15734. /**
  15735. * Parse properties from a JSON object
  15736. * @param serializationObject defines the JSON object
  15737. */
  15738. parse(serializationObject: any): void;
  15739. }
  15740. }
  15741. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15742. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15743. import { Effect } from "babylonjs/Materials/effect";
  15744. import { Particle } from "babylonjs/Particles/particle";
  15745. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15746. /**
  15747. * Particle emitter emitting particles from the inside of a box.
  15748. * It emits the particles randomly between 2 given directions.
  15749. */
  15750. export class BoxParticleEmitter implements IParticleEmitterType {
  15751. /**
  15752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15753. */
  15754. direction1: Vector3;
  15755. /**
  15756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15757. */
  15758. direction2: Vector3;
  15759. /**
  15760. * 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.
  15761. */
  15762. minEmitBox: Vector3;
  15763. /**
  15764. * 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.
  15765. */
  15766. maxEmitBox: Vector3;
  15767. /**
  15768. * Creates a new instance BoxParticleEmitter
  15769. */
  15770. constructor();
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. */
  15777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Called by the particle System when the position is computed for the created particle.
  15780. * @param worldMatrix is the world matrix of the particle system
  15781. * @param positionToUpdate is the position vector to update with the result
  15782. * @param particle is the particle we are computed the position for
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): BoxParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "BoxParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15818. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15819. import { Effect } from "babylonjs/Materials/effect";
  15820. import { Particle } from "babylonjs/Particles/particle";
  15821. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15822. /**
  15823. * Particle emitter emitting particles from the inside of a cone.
  15824. * It emits the particles alongside the cone volume from the base to the particle.
  15825. * The emission direction might be randomized.
  15826. */
  15827. export class ConeParticleEmitter implements IParticleEmitterType {
  15828. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15829. directionRandomizer: number;
  15830. private _radius;
  15831. private _angle;
  15832. private _height;
  15833. /**
  15834. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15835. */
  15836. radiusRange: number;
  15837. /**
  15838. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15839. */
  15840. heightRange: number;
  15841. /**
  15842. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15843. */
  15844. emitFromSpawnPointOnly: boolean;
  15845. /**
  15846. * Gets or sets the radius of the emission cone
  15847. */
  15848. radius: number;
  15849. /**
  15850. * Gets or sets the angle of the emission cone
  15851. */
  15852. angle: number;
  15853. private _buildHeight;
  15854. /**
  15855. * Creates a new instance ConeParticleEmitter
  15856. * @param radius the radius of the emission cone (1 by default)
  15857. * @param angle the cone base angle (PI by default)
  15858. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15859. */
  15860. constructor(radius?: number, angle?: number,
  15861. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15862. directionRandomizer?: number);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. */
  15869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15870. /**
  15871. * Called by the particle System when the position is computed for the created particle.
  15872. * @param worldMatrix is the world matrix of the particle system
  15873. * @param positionToUpdate is the position vector to update with the result
  15874. * @param particle is the particle we are computed the position for
  15875. */
  15876. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15877. /**
  15878. * Clones the current emitter and returns a copy of it
  15879. * @returns the new emitter
  15880. */
  15881. clone(): ConeParticleEmitter;
  15882. /**
  15883. * Called by the GPUParticleSystem to setup the update shader
  15884. * @param effect defines the update shader
  15885. */
  15886. applyToShader(effect: Effect): void;
  15887. /**
  15888. * Returns a string to use to update the GPU particles update shader
  15889. * @returns a string containng the defines string
  15890. */
  15891. getEffectDefines(): string;
  15892. /**
  15893. * Returns the string "ConeParticleEmitter"
  15894. * @returns a string containing the class name
  15895. */
  15896. getClassName(): string;
  15897. /**
  15898. * Serializes the particle system to a JSON object.
  15899. * @returns the JSON object
  15900. */
  15901. serialize(): any;
  15902. /**
  15903. * Parse properties from a JSON object
  15904. * @param serializationObject defines the JSON object
  15905. */
  15906. parse(serializationObject: any): void;
  15907. }
  15908. }
  15909. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15910. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15911. import { Effect } from "babylonjs/Materials/effect";
  15912. import { Particle } from "babylonjs/Particles/particle";
  15913. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15914. /**
  15915. * Particle emitter emitting particles from the inside of a cylinder.
  15916. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15917. */
  15918. export class CylinderParticleEmitter implements IParticleEmitterType {
  15919. /**
  15920. * The radius of the emission cylinder.
  15921. */
  15922. radius: number;
  15923. /**
  15924. * The height of the emission cylinder.
  15925. */
  15926. height: number;
  15927. /**
  15928. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15929. */
  15930. radiusRange: number;
  15931. /**
  15932. * How much to randomize the particle direction [0-1].
  15933. */
  15934. directionRandomizer: number;
  15935. /**
  15936. * Creates a new instance CylinderParticleEmitter
  15937. * @param radius the radius of the emission cylinder (1 by default)
  15938. * @param height the height of the emission cylinder (1 by default)
  15939. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15941. */
  15942. constructor(
  15943. /**
  15944. * The radius of the emission cylinder.
  15945. */
  15946. radius?: number,
  15947. /**
  15948. * The height of the emission cylinder.
  15949. */
  15950. height?: number,
  15951. /**
  15952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15953. */
  15954. radiusRange?: number,
  15955. /**
  15956. * How much to randomize the particle direction [0-1].
  15957. */
  15958. directionRandomizer?: number);
  15959. /**
  15960. * Called by the particle System when the direction is computed for the created particle.
  15961. * @param worldMatrix is the world matrix of the particle system
  15962. * @param directionToUpdate is the direction vector to update with the result
  15963. * @param particle is the particle we are computed the direction for
  15964. */
  15965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15966. /**
  15967. * Called by the particle System when the position is computed for the created particle.
  15968. * @param worldMatrix is the world matrix of the particle system
  15969. * @param positionToUpdate is the position vector to update with the result
  15970. * @param particle is the particle we are computed the position for
  15971. */
  15972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15973. /**
  15974. * Clones the current emitter and returns a copy of it
  15975. * @returns the new emitter
  15976. */
  15977. clone(): CylinderParticleEmitter;
  15978. /**
  15979. * Called by the GPUParticleSystem to setup the update shader
  15980. * @param effect defines the update shader
  15981. */
  15982. applyToShader(effect: Effect): void;
  15983. /**
  15984. * Returns a string to use to update the GPU particles update shader
  15985. * @returns a string containng the defines string
  15986. */
  15987. getEffectDefines(): string;
  15988. /**
  15989. * Returns the string "CylinderParticleEmitter"
  15990. * @returns a string containing the class name
  15991. */
  15992. getClassName(): string;
  15993. /**
  15994. * Serializes the particle system to a JSON object.
  15995. * @returns the JSON object
  15996. */
  15997. serialize(): any;
  15998. /**
  15999. * Parse properties from a JSON object
  16000. * @param serializationObject defines the JSON object
  16001. */
  16002. parse(serializationObject: any): void;
  16003. }
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cylinder.
  16006. * It emits the particles randomly between two vectors.
  16007. */
  16008. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16009. /**
  16010. * The min limit of the emission direction.
  16011. */
  16012. direction1: Vector3;
  16013. /**
  16014. * The max limit of the emission direction.
  16015. */
  16016. direction2: Vector3;
  16017. /**
  16018. * Creates a new instance CylinderDirectedParticleEmitter
  16019. * @param radius the radius of the emission cylinder (1 by default)
  16020. * @param height the height of the emission cylinder (1 by default)
  16021. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16022. * @param direction1 the min limit of the emission direction (up vector by default)
  16023. * @param direction2 the max limit of the emission direction (up vector by default)
  16024. */
  16025. constructor(radius?: number, height?: number, radiusRange?: number,
  16026. /**
  16027. * The min limit of the emission direction.
  16028. */
  16029. direction1?: Vector3,
  16030. /**
  16031. * The max limit of the emission direction.
  16032. */
  16033. direction2?: Vector3);
  16034. /**
  16035. * Called by the particle System when the direction is computed for the created particle.
  16036. * @param worldMatrix is the world matrix of the particle system
  16037. * @param directionToUpdate is the direction vector to update with the result
  16038. * @param particle is the particle we are computed the direction for
  16039. */
  16040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16041. /**
  16042. * Clones the current emitter and returns a copy of it
  16043. * @returns the new emitter
  16044. */
  16045. clone(): CylinderDirectedParticleEmitter;
  16046. /**
  16047. * Called by the GPUParticleSystem to setup the update shader
  16048. * @param effect defines the update shader
  16049. */
  16050. applyToShader(effect: Effect): void;
  16051. /**
  16052. * Returns a string to use to update the GPU particles update shader
  16053. * @returns a string containng the defines string
  16054. */
  16055. getEffectDefines(): string;
  16056. /**
  16057. * Returns the string "CylinderDirectedParticleEmitter"
  16058. * @returns a string containing the class name
  16059. */
  16060. getClassName(): string;
  16061. /**
  16062. * Serializes the particle system to a JSON object.
  16063. * @returns the JSON object
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Parse properties from a JSON object
  16068. * @param serializationObject defines the JSON object
  16069. */
  16070. parse(serializationObject: any): void;
  16071. }
  16072. }
  16073. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16074. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16075. import { Effect } from "babylonjs/Materials/effect";
  16076. import { Particle } from "babylonjs/Particles/particle";
  16077. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16078. /**
  16079. * Particle emitter emitting particles from the inside of a hemisphere.
  16080. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16081. */
  16082. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16083. /**
  16084. * The radius of the emission hemisphere.
  16085. */
  16086. radius: number;
  16087. /**
  16088. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16089. */
  16090. radiusRange: number;
  16091. /**
  16092. * How much to randomize the particle direction [0-1].
  16093. */
  16094. directionRandomizer: number;
  16095. /**
  16096. * Creates a new instance HemisphericParticleEmitter
  16097. * @param radius the radius of the emission hemisphere (1 by default)
  16098. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16099. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16100. */
  16101. constructor(
  16102. /**
  16103. * The radius of the emission hemisphere.
  16104. */
  16105. radius?: number,
  16106. /**
  16107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16108. */
  16109. radiusRange?: number,
  16110. /**
  16111. * How much to randomize the particle direction [0-1].
  16112. */
  16113. directionRandomizer?: number);
  16114. /**
  16115. * Called by the particle System when the direction is computed for the created particle.
  16116. * @param worldMatrix is the world matrix of the particle system
  16117. * @param directionToUpdate is the direction vector to update with the result
  16118. * @param particle is the particle we are computed the direction for
  16119. */
  16120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16121. /**
  16122. * Called by the particle System when the position is computed for the created particle.
  16123. * @param worldMatrix is the world matrix of the particle system
  16124. * @param positionToUpdate is the position vector to update with the result
  16125. * @param particle is the particle we are computed the position for
  16126. */
  16127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16128. /**
  16129. * Clones the current emitter and returns a copy of it
  16130. * @returns the new emitter
  16131. */
  16132. clone(): HemisphericParticleEmitter;
  16133. /**
  16134. * Called by the GPUParticleSystem to setup the update shader
  16135. * @param effect defines the update shader
  16136. */
  16137. applyToShader(effect: Effect): void;
  16138. /**
  16139. * Returns a string to use to update the GPU particles update shader
  16140. * @returns a string containng the defines string
  16141. */
  16142. getEffectDefines(): string;
  16143. /**
  16144. * Returns the string "HemisphericParticleEmitter"
  16145. * @returns a string containing the class name
  16146. */
  16147. getClassName(): string;
  16148. /**
  16149. * Serializes the particle system to a JSON object.
  16150. * @returns the JSON object
  16151. */
  16152. serialize(): any;
  16153. /**
  16154. * Parse properties from a JSON object
  16155. * @param serializationObject defines the JSON object
  16156. */
  16157. parse(serializationObject: any): void;
  16158. }
  16159. }
  16160. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16161. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16162. import { Effect } from "babylonjs/Materials/effect";
  16163. import { Particle } from "babylonjs/Particles/particle";
  16164. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16165. /**
  16166. * Particle emitter emitting particles from a point.
  16167. * It emits the particles randomly between 2 given directions.
  16168. */
  16169. export class PointParticleEmitter implements IParticleEmitterType {
  16170. /**
  16171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16172. */
  16173. direction1: Vector3;
  16174. /**
  16175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16176. */
  16177. direction2: Vector3;
  16178. /**
  16179. * Creates a new instance PointParticleEmitter
  16180. */
  16181. constructor();
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. */
  16188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16189. /**
  16190. * Called by the particle System when the position is computed for the created particle.
  16191. * @param worldMatrix is the world matrix of the particle system
  16192. * @param positionToUpdate is the position vector to update with the result
  16193. * @param particle is the particle we are computed the position for
  16194. */
  16195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16196. /**
  16197. * Clones the current emitter and returns a copy of it
  16198. * @returns the new emitter
  16199. */
  16200. clone(): PointParticleEmitter;
  16201. /**
  16202. * Called by the GPUParticleSystem to setup the update shader
  16203. * @param effect defines the update shader
  16204. */
  16205. applyToShader(effect: Effect): void;
  16206. /**
  16207. * Returns a string to use to update the GPU particles update shader
  16208. * @returns a string containng the defines string
  16209. */
  16210. getEffectDefines(): string;
  16211. /**
  16212. * Returns the string "PointParticleEmitter"
  16213. * @returns a string containing the class name
  16214. */
  16215. getClassName(): string;
  16216. /**
  16217. * Serializes the particle system to a JSON object.
  16218. * @returns the JSON object
  16219. */
  16220. serialize(): any;
  16221. /**
  16222. * Parse properties from a JSON object
  16223. * @param serializationObject defines the JSON object
  16224. */
  16225. parse(serializationObject: any): void;
  16226. }
  16227. }
  16228. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16229. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16230. import { Effect } from "babylonjs/Materials/effect";
  16231. import { Particle } from "babylonjs/Particles/particle";
  16232. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16233. /**
  16234. * Particle emitter emitting particles from the inside of a sphere.
  16235. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16236. */
  16237. export class SphereParticleEmitter implements IParticleEmitterType {
  16238. /**
  16239. * The radius of the emission sphere.
  16240. */
  16241. radius: number;
  16242. /**
  16243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16244. */
  16245. radiusRange: number;
  16246. /**
  16247. * How much to randomize the particle direction [0-1].
  16248. */
  16249. directionRandomizer: number;
  16250. /**
  16251. * Creates a new instance SphereParticleEmitter
  16252. * @param radius the radius of the emission sphere (1 by default)
  16253. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16254. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16255. */
  16256. constructor(
  16257. /**
  16258. * The radius of the emission sphere.
  16259. */
  16260. radius?: number,
  16261. /**
  16262. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16263. */
  16264. radiusRange?: number,
  16265. /**
  16266. * How much to randomize the particle direction [0-1].
  16267. */
  16268. directionRandomizer?: number);
  16269. /**
  16270. * Called by the particle System when the direction is computed for the created particle.
  16271. * @param worldMatrix is the world matrix of the particle system
  16272. * @param directionToUpdate is the direction vector to update with the result
  16273. * @param particle is the particle we are computed the direction for
  16274. */
  16275. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16276. /**
  16277. * Called by the particle System when the position is computed for the created particle.
  16278. * @param worldMatrix is the world matrix of the particle system
  16279. * @param positionToUpdate is the position vector to update with the result
  16280. * @param particle is the particle we are computed the position for
  16281. */
  16282. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16283. /**
  16284. * Clones the current emitter and returns a copy of it
  16285. * @returns the new emitter
  16286. */
  16287. clone(): SphereParticleEmitter;
  16288. /**
  16289. * Called by the GPUParticleSystem to setup the update shader
  16290. * @param effect defines the update shader
  16291. */
  16292. applyToShader(effect: Effect): void;
  16293. /**
  16294. * Returns a string to use to update the GPU particles update shader
  16295. * @returns a string containng the defines string
  16296. */
  16297. getEffectDefines(): string;
  16298. /**
  16299. * Returns the string "SphereParticleEmitter"
  16300. * @returns a string containing the class name
  16301. */
  16302. getClassName(): string;
  16303. /**
  16304. * Serializes the particle system to a JSON object.
  16305. * @returns the JSON object
  16306. */
  16307. serialize(): any;
  16308. /**
  16309. * Parse properties from a JSON object
  16310. * @param serializationObject defines the JSON object
  16311. */
  16312. parse(serializationObject: any): void;
  16313. }
  16314. /**
  16315. * Particle emitter emitting particles from the inside of a sphere.
  16316. * It emits the particles randomly between two vectors.
  16317. */
  16318. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16319. /**
  16320. * The min limit of the emission direction.
  16321. */
  16322. direction1: Vector3;
  16323. /**
  16324. * The max limit of the emission direction.
  16325. */
  16326. direction2: Vector3;
  16327. /**
  16328. * Creates a new instance SphereDirectedParticleEmitter
  16329. * @param radius the radius of the emission sphere (1 by default)
  16330. * @param direction1 the min limit of the emission direction (up vector by default)
  16331. * @param direction2 the max limit of the emission direction (up vector by default)
  16332. */
  16333. constructor(radius?: number,
  16334. /**
  16335. * The min limit of the emission direction.
  16336. */
  16337. direction1?: Vector3,
  16338. /**
  16339. * The max limit of the emission direction.
  16340. */
  16341. direction2?: Vector3);
  16342. /**
  16343. * Called by the particle System when the direction is computed for the created particle.
  16344. * @param worldMatrix is the world matrix of the particle system
  16345. * @param directionToUpdate is the direction vector to update with the result
  16346. * @param particle is the particle we are computed the direction for
  16347. */
  16348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16349. /**
  16350. * Clones the current emitter and returns a copy of it
  16351. * @returns the new emitter
  16352. */
  16353. clone(): SphereDirectedParticleEmitter;
  16354. /**
  16355. * Called by the GPUParticleSystem to setup the update shader
  16356. * @param effect defines the update shader
  16357. */
  16358. applyToShader(effect: Effect): void;
  16359. /**
  16360. * Returns a string to use to update the GPU particles update shader
  16361. * @returns a string containng the defines string
  16362. */
  16363. getEffectDefines(): string;
  16364. /**
  16365. * Returns the string "SphereDirectedParticleEmitter"
  16366. * @returns a string containing the class name
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Serializes the particle system to a JSON object.
  16371. * @returns the JSON object
  16372. */
  16373. serialize(): any;
  16374. /**
  16375. * Parse properties from a JSON object
  16376. * @param serializationObject defines the JSON object
  16377. */
  16378. parse(serializationObject: any): void;
  16379. }
  16380. }
  16381. declare module "babylonjs/Particles/EmitterTypes/index" {
  16382. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16383. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16384. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16385. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16386. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16387. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16388. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16389. }
  16390. declare module "babylonjs/Particles/IParticleSystem" {
  16391. import { Nullable } from "babylonjs/types";
  16392. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16395. import { Texture } from "babylonjs/Materials/Textures/texture";
  16396. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16397. import { Scene } from "babylonjs/scene";
  16398. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16399. import { Animation } from "babylonjs/Animations/animation";
  16400. /**
  16401. * Interface representing a particle system in Babylon.js.
  16402. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16403. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16404. */
  16405. export interface IParticleSystem {
  16406. /**
  16407. * List of animations used by the particle system.
  16408. */
  16409. animations: Animation[];
  16410. /**
  16411. * The id of the Particle system.
  16412. */
  16413. id: string;
  16414. /**
  16415. * The name of the Particle system.
  16416. */
  16417. name: string;
  16418. /**
  16419. * The emitter represents the Mesh or position we are attaching the particle system to.
  16420. */
  16421. emitter: Nullable<AbstractMesh | Vector3>;
  16422. /**
  16423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16424. */
  16425. isBillboardBased: boolean;
  16426. /**
  16427. * The rendering group used by the Particle system to chose when to render.
  16428. */
  16429. renderingGroupId: number;
  16430. /**
  16431. * The layer mask we are rendering the particles through.
  16432. */
  16433. layerMask: number;
  16434. /**
  16435. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16436. */
  16437. updateSpeed: number;
  16438. /**
  16439. * The amount of time the particle system is running (depends of the overall update speed).
  16440. */
  16441. targetStopDuration: number;
  16442. /**
  16443. * The texture used to render each particle. (this can be a spritesheet)
  16444. */
  16445. particleTexture: Nullable<Texture>;
  16446. /**
  16447. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16448. */
  16449. blendMode: number;
  16450. /**
  16451. * Minimum life time of emitting particles.
  16452. */
  16453. minLifeTime: number;
  16454. /**
  16455. * Maximum life time of emitting particles.
  16456. */
  16457. maxLifeTime: number;
  16458. /**
  16459. * Minimum Size of emitting particles.
  16460. */
  16461. minSize: number;
  16462. /**
  16463. * Maximum Size of emitting particles.
  16464. */
  16465. maxSize: number;
  16466. /**
  16467. * Minimum scale of emitting particles on X axis.
  16468. */
  16469. minScaleX: number;
  16470. /**
  16471. * Maximum scale of emitting particles on X axis.
  16472. */
  16473. maxScaleX: number;
  16474. /**
  16475. * Minimum scale of emitting particles on Y axis.
  16476. */
  16477. minScaleY: number;
  16478. /**
  16479. * Maximum scale of emitting particles on Y axis.
  16480. */
  16481. maxScaleY: number;
  16482. /**
  16483. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16484. */
  16485. color1: Color4;
  16486. /**
  16487. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16488. */
  16489. color2: Color4;
  16490. /**
  16491. * Color the particle will have at the end of its lifetime.
  16492. */
  16493. colorDead: Color4;
  16494. /**
  16495. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16496. */
  16497. emitRate: number;
  16498. /**
  16499. * You can use gravity if you want to give an orientation to your particles.
  16500. */
  16501. gravity: Vector3;
  16502. /**
  16503. * Minimum power of emitting particles.
  16504. */
  16505. minEmitPower: number;
  16506. /**
  16507. * Maximum power of emitting particles.
  16508. */
  16509. maxEmitPower: number;
  16510. /**
  16511. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16512. */
  16513. minAngularSpeed: number;
  16514. /**
  16515. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16516. */
  16517. maxAngularSpeed: number;
  16518. /**
  16519. * Gets or sets the minimal initial rotation in radians.
  16520. */
  16521. minInitialRotation: number;
  16522. /**
  16523. * Gets or sets the maximal initial rotation in radians.
  16524. */
  16525. maxInitialRotation: number;
  16526. /**
  16527. * The particle emitter type defines the emitter used by the particle system.
  16528. * It can be for example box, sphere, or cone...
  16529. */
  16530. particleEmitterType: Nullable<IParticleEmitterType>;
  16531. /**
  16532. * Defines the delay in milliseconds before starting the system (0 by default)
  16533. */
  16534. startDelay: number;
  16535. /**
  16536. * 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
  16537. */
  16538. preWarmCycles: number;
  16539. /**
  16540. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16541. */
  16542. preWarmStepOffset: number;
  16543. /**
  16544. * 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)
  16545. */
  16546. spriteCellChangeSpeed: number;
  16547. /**
  16548. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16549. */
  16550. startSpriteCellID: number;
  16551. /**
  16552. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16553. */
  16554. endSpriteCellID: number;
  16555. /**
  16556. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16557. */
  16558. spriteCellWidth: number;
  16559. /**
  16560. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16561. */
  16562. spriteCellHeight: number;
  16563. /**
  16564. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16565. */
  16566. spriteRandomStartCell: boolean;
  16567. /**
  16568. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16569. */
  16570. isAnimationSheetEnabled: boolean;
  16571. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16572. translationPivot: Vector2;
  16573. /**
  16574. * Gets or sets a texture used to add random noise to particle positions
  16575. */
  16576. noiseTexture: Nullable<BaseTexture>;
  16577. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16578. noiseStrength: Vector3;
  16579. /**
  16580. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16581. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16582. */
  16583. billboardMode: number;
  16584. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16585. limitVelocityDamping: number;
  16586. /**
  16587. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16588. */
  16589. beginAnimationOnStart: boolean;
  16590. /**
  16591. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16592. */
  16593. beginAnimationFrom: number;
  16594. /**
  16595. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16596. */
  16597. beginAnimationTo: number;
  16598. /**
  16599. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16600. */
  16601. beginAnimationLoop: boolean;
  16602. /**
  16603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16604. */
  16605. disposeOnStop: boolean;
  16606. /**
  16607. * Gets the maximum number of particles active at the same time.
  16608. * @returns The max number of active particles.
  16609. */
  16610. getCapacity(): number;
  16611. /**
  16612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16613. * @returns True if it has been started, otherwise false.
  16614. */
  16615. isStarted(): boolean;
  16616. /**
  16617. * Animates the particle system for this frame.
  16618. */
  16619. animate(): void;
  16620. /**
  16621. * Renders the particle system in its current state.
  16622. * @returns the current number of particles
  16623. */
  16624. render(): number;
  16625. /**
  16626. * Dispose the particle system and frees its associated resources.
  16627. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16628. */
  16629. dispose(disposeTexture?: boolean): void;
  16630. /**
  16631. * Clones the particle system.
  16632. * @param name The name of the cloned object
  16633. * @param newEmitter The new emitter to use
  16634. * @returns the cloned particle system
  16635. */
  16636. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16637. /**
  16638. * Serializes the particle system to a JSON object.
  16639. * @returns the JSON object
  16640. */
  16641. serialize(): any;
  16642. /**
  16643. * Rebuild the particle system
  16644. */
  16645. rebuild(): void;
  16646. /**
  16647. * Starts the particle system and begins to emit
  16648. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16649. */
  16650. start(delay?: number): void;
  16651. /**
  16652. * Stops the particle system.
  16653. */
  16654. stop(): void;
  16655. /**
  16656. * Remove all active particles
  16657. */
  16658. reset(): void;
  16659. /**
  16660. * Is this system ready to be used/rendered
  16661. * @return true if the system is ready
  16662. */
  16663. isReady(): boolean;
  16664. /**
  16665. * Adds a new color gradient
  16666. * @param gradient defines the gradient to use (between 0 and 1)
  16667. * @param color1 defines the color to affect to the specified gradient
  16668. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16669. * @returns the current particle system
  16670. */
  16671. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16672. /**
  16673. * Remove a specific color gradient
  16674. * @param gradient defines the gradient to remove
  16675. * @returns the current particle system
  16676. */
  16677. removeColorGradient(gradient: number): IParticleSystem;
  16678. /**
  16679. * Adds a new size gradient
  16680. * @param gradient defines the gradient to use (between 0 and 1)
  16681. * @param factor defines the size factor to affect to the specified gradient
  16682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16683. * @returns the current particle system
  16684. */
  16685. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16686. /**
  16687. * Remove a specific size gradient
  16688. * @param gradient defines the gradient to remove
  16689. * @returns the current particle system
  16690. */
  16691. removeSizeGradient(gradient: number): IParticleSystem;
  16692. /**
  16693. * Gets the current list of color gradients.
  16694. * You must use addColorGradient and removeColorGradient to udpate this list
  16695. * @returns the list of color gradients
  16696. */
  16697. getColorGradients(): Nullable<Array<ColorGradient>>;
  16698. /**
  16699. * Gets the current list of size gradients.
  16700. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16701. * @returns the list of size gradients
  16702. */
  16703. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16704. /**
  16705. * Gets the current list of angular speed gradients.
  16706. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16707. * @returns the list of angular speed gradients
  16708. */
  16709. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16710. /**
  16711. * Adds a new angular speed gradient
  16712. * @param gradient defines the gradient to use (between 0 and 1)
  16713. * @param factor defines the angular speed to affect to the specified gradient
  16714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16715. * @returns the current particle system
  16716. */
  16717. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16718. /**
  16719. * Remove a specific angular speed gradient
  16720. * @param gradient defines the gradient to remove
  16721. * @returns the current particle system
  16722. */
  16723. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16724. /**
  16725. * Gets the current list of velocity gradients.
  16726. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16727. * @returns the list of velocity gradients
  16728. */
  16729. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16730. /**
  16731. * Adds a new velocity gradient
  16732. * @param gradient defines the gradient to use (between 0 and 1)
  16733. * @param factor defines the velocity to affect to the specified gradient
  16734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16735. * @returns the current particle system
  16736. */
  16737. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16738. /**
  16739. * Remove a specific velocity gradient
  16740. * @param gradient defines the gradient to remove
  16741. * @returns the current particle system
  16742. */
  16743. removeVelocityGradient(gradient: number): IParticleSystem;
  16744. /**
  16745. * Gets the current list of limit velocity gradients.
  16746. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16747. * @returns the list of limit velocity gradients
  16748. */
  16749. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16750. /**
  16751. * Adds a new limit velocity gradient
  16752. * @param gradient defines the gradient to use (between 0 and 1)
  16753. * @param factor defines the limit velocity to affect to the specified gradient
  16754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16755. * @returns the current particle system
  16756. */
  16757. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16758. /**
  16759. * Remove a specific limit velocity gradient
  16760. * @param gradient defines the gradient to remove
  16761. * @returns the current particle system
  16762. */
  16763. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16764. /**
  16765. * Adds a new drag gradient
  16766. * @param gradient defines the gradient to use (between 0 and 1)
  16767. * @param factor defines the drag to affect to the specified gradient
  16768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16769. * @returns the current particle system
  16770. */
  16771. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16772. /**
  16773. * Remove a specific drag gradient
  16774. * @param gradient defines the gradient to remove
  16775. * @returns the current particle system
  16776. */
  16777. removeDragGradient(gradient: number): IParticleSystem;
  16778. /**
  16779. * Gets the current list of drag gradients.
  16780. * You must use addDragGradient and removeDragGradient to udpate this list
  16781. * @returns the list of drag gradients
  16782. */
  16783. getDragGradients(): Nullable<Array<FactorGradient>>;
  16784. /**
  16785. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16786. * @param gradient defines the gradient to use (between 0 and 1)
  16787. * @param factor defines the emit rate to affect to the specified gradient
  16788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16789. * @returns the current particle system
  16790. */
  16791. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16792. /**
  16793. * Remove a specific emit rate gradient
  16794. * @param gradient defines the gradient to remove
  16795. * @returns the current particle system
  16796. */
  16797. removeEmitRateGradient(gradient: number): IParticleSystem;
  16798. /**
  16799. * Gets the current list of emit rate gradients.
  16800. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16801. * @returns the list of emit rate gradients
  16802. */
  16803. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16804. /**
  16805. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16806. * @param gradient defines the gradient to use (between 0 and 1)
  16807. * @param factor defines the start size to affect to the specified gradient
  16808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16809. * @returns the current particle system
  16810. */
  16811. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16812. /**
  16813. * Remove a specific start size gradient
  16814. * @param gradient defines the gradient to remove
  16815. * @returns the current particle system
  16816. */
  16817. removeStartSizeGradient(gradient: number): IParticleSystem;
  16818. /**
  16819. * Gets the current list of start size gradients.
  16820. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16821. * @returns the list of start size gradients
  16822. */
  16823. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16824. /**
  16825. * Adds a new life time gradient
  16826. * @param gradient defines the gradient to use (between 0 and 1)
  16827. * @param factor defines the life time factor to affect to the specified gradient
  16828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16829. * @returns the current particle system
  16830. */
  16831. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16832. /**
  16833. * Remove a specific life time gradient
  16834. * @param gradient defines the gradient to remove
  16835. * @returns the current particle system
  16836. */
  16837. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16838. /**
  16839. * Gets the current list of life time gradients.
  16840. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16841. * @returns the list of life time gradients
  16842. */
  16843. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16844. /**
  16845. * Gets the current list of color gradients.
  16846. * You must use addColorGradient and removeColorGradient to udpate this list
  16847. * @returns the list of color gradients
  16848. */
  16849. getColorGradients(): Nullable<Array<ColorGradient>>;
  16850. /**
  16851. * Adds a new ramp gradient used to remap particle colors
  16852. * @param gradient defines the gradient to use (between 0 and 1)
  16853. * @param color defines the color to affect to the specified gradient
  16854. * @returns the current particle system
  16855. */
  16856. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16857. /**
  16858. * Gets the current list of ramp gradients.
  16859. * You must use addRampGradient and removeRampGradient to udpate this list
  16860. * @returns the list of ramp gradients
  16861. */
  16862. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16863. /** Gets or sets a boolean indicating that ramp gradients must be used
  16864. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16865. */
  16866. useRampGradients: boolean;
  16867. /**
  16868. * Adds a new color remap gradient
  16869. * @param gradient defines the gradient to use (between 0 and 1)
  16870. * @param min defines the color remap minimal range
  16871. * @param max defines the color remap maximal range
  16872. * @returns the current particle system
  16873. */
  16874. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16875. /**
  16876. * Gets the current list of color remap gradients.
  16877. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16878. * @returns the list of color remap gradients
  16879. */
  16880. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16881. /**
  16882. * Adds a new alpha remap gradient
  16883. * @param gradient defines the gradient to use (between 0 and 1)
  16884. * @param min defines the alpha remap minimal range
  16885. * @param max defines the alpha remap maximal range
  16886. * @returns the current particle system
  16887. */
  16888. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16889. /**
  16890. * Gets the current list of alpha remap gradients.
  16891. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16892. * @returns the list of alpha remap gradients
  16893. */
  16894. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16899. * @returns the emitter
  16900. */
  16901. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16902. /**
  16903. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16904. * @param radius The radius of the hemisphere to emit from
  16905. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16906. * @returns the emitter
  16907. */
  16908. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16909. /**
  16910. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16911. * @param radius The radius of the sphere to emit from
  16912. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16913. * @returns the emitter
  16914. */
  16915. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16916. /**
  16917. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16918. * @param radius The radius of the sphere to emit from
  16919. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16920. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16921. * @returns the emitter
  16922. */
  16923. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16924. /**
  16925. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16926. * @param radius The radius of the emission cylinder
  16927. * @param height The height of the emission cylinder
  16928. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16929. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16930. * @returns the emitter
  16931. */
  16932. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16933. /**
  16934. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16935. * @param radius The radius of the cylinder to emit from
  16936. * @param height The height of the emission cylinder
  16937. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16938. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16939. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16940. * @returns the emitter
  16941. */
  16942. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16943. /**
  16944. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16945. * @param radius The radius of the cone to emit from
  16946. * @param angle The base angle of the cone
  16947. * @returns the emitter
  16948. */
  16949. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16950. /**
  16951. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16954. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16955. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16956. * @returns the emitter
  16957. */
  16958. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16959. /**
  16960. * Get hosting scene
  16961. * @returns the scene
  16962. */
  16963. getScene(): Scene;
  16964. }
  16965. }
  16966. declare module "babylonjs/Shaders/line.fragment" {
  16967. /** @hidden */
  16968. export var linePixelShader: {
  16969. name: string;
  16970. shader: string;
  16971. };
  16972. }
  16973. declare module "babylonjs/Shaders/line.vertex" {
  16974. /** @hidden */
  16975. export var lineVertexShader: {
  16976. name: string;
  16977. shader: string;
  16978. };
  16979. }
  16980. declare module "babylonjs/Rendering/edgesRenderer" {
  16981. import { Nullable } from "babylonjs/types";
  16982. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16984. import { Vector3 } from "babylonjs/Maths/math";
  16985. import { IDisposable } from "babylonjs/scene";
  16986. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16987. import "babylonjs/Shaders/line.fragment";
  16988. import "babylonjs/Shaders/line.vertex";
  16989. module "babylonjs/Meshes/abstractMesh" {
  16990. interface AbstractMesh {
  16991. /**
  16992. * Disables the mesh edge rendering mode
  16993. * @returns the currentAbstractMesh
  16994. */
  16995. disableEdgesRendering(): AbstractMesh;
  16996. /**
  16997. * Enables the edge rendering mode on the mesh.
  16998. * This mode makes the mesh edges visible
  16999. * @param epsilon defines the maximal distance between two angles to detect a face
  17000. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17001. * @returns the currentAbstractMesh
  17002. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17003. */
  17004. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17005. /**
  17006. * Gets the edgesRenderer associated with the mesh
  17007. */
  17008. edgesRenderer: Nullable<EdgesRenderer>;
  17009. }
  17010. }
  17011. module "babylonjs/Meshes/linesMesh" {
  17012. interface LinesMesh {
  17013. /**
  17014. * Enables the edge rendering mode on the mesh.
  17015. * This mode makes the mesh edges visible
  17016. * @param epsilon defines the maximal distance between two angles to detect a face
  17017. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17018. * @returns the currentAbstractMesh
  17019. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17020. */
  17021. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17022. }
  17023. }
  17024. module "babylonjs/Meshes/linesMesh" {
  17025. interface InstancedLinesMesh {
  17026. /**
  17027. * Enables the edge rendering mode on the mesh.
  17028. * This mode makes the mesh edges visible
  17029. * @param epsilon defines the maximal distance between two angles to detect a face
  17030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17031. * @returns the current InstancedLinesMesh
  17032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17033. */
  17034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17035. }
  17036. }
  17037. /**
  17038. * Defines the minimum contract an Edges renderer should follow.
  17039. */
  17040. export interface IEdgesRenderer extends IDisposable {
  17041. /**
  17042. * Gets or sets a boolean indicating if the edgesRenderer is active
  17043. */
  17044. isEnabled: boolean;
  17045. /**
  17046. * Renders the edges of the attached mesh,
  17047. */
  17048. render(): void;
  17049. /**
  17050. * Checks wether or not the edges renderer is ready to render.
  17051. * @return true if ready, otherwise false.
  17052. */
  17053. isReady(): boolean;
  17054. }
  17055. /**
  17056. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17057. */
  17058. export class EdgesRenderer implements IEdgesRenderer {
  17059. /**
  17060. * Define the size of the edges with an orthographic camera
  17061. */
  17062. edgesWidthScalerForOrthographic: number;
  17063. /**
  17064. * Define the size of the edges with a perspective camera
  17065. */
  17066. edgesWidthScalerForPerspective: number;
  17067. protected _source: AbstractMesh;
  17068. protected _linesPositions: number[];
  17069. protected _linesNormals: number[];
  17070. protected _linesIndices: number[];
  17071. protected _epsilon: number;
  17072. protected _indicesCount: number;
  17073. protected _lineShader: ShaderMaterial;
  17074. protected _ib: WebGLBuffer;
  17075. protected _buffers: {
  17076. [key: string]: Nullable<VertexBuffer>;
  17077. };
  17078. protected _checkVerticesInsteadOfIndices: boolean;
  17079. private _meshRebuildObserver;
  17080. private _meshDisposeObserver;
  17081. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17082. isEnabled: boolean;
  17083. /**
  17084. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17085. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17086. * @param source Mesh used to create edges
  17087. * @param epsilon sum of angles in adjacency to check for edge
  17088. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17089. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17090. */
  17091. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17092. protected _prepareRessources(): void;
  17093. /** @hidden */
  17094. _rebuild(): void;
  17095. /**
  17096. * Releases the required resources for the edges renderer
  17097. */
  17098. dispose(): void;
  17099. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17100. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17101. /**
  17102. * Checks if the pair of p0 and p1 is en edge
  17103. * @param faceIndex
  17104. * @param edge
  17105. * @param faceNormals
  17106. * @param p0
  17107. * @param p1
  17108. * @private
  17109. */
  17110. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17111. /**
  17112. * push line into the position, normal and index buffer
  17113. * @protected
  17114. */
  17115. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17116. /**
  17117. * Generates lines edges from adjacencjes
  17118. * @private
  17119. */
  17120. _generateEdgesLines(): void;
  17121. /**
  17122. * Checks wether or not the edges renderer is ready to render.
  17123. * @return true if ready, otherwise false.
  17124. */
  17125. isReady(): boolean;
  17126. /**
  17127. * Renders the edges of the attached mesh,
  17128. */
  17129. render(): void;
  17130. }
  17131. /**
  17132. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17133. */
  17134. export class LineEdgesRenderer extends EdgesRenderer {
  17135. /**
  17136. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17137. * @param source LineMesh used to generate edges
  17138. * @param epsilon not important (specified angle for edge detection)
  17139. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17140. */
  17141. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17142. /**
  17143. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17144. */
  17145. _generateEdgesLines(): void;
  17146. }
  17147. }
  17148. declare module "babylonjs/Rendering/renderingGroup" {
  17149. import { SmartArray } from "babylonjs/Misc/smartArray";
  17150. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17152. import { Nullable } from "babylonjs/types";
  17153. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17154. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Scene } from "babylonjs/scene";
  17157. /**
  17158. * This represents the object necessary to create a rendering group.
  17159. * This is exclusively used and created by the rendering manager.
  17160. * To modify the behavior, you use the available helpers in your scene or meshes.
  17161. * @hidden
  17162. */
  17163. export class RenderingGroup {
  17164. index: number;
  17165. private _scene;
  17166. private _opaqueSubMeshes;
  17167. private _transparentSubMeshes;
  17168. private _alphaTestSubMeshes;
  17169. private _depthOnlySubMeshes;
  17170. private _particleSystems;
  17171. private _spriteManagers;
  17172. private _opaqueSortCompareFn;
  17173. private _alphaTestSortCompareFn;
  17174. private _transparentSortCompareFn;
  17175. private _renderOpaque;
  17176. private _renderAlphaTest;
  17177. private _renderTransparent;
  17178. private _edgesRenderers;
  17179. onBeforeTransparentRendering: () => void;
  17180. /**
  17181. * Set the opaque sort comparison function.
  17182. * If null the sub meshes will be render in the order they were created
  17183. */
  17184. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17185. /**
  17186. * Set the alpha test sort comparison function.
  17187. * If null the sub meshes will be render in the order they were created
  17188. */
  17189. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17190. /**
  17191. * Set the transparent sort comparison function.
  17192. * If null the sub meshes will be render in the order they were created
  17193. */
  17194. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17195. /**
  17196. * Creates a new rendering group.
  17197. * @param index The rendering group index
  17198. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17199. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17200. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17201. */
  17202. 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>);
  17203. /**
  17204. * Render all the sub meshes contained in the group.
  17205. * @param customRenderFunction Used to override the default render behaviour of the group.
  17206. * @returns true if rendered some submeshes.
  17207. */
  17208. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17209. /**
  17210. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17211. * @param subMeshes The submeshes to render
  17212. */
  17213. private renderOpaqueSorted;
  17214. /**
  17215. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17216. * @param subMeshes The submeshes to render
  17217. */
  17218. private renderAlphaTestSorted;
  17219. /**
  17220. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17221. * @param subMeshes The submeshes to render
  17222. */
  17223. private renderTransparentSorted;
  17224. /**
  17225. * Renders the submeshes in a specified order.
  17226. * @param subMeshes The submeshes to sort before render
  17227. * @param sortCompareFn The comparison function use to sort
  17228. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17229. * @param transparent Specifies to activate blending if true
  17230. */
  17231. private static renderSorted;
  17232. /**
  17233. * Renders the submeshes in the order they were dispatched (no sort applied).
  17234. * @param subMeshes The submeshes to render
  17235. */
  17236. private static renderUnsorted;
  17237. /**
  17238. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17239. * are rendered back to front if in the same alpha index.
  17240. *
  17241. * @param a The first submesh
  17242. * @param b The second submesh
  17243. * @returns The result of the comparison
  17244. */
  17245. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17246. /**
  17247. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17248. * are rendered back to front.
  17249. *
  17250. * @param a The first submesh
  17251. * @param b The second submesh
  17252. * @returns The result of the comparison
  17253. */
  17254. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17255. /**
  17256. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17257. * are rendered front to back (prevent overdraw).
  17258. *
  17259. * @param a The first submesh
  17260. * @param b The second submesh
  17261. * @returns The result of the comparison
  17262. */
  17263. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17264. /**
  17265. * Resets the different lists of submeshes to prepare a new frame.
  17266. */
  17267. prepare(): void;
  17268. dispose(): void;
  17269. /**
  17270. * Inserts the submesh in its correct queue depending on its material.
  17271. * @param subMesh The submesh to dispatch
  17272. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17273. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17274. */
  17275. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17276. dispatchSprites(spriteManager: ISpriteManager): void;
  17277. dispatchParticles(particleSystem: IParticleSystem): void;
  17278. private _renderParticles;
  17279. private _renderSprites;
  17280. }
  17281. }
  17282. declare module "babylonjs/Rendering/renderingManager" {
  17283. import { Nullable } from "babylonjs/types";
  17284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17286. import { SmartArray } from "babylonjs/Misc/smartArray";
  17287. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17288. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17289. import { Material } from "babylonjs/Materials/material";
  17290. import { Scene } from "babylonjs/scene";
  17291. import { Camera } from "babylonjs/Cameras/camera";
  17292. /**
  17293. * Interface describing the different options available in the rendering manager
  17294. * regarding Auto Clear between groups.
  17295. */
  17296. export interface IRenderingManagerAutoClearSetup {
  17297. /**
  17298. * Defines whether or not autoclear is enable.
  17299. */
  17300. autoClear: boolean;
  17301. /**
  17302. * Defines whether or not to autoclear the depth buffer.
  17303. */
  17304. depth: boolean;
  17305. /**
  17306. * Defines whether or not to autoclear the stencil buffer.
  17307. */
  17308. stencil: boolean;
  17309. }
  17310. /**
  17311. * This class is used by the onRenderingGroupObservable
  17312. */
  17313. export class RenderingGroupInfo {
  17314. /**
  17315. * The Scene that being rendered
  17316. */
  17317. scene: Scene;
  17318. /**
  17319. * The camera currently used for the rendering pass
  17320. */
  17321. camera: Nullable<Camera>;
  17322. /**
  17323. * The ID of the renderingGroup being processed
  17324. */
  17325. renderingGroupId: number;
  17326. }
  17327. /**
  17328. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17329. * It is enable to manage the different groups as well as the different necessary sort functions.
  17330. * This should not be used directly aside of the few static configurations
  17331. */
  17332. export class RenderingManager {
  17333. /**
  17334. * The max id used for rendering groups (not included)
  17335. */
  17336. static MAX_RENDERINGGROUPS: number;
  17337. /**
  17338. * The min id used for rendering groups (included)
  17339. */
  17340. static MIN_RENDERINGGROUPS: number;
  17341. /**
  17342. * Used to globally prevent autoclearing scenes.
  17343. */
  17344. static AUTOCLEAR: boolean;
  17345. /**
  17346. * @hidden
  17347. */
  17348. _useSceneAutoClearSetup: boolean;
  17349. private _scene;
  17350. private _renderingGroups;
  17351. private _depthStencilBufferAlreadyCleaned;
  17352. private _autoClearDepthStencil;
  17353. private _customOpaqueSortCompareFn;
  17354. private _customAlphaTestSortCompareFn;
  17355. private _customTransparentSortCompareFn;
  17356. private _renderingGroupInfo;
  17357. /**
  17358. * Instantiates a new rendering group for a particular scene
  17359. * @param scene Defines the scene the groups belongs to
  17360. */
  17361. constructor(scene: Scene);
  17362. private _clearDepthStencilBuffer;
  17363. /**
  17364. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17365. * @hidden
  17366. */
  17367. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17368. /**
  17369. * Resets the different information of the group to prepare a new frame
  17370. * @hidden
  17371. */
  17372. reset(): void;
  17373. /**
  17374. * Dispose and release the group and its associated resources.
  17375. * @hidden
  17376. */
  17377. dispose(): void;
  17378. /**
  17379. * Clear the info related to rendering groups preventing retention points during dispose.
  17380. */
  17381. freeRenderingGroups(): void;
  17382. private _prepareRenderingGroup;
  17383. /**
  17384. * Add a sprite manager to the rendering manager in order to render it this frame.
  17385. * @param spriteManager Define the sprite manager to render
  17386. */
  17387. dispatchSprites(spriteManager: ISpriteManager): void;
  17388. /**
  17389. * Add a particle system to the rendering manager in order to render it this frame.
  17390. * @param particleSystem Define the particle system to render
  17391. */
  17392. dispatchParticles(particleSystem: IParticleSystem): void;
  17393. /**
  17394. * Add a submesh to the manager in order to render it this frame
  17395. * @param subMesh The submesh to dispatch
  17396. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17397. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17398. */
  17399. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17400. /**
  17401. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17402. * This allowed control for front to back rendering or reversly depending of the special needs.
  17403. *
  17404. * @param renderingGroupId The rendering group id corresponding to its index
  17405. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17406. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17407. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17408. */
  17409. 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;
  17410. /**
  17411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17412. *
  17413. * @param renderingGroupId The rendering group id corresponding to its index
  17414. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17415. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17416. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17417. */
  17418. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17419. /**
  17420. * Gets the current auto clear configuration for one rendering group of the rendering
  17421. * manager.
  17422. * @param index the rendering group index to get the information for
  17423. * @returns The auto clear setup for the requested rendering group
  17424. */
  17425. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17426. }
  17427. }
  17428. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17429. import { Observable } from "babylonjs/Misc/observable";
  17430. import { SmartArray } from "babylonjs/Misc/smartArray";
  17431. import { Nullable } from "babylonjs/types";
  17432. import { Camera } from "babylonjs/Cameras/camera";
  17433. import { Scene } from "babylonjs/scene";
  17434. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17435. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17437. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17439. import { Texture } from "babylonjs/Materials/Textures/texture";
  17440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17441. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17442. import { Engine } from "babylonjs/Engines/engine";
  17443. /**
  17444. * This Helps creating a texture that will be created from a camera in your scene.
  17445. * It is basically a dynamic texture that could be used to create special effects for instance.
  17446. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17447. */
  17448. export class RenderTargetTexture extends Texture {
  17449. isCube: boolean;
  17450. /**
  17451. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17452. */
  17453. static readonly REFRESHRATE_RENDER_ONCE: number;
  17454. /**
  17455. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17456. */
  17457. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17458. /**
  17459. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17460. * the central point of your effect and can save a lot of performances.
  17461. */
  17462. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17463. /**
  17464. * Use this predicate to dynamically define the list of mesh you want to render.
  17465. * If set, the renderList property will be overwritten.
  17466. */
  17467. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17468. private _renderList;
  17469. /**
  17470. * Use this list to define the list of mesh you want to render.
  17471. */
  17472. renderList: Nullable<Array<AbstractMesh>>;
  17473. private _hookArray;
  17474. /**
  17475. * Define if particles should be rendered in your texture.
  17476. */
  17477. renderParticles: boolean;
  17478. /**
  17479. * Define if sprites should be rendered in your texture.
  17480. */
  17481. renderSprites: boolean;
  17482. /**
  17483. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17484. */
  17485. coordinatesMode: number;
  17486. /**
  17487. * Define the camera used to render the texture.
  17488. */
  17489. activeCamera: Nullable<Camera>;
  17490. /**
  17491. * Override the render function of the texture with your own one.
  17492. */
  17493. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17494. /**
  17495. * Define if camera post processes should be use while rendering the texture.
  17496. */
  17497. useCameraPostProcesses: boolean;
  17498. /**
  17499. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17500. */
  17501. ignoreCameraViewport: boolean;
  17502. private _postProcessManager;
  17503. private _postProcesses;
  17504. private _resizeObserver;
  17505. /**
  17506. * An event triggered when the texture is unbind.
  17507. */
  17508. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17509. /**
  17510. * An event triggered when the texture is unbind.
  17511. */
  17512. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17513. private _onAfterUnbindObserver;
  17514. /**
  17515. * Set a after unbind callback in the texture.
  17516. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17517. */
  17518. onAfterUnbind: () => void;
  17519. /**
  17520. * An event triggered before rendering the texture
  17521. */
  17522. onBeforeRenderObservable: Observable<number>;
  17523. private _onBeforeRenderObserver;
  17524. /**
  17525. * Set a before render callback in the texture.
  17526. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17527. */
  17528. onBeforeRender: (faceIndex: number) => void;
  17529. /**
  17530. * An event triggered after rendering the texture
  17531. */
  17532. onAfterRenderObservable: Observable<number>;
  17533. private _onAfterRenderObserver;
  17534. /**
  17535. * Set a after render callback in the texture.
  17536. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17537. */
  17538. onAfterRender: (faceIndex: number) => void;
  17539. /**
  17540. * An event triggered after the texture clear
  17541. */
  17542. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17543. private _onClearObserver;
  17544. /**
  17545. * Set a clear callback in the texture.
  17546. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17547. */
  17548. onClear: (Engine: Engine) => void;
  17549. /**
  17550. * Define the clear color of the Render Target if it should be different from the scene.
  17551. */
  17552. clearColor: Color4;
  17553. protected _size: number | {
  17554. width: number;
  17555. height: number;
  17556. };
  17557. protected _initialSizeParameter: number | {
  17558. width: number;
  17559. height: number;
  17560. } | {
  17561. ratio: number;
  17562. };
  17563. protected _sizeRatio: Nullable<number>;
  17564. /** @hidden */
  17565. _generateMipMaps: boolean;
  17566. protected _renderingManager: RenderingManager;
  17567. /** @hidden */
  17568. _waitingRenderList: string[];
  17569. protected _doNotChangeAspectRatio: boolean;
  17570. protected _currentRefreshId: number;
  17571. protected _refreshRate: number;
  17572. protected _textureMatrix: Matrix;
  17573. protected _samples: number;
  17574. protected _renderTargetOptions: RenderTargetCreationOptions;
  17575. /**
  17576. * Gets render target creation options that were used.
  17577. */
  17578. readonly renderTargetOptions: RenderTargetCreationOptions;
  17579. protected _engine: Engine;
  17580. protected _onRatioRescale(): void;
  17581. /**
  17582. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17583. * It must define where the camera used to render the texture is set
  17584. */
  17585. boundingBoxPosition: Vector3;
  17586. private _boundingBoxSize;
  17587. /**
  17588. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17589. * When defined, the cubemap will switch to local mode
  17590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17591. * @example https://www.babylonjs-playground.com/#RNASML
  17592. */
  17593. boundingBoxSize: Vector3;
  17594. /**
  17595. * In case the RTT has been created with a depth texture, get the associated
  17596. * depth texture.
  17597. * Otherwise, return null.
  17598. */
  17599. depthStencilTexture: Nullable<InternalTexture>;
  17600. /**
  17601. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17602. * or used a shadow, depth texture...
  17603. * @param name The friendly name of the texture
  17604. * @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)
  17605. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17606. * @param generateMipMaps True if mip maps need to be generated after render.
  17607. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17608. * @param type The type of the buffer in the RTT (int, half float, float...)
  17609. * @param isCube True if a cube texture needs to be created
  17610. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17611. * @param generateDepthBuffer True to generate a depth buffer
  17612. * @param generateStencilBuffer True to generate a stencil buffer
  17613. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17614. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17615. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17616. */
  17617. constructor(name: string, size: number | {
  17618. width: number;
  17619. height: number;
  17620. } | {
  17621. ratio: number;
  17622. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17623. /**
  17624. * Creates a depth stencil texture.
  17625. * This is only available in WebGL 2 or with the depth texture extension available.
  17626. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17627. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17628. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17629. */
  17630. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17631. private _processSizeParameter;
  17632. /**
  17633. * Define the number of samples to use in case of MSAA.
  17634. * It defaults to one meaning no MSAA has been enabled.
  17635. */
  17636. samples: number;
  17637. /**
  17638. * Resets the refresh counter of the texture and start bak from scratch.
  17639. * Could be useful to regenerate the texture if it is setup to render only once.
  17640. */
  17641. resetRefreshCounter(): void;
  17642. /**
  17643. * Define the refresh rate of the texture or the rendering frequency.
  17644. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17645. */
  17646. refreshRate: number;
  17647. /**
  17648. * Adds a post process to the render target rendering passes.
  17649. * @param postProcess define the post process to add
  17650. */
  17651. addPostProcess(postProcess: PostProcess): void;
  17652. /**
  17653. * Clear all the post processes attached to the render target
  17654. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17655. */
  17656. clearPostProcesses(dispose?: boolean): void;
  17657. /**
  17658. * Remove one of the post process from the list of attached post processes to the texture
  17659. * @param postProcess define the post process to remove from the list
  17660. */
  17661. removePostProcess(postProcess: PostProcess): void;
  17662. /** @hidden */
  17663. _shouldRender(): boolean;
  17664. /**
  17665. * Gets the actual render size of the texture.
  17666. * @returns the width of the render size
  17667. */
  17668. getRenderSize(): number;
  17669. /**
  17670. * Gets the actual render width of the texture.
  17671. * @returns the width of the render size
  17672. */
  17673. getRenderWidth(): number;
  17674. /**
  17675. * Gets the actual render height of the texture.
  17676. * @returns the height of the render size
  17677. */
  17678. getRenderHeight(): number;
  17679. /**
  17680. * Get if the texture can be rescaled or not.
  17681. */
  17682. readonly canRescale: boolean;
  17683. /**
  17684. * Resize the texture using a ratio.
  17685. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17686. */
  17687. scale(ratio: number): void;
  17688. /**
  17689. * Get the texture reflection matrix used to rotate/transform the reflection.
  17690. * @returns the reflection matrix
  17691. */
  17692. getReflectionTextureMatrix(): Matrix;
  17693. /**
  17694. * Resize the texture to a new desired size.
  17695. * Be carrefull as it will recreate all the data in the new texture.
  17696. * @param size Define the new size. It can be:
  17697. * - a number for squared texture,
  17698. * - an object containing { width: number, height: number }
  17699. * - or an object containing a ratio { ratio: number }
  17700. */
  17701. resize(size: number | {
  17702. width: number;
  17703. height: number;
  17704. } | {
  17705. ratio: number;
  17706. }): void;
  17707. /**
  17708. * Renders all the objects from the render list into the texture.
  17709. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17710. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17711. */
  17712. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17713. private _bestReflectionRenderTargetDimension;
  17714. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17715. private renderToTarget;
  17716. /**
  17717. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17718. * This allowed control for front to back rendering or reversly depending of the special needs.
  17719. *
  17720. * @param renderingGroupId The rendering group id corresponding to its index
  17721. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17722. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17723. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17724. */
  17725. 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;
  17726. /**
  17727. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17728. *
  17729. * @param renderingGroupId The rendering group id corresponding to its index
  17730. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17731. */
  17732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17733. /**
  17734. * Clones the texture.
  17735. * @returns the cloned texture
  17736. */
  17737. clone(): RenderTargetTexture;
  17738. /**
  17739. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17740. * @returns The JSON representation of the texture
  17741. */
  17742. serialize(): any;
  17743. /**
  17744. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17745. */
  17746. disposeFramebufferObjects(): void;
  17747. /**
  17748. * Dispose the texture and release its associated resources.
  17749. */
  17750. dispose(): void;
  17751. /** @hidden */
  17752. _rebuild(): void;
  17753. /**
  17754. * Clear the info related to rendering groups preventing retention point in material dispose.
  17755. */
  17756. freeRenderingGroups(): void;
  17757. }
  17758. }
  17759. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17760. import { Scene } from "babylonjs/scene";
  17761. import { Plane } from "babylonjs/Maths/math";
  17762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17763. /**
  17764. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17765. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17766. * You can then easily use it as a reflectionTexture on a flat surface.
  17767. * In case the surface is not a plane, please consider relying on reflection probes.
  17768. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17769. */
  17770. export class MirrorTexture extends RenderTargetTexture {
  17771. private scene;
  17772. /**
  17773. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17774. * 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.
  17775. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17776. */
  17777. mirrorPlane: Plane;
  17778. /**
  17779. * Define the blur ratio used to blur the reflection if needed.
  17780. */
  17781. blurRatio: number;
  17782. /**
  17783. * Define the adaptive blur kernel used to blur the reflection if needed.
  17784. * This will autocompute the closest best match for the `blurKernel`
  17785. */
  17786. adaptiveBlurKernel: number;
  17787. /**
  17788. * Define the blur kernel used to blur the reflection if needed.
  17789. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17790. */
  17791. blurKernel: number;
  17792. /**
  17793. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17794. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17795. */
  17796. blurKernelX: number;
  17797. /**
  17798. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17800. */
  17801. blurKernelY: number;
  17802. private _autoComputeBlurKernel;
  17803. protected _onRatioRescale(): void;
  17804. private _updateGammaSpace;
  17805. private _imageProcessingConfigChangeObserver;
  17806. private _transformMatrix;
  17807. private _mirrorMatrix;
  17808. private _savedViewMatrix;
  17809. private _blurX;
  17810. private _blurY;
  17811. private _adaptiveBlurKernel;
  17812. private _blurKernelX;
  17813. private _blurKernelY;
  17814. private _blurRatio;
  17815. /**
  17816. * Instantiates a Mirror Texture.
  17817. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17818. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17819. * You can then easily use it as a reflectionTexture on a flat surface.
  17820. * In case the surface is not a plane, please consider relying on reflection probes.
  17821. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17822. * @param name
  17823. * @param size
  17824. * @param scene
  17825. * @param generateMipMaps
  17826. * @param type
  17827. * @param samplingMode
  17828. * @param generateDepthBuffer
  17829. */
  17830. constructor(name: string, size: number | {
  17831. width: number;
  17832. height: number;
  17833. } | {
  17834. ratio: number;
  17835. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17836. private _preparePostProcesses;
  17837. /**
  17838. * Clone the mirror texture.
  17839. * @returns the cloned texture
  17840. */
  17841. clone(): MirrorTexture;
  17842. /**
  17843. * Serialize the texture to a JSON representation you could use in Parse later on
  17844. * @returns the serialized JSON representation
  17845. */
  17846. serialize(): any;
  17847. /**
  17848. * Dispose the texture and release its associated resources.
  17849. */
  17850. dispose(): void;
  17851. }
  17852. }
  17853. declare module "babylonjs/Materials/Textures/texture" {
  17854. import { Observable } from "babylonjs/Misc/observable";
  17855. import { Nullable } from "babylonjs/types";
  17856. import { Scene } from "babylonjs/scene";
  17857. import { Matrix } from "babylonjs/Maths/math";
  17858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17859. /**
  17860. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17861. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17862. */
  17863. export class Texture extends BaseTexture {
  17864. /** @hidden */
  17865. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17866. /** @hidden */
  17867. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17868. /** @hidden */
  17869. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17870. /** nearest is mag = nearest and min = nearest and mip = linear */
  17871. static readonly NEAREST_SAMPLINGMODE: number;
  17872. /** nearest is mag = nearest and min = nearest and mip = linear */
  17873. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17874. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17875. static readonly BILINEAR_SAMPLINGMODE: number;
  17876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17877. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17878. /** Trilinear is mag = linear and min = linear and mip = linear */
  17879. static readonly TRILINEAR_SAMPLINGMODE: number;
  17880. /** Trilinear is mag = linear and min = linear and mip = linear */
  17881. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17882. /** mag = nearest and min = nearest and mip = nearest */
  17883. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17884. /** mag = nearest and min = linear and mip = nearest */
  17885. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17886. /** mag = nearest and min = linear and mip = linear */
  17887. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17888. /** mag = nearest and min = linear and mip = none */
  17889. static readonly NEAREST_LINEAR: number;
  17890. /** mag = nearest and min = nearest and mip = none */
  17891. static readonly NEAREST_NEAREST: number;
  17892. /** mag = linear and min = nearest and mip = nearest */
  17893. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17894. /** mag = linear and min = nearest and mip = linear */
  17895. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17896. /** mag = linear and min = linear and mip = none */
  17897. static readonly LINEAR_LINEAR: number;
  17898. /** mag = linear and min = nearest and mip = none */
  17899. static readonly LINEAR_NEAREST: number;
  17900. /** Explicit coordinates mode */
  17901. static readonly EXPLICIT_MODE: number;
  17902. /** Spherical coordinates mode */
  17903. static readonly SPHERICAL_MODE: number;
  17904. /** Planar coordinates mode */
  17905. static readonly PLANAR_MODE: number;
  17906. /** Cubic coordinates mode */
  17907. static readonly CUBIC_MODE: number;
  17908. /** Projection coordinates mode */
  17909. static readonly PROJECTION_MODE: number;
  17910. /** Inverse Cubic coordinates mode */
  17911. static readonly SKYBOX_MODE: number;
  17912. /** Inverse Cubic coordinates mode */
  17913. static readonly INVCUBIC_MODE: number;
  17914. /** Equirectangular coordinates mode */
  17915. static readonly EQUIRECTANGULAR_MODE: number;
  17916. /** Equirectangular Fixed coordinates mode */
  17917. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17918. /** Equirectangular Fixed Mirrored coordinates mode */
  17919. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17920. /** Texture is not repeating outside of 0..1 UVs */
  17921. static readonly CLAMP_ADDRESSMODE: number;
  17922. /** Texture is repeating outside of 0..1 UVs */
  17923. static readonly WRAP_ADDRESSMODE: number;
  17924. /** Texture is repeating and mirrored */
  17925. static readonly MIRROR_ADDRESSMODE: number;
  17926. /**
  17927. * 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
  17928. */
  17929. static UseSerializedUrlIfAny: boolean;
  17930. /**
  17931. * Define the url of the texture.
  17932. */
  17933. url: Nullable<string>;
  17934. /**
  17935. * Define an offset on the texture to offset the u coordinates of the UVs
  17936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17937. */
  17938. uOffset: number;
  17939. /**
  17940. * Define an offset on the texture to offset the v coordinates of the UVs
  17941. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17942. */
  17943. vOffset: number;
  17944. /**
  17945. * Define an offset on the texture to scale the u coordinates of the UVs
  17946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17947. */
  17948. uScale: number;
  17949. /**
  17950. * Define an offset on the texture to scale the v coordinates of the UVs
  17951. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17952. */
  17953. vScale: number;
  17954. /**
  17955. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17956. * @see http://doc.babylonjs.com/how_to/more_materials
  17957. */
  17958. uAng: number;
  17959. /**
  17960. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17961. * @see http://doc.babylonjs.com/how_to/more_materials
  17962. */
  17963. vAng: number;
  17964. /**
  17965. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17966. * @see http://doc.babylonjs.com/how_to/more_materials
  17967. */
  17968. wAng: number;
  17969. /**
  17970. * Defines the center of rotation (U)
  17971. */
  17972. uRotationCenter: number;
  17973. /**
  17974. * Defines the center of rotation (V)
  17975. */
  17976. vRotationCenter: number;
  17977. /**
  17978. * Defines the center of rotation (W)
  17979. */
  17980. wRotationCenter: number;
  17981. /**
  17982. * Are mip maps generated for this texture or not.
  17983. */
  17984. readonly noMipmap: boolean;
  17985. private _noMipmap;
  17986. /** @hidden */
  17987. _invertY: boolean;
  17988. private _rowGenerationMatrix;
  17989. private _cachedTextureMatrix;
  17990. private _projectionModeMatrix;
  17991. private _t0;
  17992. private _t1;
  17993. private _t2;
  17994. private _cachedUOffset;
  17995. private _cachedVOffset;
  17996. private _cachedUScale;
  17997. private _cachedVScale;
  17998. private _cachedUAng;
  17999. private _cachedVAng;
  18000. private _cachedWAng;
  18001. private _cachedProjectionMatrixId;
  18002. private _cachedCoordinatesMode;
  18003. /** @hidden */
  18004. protected _initialSamplingMode: number;
  18005. /** @hidden */
  18006. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18007. private _deleteBuffer;
  18008. protected _format: Nullable<number>;
  18009. private _delayedOnLoad;
  18010. private _delayedOnError;
  18011. /**
  18012. * Observable triggered once the texture has been loaded.
  18013. */
  18014. onLoadObservable: Observable<Texture>;
  18015. protected _isBlocking: boolean;
  18016. /**
  18017. * Is the texture preventing material to render while loading.
  18018. * If false, a default texture will be used instead of the loading one during the preparation step.
  18019. */
  18020. isBlocking: boolean;
  18021. /**
  18022. * Get the current sampling mode associated with the texture.
  18023. */
  18024. readonly samplingMode: number;
  18025. /**
  18026. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18027. */
  18028. readonly invertY: boolean;
  18029. /**
  18030. * Instantiates a new texture.
  18031. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18032. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18033. * @param url define the url of the picture to load as a texture
  18034. * @param scene define the scene the texture will belong to
  18035. * @param noMipmap define if the texture will require mip maps or not
  18036. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18037. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18038. * @param onLoad define a callback triggered when the texture has been loaded
  18039. * @param onError define a callback triggered when an error occurred during the loading session
  18040. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18041. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18042. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18043. */
  18044. 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);
  18045. /**
  18046. * Update the url (and optional buffer) of this texture if url was null during construction.
  18047. * @param url the url of the texture
  18048. * @param buffer the buffer of the texture (defaults to null)
  18049. * @param onLoad callback called when the texture is loaded (defaults to null)
  18050. */
  18051. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18052. /**
  18053. * Finish the loading sequence of a texture flagged as delayed load.
  18054. * @hidden
  18055. */
  18056. delayLoad(): void;
  18057. private _prepareRowForTextureGeneration;
  18058. /**
  18059. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18060. * @returns the transform matrix of the texture.
  18061. */
  18062. getTextureMatrix(): Matrix;
  18063. /**
  18064. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18065. * @returns The reflection texture transform
  18066. */
  18067. getReflectionTextureMatrix(): Matrix;
  18068. /**
  18069. * Clones the texture.
  18070. * @returns the cloned texture
  18071. */
  18072. clone(): Texture;
  18073. /**
  18074. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18075. * @returns The JSON representation of the texture
  18076. */
  18077. serialize(): any;
  18078. /**
  18079. * Get the current class name of the texture useful for serialization or dynamic coding.
  18080. * @returns "Texture"
  18081. */
  18082. getClassName(): string;
  18083. /**
  18084. * Dispose the texture and release its associated resources.
  18085. */
  18086. dispose(): void;
  18087. /**
  18088. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18089. * @param parsedTexture Define the JSON representation of the texture
  18090. * @param scene Define the scene the parsed texture should be instantiated in
  18091. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18092. * @returns The parsed texture if successful
  18093. */
  18094. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18095. /**
  18096. * Creates a texture from its base 64 representation.
  18097. * @param data Define the base64 payload without the data: prefix
  18098. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18099. * @param scene Define the scene the texture should belong to
  18100. * @param noMipmap Forces the texture to not create mip map information if true
  18101. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18102. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18103. * @param onLoad define a callback triggered when the texture has been loaded
  18104. * @param onError define a callback triggered when an error occurred during the loading session
  18105. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18106. * @returns the created texture
  18107. */
  18108. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18109. /**
  18110. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18111. * @param data Define the base64 payload without the data: prefix
  18112. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18113. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18114. * @param scene Define the scene the texture should belong to
  18115. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18116. * @param noMipmap Forces the texture to not create mip map information if true
  18117. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18118. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18119. * @param onLoad define a callback triggered when the texture has been loaded
  18120. * @param onError define a callback triggered when an error occurred during the loading session
  18121. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18122. * @returns the created texture
  18123. */
  18124. 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;
  18125. }
  18126. }
  18127. declare module "babylonjs/Materials/shaderMaterial" {
  18128. import { Scene } from "babylonjs/scene";
  18129. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  18130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18131. import { Mesh } from "babylonjs/Meshes/mesh";
  18132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18133. import { Texture } from "babylonjs/Materials/Textures/texture";
  18134. import { Material } from "babylonjs/Materials/material";
  18135. /**
  18136. * Defines the options associated with the creation of a shader material.
  18137. */
  18138. export interface IShaderMaterialOptions {
  18139. /**
  18140. * Does the material work in alpha blend mode
  18141. */
  18142. needAlphaBlending: boolean;
  18143. /**
  18144. * Does the material work in alpha test mode
  18145. */
  18146. needAlphaTesting: boolean;
  18147. /**
  18148. * The list of attribute names used in the shader
  18149. */
  18150. attributes: string[];
  18151. /**
  18152. * The list of unifrom names used in the shader
  18153. */
  18154. uniforms: string[];
  18155. /**
  18156. * The list of UBO names used in the shader
  18157. */
  18158. uniformBuffers: string[];
  18159. /**
  18160. * The list of sampler names used in the shader
  18161. */
  18162. samplers: string[];
  18163. /**
  18164. * The list of defines used in the shader
  18165. */
  18166. defines: string[];
  18167. }
  18168. /**
  18169. * 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.
  18170. *
  18171. * This returned material effects how the mesh will look based on the code in the shaders.
  18172. *
  18173. * @see http://doc.babylonjs.com/how_to/shader_material
  18174. */
  18175. export class ShaderMaterial extends Material {
  18176. private _shaderPath;
  18177. private _options;
  18178. private _textures;
  18179. private _textureArrays;
  18180. private _floats;
  18181. private _ints;
  18182. private _floatsArrays;
  18183. private _colors3;
  18184. private _colors3Arrays;
  18185. private _colors4;
  18186. private _vectors2;
  18187. private _vectors3;
  18188. private _vectors4;
  18189. private _matrices;
  18190. private _matrices3x3;
  18191. private _matrices2x2;
  18192. private _vectors2Arrays;
  18193. private _vectors3Arrays;
  18194. private _cachedWorldViewMatrix;
  18195. private _renderId;
  18196. /**
  18197. * Instantiate a new shader material.
  18198. * 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.
  18199. * This returned material effects how the mesh will look based on the code in the shaders.
  18200. * @see http://doc.babylonjs.com/how_to/shader_material
  18201. * @param name Define the name of the material in the scene
  18202. * @param scene Define the scene the material belongs to
  18203. * @param shaderPath Defines the route to the shader code in one of three ways:
  18204. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18205. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18206. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18207. * @param options Define the options used to create the shader
  18208. */
  18209. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18210. /**
  18211. * Gets the current class name of the material e.g. "ShaderMaterial"
  18212. * Mainly use in serialization.
  18213. * @returns the class name
  18214. */
  18215. getClassName(): string;
  18216. /**
  18217. * Specifies if the material will require alpha blending
  18218. * @returns a boolean specifying if alpha blending is needed
  18219. */
  18220. needAlphaBlending(): boolean;
  18221. /**
  18222. * Specifies if this material should be rendered in alpha test mode
  18223. * @returns a boolean specifying if an alpha test is needed.
  18224. */
  18225. needAlphaTesting(): boolean;
  18226. private _checkUniform;
  18227. /**
  18228. * Set a texture in the shader.
  18229. * @param name Define the name of the uniform samplers as defined in the shader
  18230. * @param texture Define the texture to bind to this sampler
  18231. * @return the material itself allowing "fluent" like uniform updates
  18232. */
  18233. setTexture(name: string, texture: Texture): ShaderMaterial;
  18234. /**
  18235. * Set a texture array in the shader.
  18236. * @param name Define the name of the uniform sampler array as defined in the shader
  18237. * @param textures Define the list of textures to bind to this sampler
  18238. * @return the material itself allowing "fluent" like uniform updates
  18239. */
  18240. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18241. /**
  18242. * Set a float in the shader.
  18243. * @param name Define the name of the uniform as defined in the shader
  18244. * @param value Define the value to give to the uniform
  18245. * @return the material itself allowing "fluent" like uniform updates
  18246. */
  18247. setFloat(name: string, value: number): ShaderMaterial;
  18248. /**
  18249. * Set a int in the shader.
  18250. * @param name Define the name of the uniform as defined in the shader
  18251. * @param value Define the value to give to the uniform
  18252. * @return the material itself allowing "fluent" like uniform updates
  18253. */
  18254. setInt(name: string, value: number): ShaderMaterial;
  18255. /**
  18256. * Set an array of floats in the shader.
  18257. * @param name Define the name of the uniform as defined in the shader
  18258. * @param value Define the value to give to the uniform
  18259. * @return the material itself allowing "fluent" like uniform updates
  18260. */
  18261. setFloats(name: string, value: number[]): ShaderMaterial;
  18262. /**
  18263. * Set a vec3 in the shader from a Color3.
  18264. * @param name Define the name of the uniform as defined in the shader
  18265. * @param value Define the value to give to the uniform
  18266. * @return the material itself allowing "fluent" like uniform updates
  18267. */
  18268. setColor3(name: string, value: Color3): ShaderMaterial;
  18269. /**
  18270. * Set a vec3 array in the shader from a Color3 array.
  18271. * @param name Define the name of the uniform as defined in the shader
  18272. * @param value Define the value to give to the uniform
  18273. * @return the material itself allowing "fluent" like uniform updates
  18274. */
  18275. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18276. /**
  18277. * Set a vec4 in the shader from a Color4.
  18278. * @param name Define the name of the uniform as defined in the shader
  18279. * @param value Define the value to give to the uniform
  18280. * @return the material itself allowing "fluent" like uniform updates
  18281. */
  18282. setColor4(name: string, value: Color4): ShaderMaterial;
  18283. /**
  18284. * Set a vec2 in the shader from a Vector2.
  18285. * @param name Define the name of the uniform as defined in the shader
  18286. * @param value Define the value to give to the uniform
  18287. * @return the material itself allowing "fluent" like uniform updates
  18288. */
  18289. setVector2(name: string, value: Vector2): ShaderMaterial;
  18290. /**
  18291. * Set a vec3 in the shader from a Vector3.
  18292. * @param name Define the name of the uniform as defined in the shader
  18293. * @param value Define the value to give to the uniform
  18294. * @return the material itself allowing "fluent" like uniform updates
  18295. */
  18296. setVector3(name: string, value: Vector3): ShaderMaterial;
  18297. /**
  18298. * Set a vec4 in the shader from a Vector4.
  18299. * @param name Define the name of the uniform as defined in the shader
  18300. * @param value Define the value to give to the uniform
  18301. * @return the material itself allowing "fluent" like uniform updates
  18302. */
  18303. setVector4(name: string, value: Vector4): ShaderMaterial;
  18304. /**
  18305. * Set a mat4 in the shader from a Matrix.
  18306. * @param name Define the name of the uniform as defined in the shader
  18307. * @param value Define the value to give to the uniform
  18308. * @return the material itself allowing "fluent" like uniform updates
  18309. */
  18310. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18311. /**
  18312. * Set a mat3 in the shader from a Float32Array.
  18313. * @param name Define the name of the uniform as defined in the shader
  18314. * @param value Define the value to give to the uniform
  18315. * @return the material itself allowing "fluent" like uniform updates
  18316. */
  18317. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18318. /**
  18319. * Set a mat2 in the shader from a Float32Array.
  18320. * @param name Define the name of the uniform as defined in the shader
  18321. * @param value Define the value to give to the uniform
  18322. * @return the material itself allowing "fluent" like uniform updates
  18323. */
  18324. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18325. /**
  18326. * Set a vec2 array in the shader from a number array.
  18327. * @param name Define the name of the uniform as defined in the shader
  18328. * @param value Define the value to give to the uniform
  18329. * @return the material itself allowing "fluent" like uniform updates
  18330. */
  18331. setArray2(name: string, value: number[]): ShaderMaterial;
  18332. /**
  18333. * Set a vec3 array in the shader from a number array.
  18334. * @param name Define the name of the uniform as defined in the shader
  18335. * @param value Define the value to give to the uniform
  18336. * @return the material itself allowing "fluent" like uniform updates
  18337. */
  18338. setArray3(name: string, value: number[]): ShaderMaterial;
  18339. private _checkCache;
  18340. /**
  18341. * Checks if the material is ready to render the requested mesh
  18342. * @param mesh Define the mesh to render
  18343. * @param useInstances Define whether or not the material is used with instances
  18344. * @returns true if ready, otherwise false
  18345. */
  18346. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18347. /**
  18348. * Binds the world matrix to the material
  18349. * @param world defines the world transformation matrix
  18350. */
  18351. bindOnlyWorldMatrix(world: Matrix): void;
  18352. /**
  18353. * Binds the material to the mesh
  18354. * @param world defines the world transformation matrix
  18355. * @param mesh defines the mesh to bind the material to
  18356. */
  18357. bind(world: Matrix, mesh?: Mesh): void;
  18358. /**
  18359. * Gets the active textures from the material
  18360. * @returns an array of textures
  18361. */
  18362. getActiveTextures(): BaseTexture[];
  18363. /**
  18364. * Specifies if the material uses a texture
  18365. * @param texture defines the texture to check against the material
  18366. * @returns a boolean specifying if the material uses the texture
  18367. */
  18368. hasTexture(texture: BaseTexture): boolean;
  18369. /**
  18370. * Makes a duplicate of the material, and gives it a new name
  18371. * @param name defines the new name for the duplicated material
  18372. * @returns the cloned material
  18373. */
  18374. clone(name: string): ShaderMaterial;
  18375. /**
  18376. * Disposes the material
  18377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18378. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18379. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18380. */
  18381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18382. /**
  18383. * Serializes this material in a JSON representation
  18384. * @returns the serialized material object
  18385. */
  18386. serialize(): any;
  18387. /**
  18388. * Creates a shader material from parsed shader material data
  18389. * @param source defines the JSON represnetation of the material
  18390. * @param scene defines the hosting scene
  18391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18392. * @returns a new material
  18393. */
  18394. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18395. }
  18396. }
  18397. declare module "babylonjs/Shaders/color.fragment" {
  18398. /** @hidden */
  18399. export var colorPixelShader: {
  18400. name: string;
  18401. shader: string;
  18402. };
  18403. }
  18404. declare module "babylonjs/Shaders/color.vertex" {
  18405. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  18406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  18407. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  18408. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  18409. /** @hidden */
  18410. export var colorVertexShader: {
  18411. name: string;
  18412. shader: string;
  18413. };
  18414. }
  18415. declare module "babylonjs/Meshes/linesMesh" {
  18416. import { Nullable } from "babylonjs/types";
  18417. import { Scene } from "babylonjs/scene";
  18418. import { Color3 } from "babylonjs/Maths/math";
  18419. import { Node } from "babylonjs/node";
  18420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18421. import { Mesh } from "babylonjs/Meshes/mesh";
  18422. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  18423. import { Effect } from "babylonjs/Materials/effect";
  18424. import { Material } from "babylonjs/Materials/material";
  18425. import "babylonjs/Shaders/color.fragment";
  18426. import "babylonjs/Shaders/color.vertex";
  18427. /**
  18428. * Line mesh
  18429. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18430. */
  18431. export class LinesMesh extends Mesh {
  18432. /**
  18433. * If vertex color should be applied to the mesh
  18434. */
  18435. useVertexColor?: boolean | undefined;
  18436. /**
  18437. * If vertex alpha should be applied to the mesh
  18438. */
  18439. useVertexAlpha?: boolean | undefined;
  18440. /**
  18441. * Color of the line (Default: White)
  18442. */
  18443. color: Color3;
  18444. /**
  18445. * Alpha of the line (Default: 1)
  18446. */
  18447. alpha: number;
  18448. /**
  18449. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18450. * This margin is expressed in world space coordinates, so its value may vary.
  18451. * Default value is 0.1
  18452. */
  18453. intersectionThreshold: number;
  18454. private _colorShader;
  18455. /**
  18456. * Creates a new LinesMesh
  18457. * @param name defines the name
  18458. * @param scene defines the hosting scene
  18459. * @param parent defines the parent mesh if any
  18460. * @param source defines the optional source LinesMesh used to clone data from
  18461. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18462. * When false, achieved by calling a clone(), also passing False.
  18463. * This will make creation of children, recursive.
  18464. * @param useVertexColor defines if this LinesMesh supports vertex color
  18465. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18466. */
  18467. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18468. /**
  18469. * If vertex color should be applied to the mesh
  18470. */
  18471. useVertexColor?: boolean | undefined,
  18472. /**
  18473. * If vertex alpha should be applied to the mesh
  18474. */
  18475. useVertexAlpha?: boolean | undefined);
  18476. /**
  18477. * Returns the string "LineMesh"
  18478. */
  18479. getClassName(): string;
  18480. /**
  18481. * @hidden
  18482. */
  18483. /**
  18484. * @hidden
  18485. */
  18486. material: Material;
  18487. /**
  18488. * @hidden
  18489. */
  18490. readonly checkCollisions: boolean;
  18491. /** @hidden */
  18492. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18493. /** @hidden */
  18494. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18495. /**
  18496. * Disposes of the line mesh
  18497. * @param doNotRecurse If children should be disposed
  18498. */
  18499. dispose(doNotRecurse?: boolean): void;
  18500. /**
  18501. * Returns a new LineMesh object cloned from the current one.
  18502. */
  18503. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18504. /**
  18505. * Creates a new InstancedLinesMesh object from the mesh model.
  18506. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18507. * @param name defines the name of the new instance
  18508. * @returns a new InstancedLinesMesh
  18509. */
  18510. createInstance(name: string): InstancedLinesMesh;
  18511. }
  18512. /**
  18513. * Creates an instance based on a source LinesMesh
  18514. */
  18515. export class InstancedLinesMesh extends InstancedMesh {
  18516. /**
  18517. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18518. * This margin is expressed in world space coordinates, so its value may vary.
  18519. * Initilized with the intersectionThreshold value of the source LinesMesh
  18520. */
  18521. intersectionThreshold: number;
  18522. constructor(name: string, source: LinesMesh);
  18523. /**
  18524. * Returns the string "InstancedLinesMesh".
  18525. */
  18526. getClassName(): string;
  18527. }
  18528. }
  18529. declare module "babylonjs/Meshes/groundMesh" {
  18530. import { Scene } from "babylonjs/scene";
  18531. import { Vector3 } from "babylonjs/Maths/math";
  18532. import { Mesh } from "babylonjs/Meshes/mesh";
  18533. /**
  18534. * Mesh representing the gorund
  18535. */
  18536. export class GroundMesh extends Mesh {
  18537. /** If octree should be generated */
  18538. generateOctree: boolean;
  18539. private _heightQuads;
  18540. /** @hidden */
  18541. _subdivisionsX: number;
  18542. /** @hidden */
  18543. _subdivisionsY: number;
  18544. /** @hidden */
  18545. _width: number;
  18546. /** @hidden */
  18547. _height: number;
  18548. /** @hidden */
  18549. _minX: number;
  18550. /** @hidden */
  18551. _maxX: number;
  18552. /** @hidden */
  18553. _minZ: number;
  18554. /** @hidden */
  18555. _maxZ: number;
  18556. constructor(name: string, scene: Scene);
  18557. /**
  18558. * "GroundMesh"
  18559. * @returns "GroundMesh"
  18560. */
  18561. getClassName(): string;
  18562. /**
  18563. * The minimum of x and y subdivisions
  18564. */
  18565. readonly subdivisions: number;
  18566. /**
  18567. * X subdivisions
  18568. */
  18569. readonly subdivisionsX: number;
  18570. /**
  18571. * Y subdivisions
  18572. */
  18573. readonly subdivisionsY: number;
  18574. /**
  18575. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18577. * @param chunksCount the number of subdivisions for x and y
  18578. * @param octreeBlocksSize (Default: 32)
  18579. */
  18580. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18581. /**
  18582. * Returns a height (y) value in the Worl system :
  18583. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18584. * @param x x coordinate
  18585. * @param z z coordinate
  18586. * @returns the ground y position if (x, z) are outside the ground surface.
  18587. */
  18588. getHeightAtCoordinates(x: number, z: number): number;
  18589. /**
  18590. * Returns a normalized vector (Vector3) orthogonal to the ground
  18591. * at the ground coordinates (x, z) expressed in the World system.
  18592. * @param x x coordinate
  18593. * @param z z coordinate
  18594. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18595. */
  18596. getNormalAtCoordinates(x: number, z: number): Vector3;
  18597. /**
  18598. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18599. * at the ground coordinates (x, z) expressed in the World system.
  18600. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18601. * @param x x coordinate
  18602. * @param z z coordinate
  18603. * @param ref vector to store the result
  18604. * @returns the GroundMesh.
  18605. */
  18606. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18607. /**
  18608. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18609. * if the ground has been updated.
  18610. * This can be used in the render loop.
  18611. * @returns the GroundMesh.
  18612. */
  18613. updateCoordinateHeights(): GroundMesh;
  18614. private _getFacetAt;
  18615. private _initHeightQuads;
  18616. private _computeHeightQuads;
  18617. /**
  18618. * Serializes this ground mesh
  18619. * @param serializationObject object to write serialization to
  18620. */
  18621. serialize(serializationObject: any): void;
  18622. /**
  18623. * Parses a serialized ground mesh
  18624. * @param parsedMesh the serialized mesh
  18625. * @param scene the scene to create the ground mesh in
  18626. * @returns the created ground mesh
  18627. */
  18628. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18629. }
  18630. }
  18631. declare module "babylonjs/Physics/physicsJoint" {
  18632. import { Vector3 } from "babylonjs/Maths/math";
  18633. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18634. /**
  18635. * Interface for Physics-Joint data
  18636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18637. */
  18638. export interface PhysicsJointData {
  18639. /**
  18640. * The main pivot of the joint
  18641. */
  18642. mainPivot?: Vector3;
  18643. /**
  18644. * The connected pivot of the joint
  18645. */
  18646. connectedPivot?: Vector3;
  18647. /**
  18648. * The main axis of the joint
  18649. */
  18650. mainAxis?: Vector3;
  18651. /**
  18652. * The connected axis of the joint
  18653. */
  18654. connectedAxis?: Vector3;
  18655. /**
  18656. * The collision of the joint
  18657. */
  18658. collision?: boolean;
  18659. /**
  18660. * Native Oimo/Cannon/Energy data
  18661. */
  18662. nativeParams?: any;
  18663. }
  18664. /**
  18665. * This is a holder class for the physics joint created by the physics plugin
  18666. * It holds a set of functions to control the underlying joint
  18667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18668. */
  18669. export class PhysicsJoint {
  18670. /**
  18671. * The type of the physics joint
  18672. */
  18673. type: number;
  18674. /**
  18675. * The data for the physics joint
  18676. */
  18677. jointData: PhysicsJointData;
  18678. private _physicsJoint;
  18679. protected _physicsPlugin: IPhysicsEnginePlugin;
  18680. /**
  18681. * Initializes the physics joint
  18682. * @param type The type of the physics joint
  18683. * @param jointData The data for the physics joint
  18684. */
  18685. constructor(
  18686. /**
  18687. * The type of the physics joint
  18688. */
  18689. type: number,
  18690. /**
  18691. * The data for the physics joint
  18692. */
  18693. jointData: PhysicsJointData);
  18694. /**
  18695. * Gets the physics joint
  18696. */
  18697. /**
  18698. * Sets the physics joint
  18699. */
  18700. physicsJoint: any;
  18701. /**
  18702. * Sets the physics plugin
  18703. */
  18704. physicsPlugin: IPhysicsEnginePlugin;
  18705. /**
  18706. * Execute a function that is physics-plugin specific.
  18707. * @param {Function} func the function that will be executed.
  18708. * It accepts two parameters: the physics world and the physics joint
  18709. */
  18710. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18711. /**
  18712. * Distance-Joint type
  18713. */
  18714. static DistanceJoint: number;
  18715. /**
  18716. * Hinge-Joint type
  18717. */
  18718. static HingeJoint: number;
  18719. /**
  18720. * Ball-and-Socket joint type
  18721. */
  18722. static BallAndSocketJoint: number;
  18723. /**
  18724. * Wheel-Joint type
  18725. */
  18726. static WheelJoint: number;
  18727. /**
  18728. * Slider-Joint type
  18729. */
  18730. static SliderJoint: number;
  18731. /**
  18732. * Prismatic-Joint type
  18733. */
  18734. static PrismaticJoint: number;
  18735. /**
  18736. * Universal-Joint type
  18737. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18738. */
  18739. static UniversalJoint: number;
  18740. /**
  18741. * Hinge-Joint 2 type
  18742. */
  18743. static Hinge2Joint: number;
  18744. /**
  18745. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18746. */
  18747. static PointToPointJoint: number;
  18748. /**
  18749. * Spring-Joint type
  18750. */
  18751. static SpringJoint: number;
  18752. /**
  18753. * Lock-Joint type
  18754. */
  18755. static LockJoint: number;
  18756. }
  18757. /**
  18758. * A class representing a physics distance joint
  18759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18760. */
  18761. export class DistanceJoint extends PhysicsJoint {
  18762. /**
  18763. *
  18764. * @param jointData The data for the Distance-Joint
  18765. */
  18766. constructor(jointData: DistanceJointData);
  18767. /**
  18768. * Update the predefined distance.
  18769. * @param maxDistance The maximum preferred distance
  18770. * @param minDistance The minimum preferred distance
  18771. */
  18772. updateDistance(maxDistance: number, minDistance?: number): void;
  18773. }
  18774. /**
  18775. * Represents a Motor-Enabled Joint
  18776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18777. */
  18778. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18779. /**
  18780. * Initializes the Motor-Enabled Joint
  18781. * @param type The type of the joint
  18782. * @param jointData The physica joint data for the joint
  18783. */
  18784. constructor(type: number, jointData: PhysicsJointData);
  18785. /**
  18786. * Set the motor values.
  18787. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18788. * @param force the force to apply
  18789. * @param maxForce max force for this motor.
  18790. */
  18791. setMotor(force?: number, maxForce?: number): void;
  18792. /**
  18793. * Set the motor's limits.
  18794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18795. * @param upperLimit The upper limit of the motor
  18796. * @param lowerLimit The lower limit of the motor
  18797. */
  18798. setLimit(upperLimit: number, lowerLimit?: number): void;
  18799. }
  18800. /**
  18801. * This class represents a single physics Hinge-Joint
  18802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18803. */
  18804. export class HingeJoint extends MotorEnabledJoint {
  18805. /**
  18806. * Initializes the Hinge-Joint
  18807. * @param jointData The joint data for the Hinge-Joint
  18808. */
  18809. constructor(jointData: PhysicsJointData);
  18810. /**
  18811. * Set the motor values.
  18812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18813. * @param {number} force the force to apply
  18814. * @param {number} maxForce max force for this motor.
  18815. */
  18816. setMotor(force?: number, maxForce?: number): void;
  18817. /**
  18818. * Set the motor's limits.
  18819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18820. * @param upperLimit The upper limit of the motor
  18821. * @param lowerLimit The lower limit of the motor
  18822. */
  18823. setLimit(upperLimit: number, lowerLimit?: number): void;
  18824. }
  18825. /**
  18826. * This class represents a dual hinge physics joint (same as wheel joint)
  18827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18828. */
  18829. export class Hinge2Joint extends MotorEnabledJoint {
  18830. /**
  18831. * Initializes the Hinge2-Joint
  18832. * @param jointData The joint data for the Hinge2-Joint
  18833. */
  18834. constructor(jointData: PhysicsJointData);
  18835. /**
  18836. * Set the motor values.
  18837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18838. * @param {number} force the force to apply
  18839. * @param {number} maxForce max force for this motor.
  18840. * @param {motorIndex} the motor's index, 0 or 1.
  18841. */
  18842. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18843. /**
  18844. * Set the motor limits.
  18845. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18846. * @param {number} upperLimit the upper limit
  18847. * @param {number} lowerLimit lower limit
  18848. * @param {motorIndex} the motor's index, 0 or 1.
  18849. */
  18850. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18851. }
  18852. /**
  18853. * Interface for a motor enabled joint
  18854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18855. */
  18856. export interface IMotorEnabledJoint {
  18857. /**
  18858. * Physics joint
  18859. */
  18860. physicsJoint: any;
  18861. /**
  18862. * Sets the motor of the motor-enabled joint
  18863. * @param force The force of the motor
  18864. * @param maxForce The maximum force of the motor
  18865. * @param motorIndex The index of the motor
  18866. */
  18867. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18868. /**
  18869. * Sets the limit of the motor
  18870. * @param upperLimit The upper limit of the motor
  18871. * @param lowerLimit The lower limit of the motor
  18872. * @param motorIndex The index of the motor
  18873. */
  18874. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18875. }
  18876. /**
  18877. * Joint data for a Distance-Joint
  18878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18879. */
  18880. export interface DistanceJointData extends PhysicsJointData {
  18881. /**
  18882. * Max distance the 2 joint objects can be apart
  18883. */
  18884. maxDistance: number;
  18885. }
  18886. /**
  18887. * Joint data from a spring joint
  18888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18889. */
  18890. export interface SpringJointData extends PhysicsJointData {
  18891. /**
  18892. * Length of the spring
  18893. */
  18894. length: number;
  18895. /**
  18896. * Stiffness of the spring
  18897. */
  18898. stiffness: number;
  18899. /**
  18900. * Damping of the spring
  18901. */
  18902. damping: number;
  18903. /** this callback will be called when applying the force to the impostors. */
  18904. forceApplicationCallback: () => void;
  18905. }
  18906. }
  18907. declare module "babylonjs/Physics/IPhysicsEngine" {
  18908. import { Nullable } from "babylonjs/types";
  18909. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18911. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18912. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18913. /**
  18914. * Interface used to describe a physics joint
  18915. */
  18916. export interface PhysicsImpostorJoint {
  18917. /** Defines the main impostor to which the joint is linked */
  18918. mainImpostor: PhysicsImpostor;
  18919. /** Defines the impostor that is connected to the main impostor using this joint */
  18920. connectedImpostor: PhysicsImpostor;
  18921. /** Defines the joint itself */
  18922. joint: PhysicsJoint;
  18923. }
  18924. /** @hidden */
  18925. export interface IPhysicsEnginePlugin {
  18926. world: any;
  18927. name: string;
  18928. setGravity(gravity: Vector3): void;
  18929. setTimeStep(timeStep: number): void;
  18930. getTimeStep(): number;
  18931. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18932. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18933. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18934. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18935. removePhysicsBody(impostor: PhysicsImpostor): void;
  18936. generateJoint(joint: PhysicsImpostorJoint): void;
  18937. removeJoint(joint: PhysicsImpostorJoint): void;
  18938. isSupported(): boolean;
  18939. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18940. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18941. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18942. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18943. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18944. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18945. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18946. getBodyMass(impostor: PhysicsImpostor): number;
  18947. getBodyFriction(impostor: PhysicsImpostor): number;
  18948. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18949. getBodyRestitution(impostor: PhysicsImpostor): number;
  18950. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18951. sleepBody(impostor: PhysicsImpostor): void;
  18952. wakeUpBody(impostor: PhysicsImpostor): void;
  18953. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18954. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18955. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18956. getRadius(impostor: PhysicsImpostor): number;
  18957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18959. dispose(): void;
  18960. }
  18961. /**
  18962. * Interface used to define a physics engine
  18963. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18964. */
  18965. export interface IPhysicsEngine {
  18966. /**
  18967. * Gets the gravity vector used by the simulation
  18968. */
  18969. gravity: Vector3;
  18970. /**
  18971. * Sets the gravity vector used by the simulation
  18972. * @param gravity defines the gravity vector to use
  18973. */
  18974. setGravity(gravity: Vector3): void;
  18975. /**
  18976. * Set the time step of the physics engine.
  18977. * Default is 1/60.
  18978. * To slow it down, enter 1/600 for example.
  18979. * To speed it up, 1/30
  18980. * @param newTimeStep the new timestep to apply to this world.
  18981. */
  18982. setTimeStep(newTimeStep: number): void;
  18983. /**
  18984. * Get the time step of the physics engine.
  18985. * @returns the current time step
  18986. */
  18987. getTimeStep(): number;
  18988. /**
  18989. * Release all resources
  18990. */
  18991. dispose(): void;
  18992. /**
  18993. * Gets the name of the current physics plugin
  18994. * @returns the name of the plugin
  18995. */
  18996. getPhysicsPluginName(): string;
  18997. /**
  18998. * Adding a new impostor for the impostor tracking.
  18999. * This will be done by the impostor itself.
  19000. * @param impostor the impostor to add
  19001. */
  19002. addImpostor(impostor: PhysicsImpostor): void;
  19003. /**
  19004. * Remove an impostor from the engine.
  19005. * This impostor and its mesh will not longer be updated by the physics engine.
  19006. * @param impostor the impostor to remove
  19007. */
  19008. removeImpostor(impostor: PhysicsImpostor): void;
  19009. /**
  19010. * Add a joint to the physics engine
  19011. * @param mainImpostor defines the main impostor to which the joint is added.
  19012. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19013. * @param joint defines the joint that will connect both impostors.
  19014. */
  19015. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19016. /**
  19017. * Removes a joint from the simulation
  19018. * @param mainImpostor defines the impostor used with the joint
  19019. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19020. * @param joint defines the joint to remove
  19021. */
  19022. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19023. /**
  19024. * Gets the current plugin used to run the simulation
  19025. * @returns current plugin
  19026. */
  19027. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19028. /**
  19029. * Gets the list of physic impostors
  19030. * @returns an array of PhysicsImpostor
  19031. */
  19032. getImpostors(): Array<PhysicsImpostor>;
  19033. /**
  19034. * Gets the impostor for a physics enabled object
  19035. * @param object defines the object impersonated by the impostor
  19036. * @returns the PhysicsImpostor or null if not found
  19037. */
  19038. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19039. /**
  19040. * Gets the impostor for a physics body object
  19041. * @param body defines physics body used by the impostor
  19042. * @returns the PhysicsImpostor or null if not found
  19043. */
  19044. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19045. /**
  19046. * Called by the scene. No need to call it.
  19047. * @param delta defines the timespam between frames
  19048. */
  19049. _step(delta: number): void;
  19050. }
  19051. }
  19052. declare module "babylonjs/Physics/physicsImpostor" {
  19053. import { Nullable, IndicesArray } from "babylonjs/types";
  19054. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19055. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19057. import { Scene } from "babylonjs/scene";
  19058. import { Bone } from "babylonjs/Bones/bone";
  19059. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19060. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19061. /**
  19062. * The interface for the physics imposter parameters
  19063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19064. */
  19065. export interface PhysicsImpostorParameters {
  19066. /**
  19067. * The mass of the physics imposter
  19068. */
  19069. mass: number;
  19070. /**
  19071. * The friction of the physics imposter
  19072. */
  19073. friction?: number;
  19074. /**
  19075. * The coefficient of restitution of the physics imposter
  19076. */
  19077. restitution?: number;
  19078. /**
  19079. * The native options of the physics imposter
  19080. */
  19081. nativeOptions?: any;
  19082. /**
  19083. * Specifies if the parent should be ignored
  19084. */
  19085. ignoreParent?: boolean;
  19086. /**
  19087. * Specifies if bi-directional transformations should be disabled
  19088. */
  19089. disableBidirectionalTransformation?: boolean;
  19090. }
  19091. /**
  19092. * Interface for a physics-enabled object
  19093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19094. */
  19095. export interface IPhysicsEnabledObject {
  19096. /**
  19097. * The position of the physics-enabled object
  19098. */
  19099. position: Vector3;
  19100. /**
  19101. * The rotation of the physics-enabled object
  19102. */
  19103. rotationQuaternion: Nullable<Quaternion>;
  19104. /**
  19105. * The scale of the physics-enabled object
  19106. */
  19107. scaling: Vector3;
  19108. /**
  19109. * The rotation of the physics-enabled object
  19110. */
  19111. rotation?: Vector3;
  19112. /**
  19113. * The parent of the physics-enabled object
  19114. */
  19115. parent?: any;
  19116. /**
  19117. * The bounding info of the physics-enabled object
  19118. * @returns The bounding info of the physics-enabled object
  19119. */
  19120. getBoundingInfo(): BoundingInfo;
  19121. /**
  19122. * Computes the world matrix
  19123. * @param force Specifies if the world matrix should be computed by force
  19124. * @returns A world matrix
  19125. */
  19126. computeWorldMatrix(force: boolean): Matrix;
  19127. /**
  19128. * Gets the world matrix
  19129. * @returns A world matrix
  19130. */
  19131. getWorldMatrix?(): Matrix;
  19132. /**
  19133. * Gets the child meshes
  19134. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19135. * @returns An array of abstract meshes
  19136. */
  19137. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19138. /**
  19139. * Gets the vertex data
  19140. * @param kind The type of vertex data
  19141. * @returns A nullable array of numbers, or a float32 array
  19142. */
  19143. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19144. /**
  19145. * Gets the indices from the mesh
  19146. * @returns A nullable array of index arrays
  19147. */
  19148. getIndices?(): Nullable<IndicesArray>;
  19149. /**
  19150. * Gets the scene from the mesh
  19151. * @returns the indices array or null
  19152. */
  19153. getScene?(): Scene;
  19154. /**
  19155. * Gets the absolute position from the mesh
  19156. * @returns the absolute position
  19157. */
  19158. getAbsolutePosition(): Vector3;
  19159. /**
  19160. * Gets the absolute pivot point from the mesh
  19161. * @returns the absolute pivot point
  19162. */
  19163. getAbsolutePivotPoint(): Vector3;
  19164. /**
  19165. * Rotates the mesh
  19166. * @param axis The axis of rotation
  19167. * @param amount The amount of rotation
  19168. * @param space The space of the rotation
  19169. * @returns The rotation transform node
  19170. */
  19171. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19172. /**
  19173. * Translates the mesh
  19174. * @param axis The axis of translation
  19175. * @param distance The distance of translation
  19176. * @param space The space of the translation
  19177. * @returns The transform node
  19178. */
  19179. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19180. /**
  19181. * Sets the absolute position of the mesh
  19182. * @param absolutePosition The absolute position of the mesh
  19183. * @returns The transform node
  19184. */
  19185. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19186. /**
  19187. * Gets the class name of the mesh
  19188. * @returns The class name
  19189. */
  19190. getClassName(): string;
  19191. }
  19192. /**
  19193. * Represents a physics imposter
  19194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19195. */
  19196. export class PhysicsImpostor {
  19197. /**
  19198. * The physics-enabled object used as the physics imposter
  19199. */
  19200. object: IPhysicsEnabledObject;
  19201. /**
  19202. * The type of the physics imposter
  19203. */
  19204. type: number;
  19205. private _options;
  19206. private _scene?;
  19207. /**
  19208. * The default object size of the imposter
  19209. */
  19210. static DEFAULT_OBJECT_SIZE: Vector3;
  19211. /**
  19212. * The identity quaternion of the imposter
  19213. */
  19214. static IDENTITY_QUATERNION: Quaternion;
  19215. /** @hidden */
  19216. _pluginData: any;
  19217. private _physicsEngine;
  19218. private _physicsBody;
  19219. private _bodyUpdateRequired;
  19220. private _onBeforePhysicsStepCallbacks;
  19221. private _onAfterPhysicsStepCallbacks;
  19222. /** @hidden */
  19223. _onPhysicsCollideCallbacks: Array<{
  19224. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19225. otherImpostors: Array<PhysicsImpostor>;
  19226. }>;
  19227. private _deltaPosition;
  19228. private _deltaRotation;
  19229. private _deltaRotationConjugated;
  19230. private _parent;
  19231. private _isDisposed;
  19232. private static _tmpVecs;
  19233. private static _tmpQuat;
  19234. /**
  19235. * Specifies if the physics imposter is disposed
  19236. */
  19237. readonly isDisposed: boolean;
  19238. /**
  19239. * Gets the mass of the physics imposter
  19240. */
  19241. mass: number;
  19242. /**
  19243. * Gets the coefficient of friction
  19244. */
  19245. /**
  19246. * Sets the coefficient of friction
  19247. */
  19248. friction: number;
  19249. /**
  19250. * Gets the coefficient of restitution
  19251. */
  19252. /**
  19253. * Sets the coefficient of restitution
  19254. */
  19255. restitution: number;
  19256. /**
  19257. * The unique id of the physics imposter
  19258. * set by the physics engine when adding this impostor to the array
  19259. */
  19260. uniqueId: number;
  19261. private _joints;
  19262. /**
  19263. * Initializes the physics imposter
  19264. * @param object The physics-enabled object used as the physics imposter
  19265. * @param type The type of the physics imposter
  19266. * @param _options The options for the physics imposter
  19267. * @param _scene The Babylon scene
  19268. */
  19269. constructor(
  19270. /**
  19271. * The physics-enabled object used as the physics imposter
  19272. */
  19273. object: IPhysicsEnabledObject,
  19274. /**
  19275. * The type of the physics imposter
  19276. */
  19277. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19278. /**
  19279. * This function will completly initialize this impostor.
  19280. * It will create a new body - but only if this mesh has no parent.
  19281. * If it has, this impostor will not be used other than to define the impostor
  19282. * of the child mesh.
  19283. * @hidden
  19284. */
  19285. _init(): void;
  19286. private _getPhysicsParent;
  19287. /**
  19288. * Should a new body be generated.
  19289. * @returns boolean specifying if body initialization is required
  19290. */
  19291. isBodyInitRequired(): boolean;
  19292. /**
  19293. * Sets the updated scaling
  19294. * @param updated Specifies if the scaling is updated
  19295. */
  19296. setScalingUpdated(): void;
  19297. /**
  19298. * Force a regeneration of this or the parent's impostor's body.
  19299. * Use under cautious - This will remove all joints already implemented.
  19300. */
  19301. forceUpdate(): void;
  19302. /**
  19303. * Gets the body that holds this impostor. Either its own, or its parent.
  19304. */
  19305. /**
  19306. * Set the physics body. Used mainly by the physics engine/plugin
  19307. */
  19308. physicsBody: any;
  19309. /**
  19310. * Get the parent of the physics imposter
  19311. * @returns Physics imposter or null
  19312. */
  19313. /**
  19314. * Sets the parent of the physics imposter
  19315. */
  19316. parent: Nullable<PhysicsImpostor>;
  19317. /**
  19318. * Resets the update flags
  19319. */
  19320. resetUpdateFlags(): void;
  19321. /**
  19322. * Gets the object extend size
  19323. * @returns the object extend size
  19324. */
  19325. getObjectExtendSize(): Vector3;
  19326. /**
  19327. * Gets the object center
  19328. * @returns The object center
  19329. */
  19330. getObjectCenter(): Vector3;
  19331. /**
  19332. * Get a specific parametes from the options parameter
  19333. * @param paramName The object parameter name
  19334. * @returns The object parameter
  19335. */
  19336. getParam(paramName: string): any;
  19337. /**
  19338. * Sets a specific parameter in the options given to the physics plugin
  19339. * @param paramName The parameter name
  19340. * @param value The value of the parameter
  19341. */
  19342. setParam(paramName: string, value: number): void;
  19343. /**
  19344. * Specifically change the body's mass option. Won't recreate the physics body object
  19345. * @param mass The mass of the physics imposter
  19346. */
  19347. setMass(mass: number): void;
  19348. /**
  19349. * Gets the linear velocity
  19350. * @returns linear velocity or null
  19351. */
  19352. getLinearVelocity(): Nullable<Vector3>;
  19353. /**
  19354. * Sets the linear velocity
  19355. * @param velocity linear velocity or null
  19356. */
  19357. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19358. /**
  19359. * Gets the angular velocity
  19360. * @returns angular velocity or null
  19361. */
  19362. getAngularVelocity(): Nullable<Vector3>;
  19363. /**
  19364. * Sets the angular velocity
  19365. * @param velocity The velocity or null
  19366. */
  19367. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19368. /**
  19369. * Execute a function with the physics plugin native code
  19370. * Provide a function the will have two variables - the world object and the physics body object
  19371. * @param func The function to execute with the physics plugin native code
  19372. */
  19373. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19374. /**
  19375. * Register a function that will be executed before the physics world is stepping forward
  19376. * @param func The function to execute before the physics world is stepped forward
  19377. */
  19378. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19379. /**
  19380. * Unregister a function that will be executed before the physics world is stepping forward
  19381. * @param func The function to execute before the physics world is stepped forward
  19382. */
  19383. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19384. /**
  19385. * Register a function that will be executed after the physics step
  19386. * @param func The function to execute after physics step
  19387. */
  19388. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19389. /**
  19390. * Unregisters a function that will be executed after the physics step
  19391. * @param func The function to execute after physics step
  19392. */
  19393. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19394. /**
  19395. * register a function that will be executed when this impostor collides against a different body
  19396. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19397. * @param func Callback that is executed on collision
  19398. */
  19399. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19400. /**
  19401. * Unregisters the physics imposter on contact
  19402. * @param collideAgainst The physics object to collide against
  19403. * @param func Callback to execute on collision
  19404. */
  19405. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19406. private _tmpQuat;
  19407. private _tmpQuat2;
  19408. /**
  19409. * Get the parent rotation
  19410. * @returns The parent rotation
  19411. */
  19412. getParentsRotation(): Quaternion;
  19413. /**
  19414. * this function is executed by the physics engine.
  19415. */
  19416. beforeStep: () => void;
  19417. /**
  19418. * this function is executed by the physics engine
  19419. */
  19420. afterStep: () => void;
  19421. /**
  19422. * Legacy collision detection event support
  19423. */
  19424. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19425. /**
  19426. * event and body object due to cannon's event-based architecture.
  19427. */
  19428. onCollide: (e: {
  19429. body: any;
  19430. }) => void;
  19431. /**
  19432. * Apply a force
  19433. * @param force The force to apply
  19434. * @param contactPoint The contact point for the force
  19435. * @returns The physics imposter
  19436. */
  19437. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19438. /**
  19439. * Apply an impulse
  19440. * @param force The impulse force
  19441. * @param contactPoint The contact point for the impulse force
  19442. * @returns The physics imposter
  19443. */
  19444. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19445. /**
  19446. * A help function to create a joint
  19447. * @param otherImpostor A physics imposter used to create a joint
  19448. * @param jointType The type of joint
  19449. * @param jointData The data for the joint
  19450. * @returns The physics imposter
  19451. */
  19452. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19453. /**
  19454. * Add a joint to this impostor with a different impostor
  19455. * @param otherImpostor A physics imposter used to add a joint
  19456. * @param joint The joint to add
  19457. * @returns The physics imposter
  19458. */
  19459. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19460. /**
  19461. * Will keep this body still, in a sleep mode.
  19462. * @returns the physics imposter
  19463. */
  19464. sleep(): PhysicsImpostor;
  19465. /**
  19466. * Wake the body up.
  19467. * @returns The physics imposter
  19468. */
  19469. wakeUp(): PhysicsImpostor;
  19470. /**
  19471. * Clones the physics imposter
  19472. * @param newObject The physics imposter clones to this physics-enabled object
  19473. * @returns A nullable physics imposter
  19474. */
  19475. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19476. /**
  19477. * Disposes the physics imposter
  19478. */
  19479. dispose(): void;
  19480. /**
  19481. * Sets the delta position
  19482. * @param position The delta position amount
  19483. */
  19484. setDeltaPosition(position: Vector3): void;
  19485. /**
  19486. * Sets the delta rotation
  19487. * @param rotation The delta rotation amount
  19488. */
  19489. setDeltaRotation(rotation: Quaternion): void;
  19490. /**
  19491. * Gets the box size of the physics imposter and stores the result in the input parameter
  19492. * @param result Stores the box size
  19493. * @returns The physics imposter
  19494. */
  19495. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19496. /**
  19497. * Gets the radius of the physics imposter
  19498. * @returns Radius of the physics imposter
  19499. */
  19500. getRadius(): number;
  19501. /**
  19502. * Sync a bone with this impostor
  19503. * @param bone The bone to sync to the impostor.
  19504. * @param boneMesh The mesh that the bone is influencing.
  19505. * @param jointPivot The pivot of the joint / bone in local space.
  19506. * @param distToJoint Optional distance from the impostor to the joint.
  19507. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19508. */
  19509. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19510. /**
  19511. * Sync impostor to a bone
  19512. * @param bone The bone that the impostor will be synced to.
  19513. * @param boneMesh The mesh that the bone is influencing.
  19514. * @param jointPivot The pivot of the joint / bone in local space.
  19515. * @param distToJoint Optional distance from the impostor to the joint.
  19516. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19517. * @param boneAxis Optional vector3 axis the bone is aligned with
  19518. */
  19519. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19520. /**
  19521. * No-Imposter type
  19522. */
  19523. static NoImpostor: number;
  19524. /**
  19525. * Sphere-Imposter type
  19526. */
  19527. static SphereImpostor: number;
  19528. /**
  19529. * Box-Imposter type
  19530. */
  19531. static BoxImpostor: number;
  19532. /**
  19533. * Plane-Imposter type
  19534. */
  19535. static PlaneImpostor: number;
  19536. /**
  19537. * Mesh-imposter type
  19538. */
  19539. static MeshImpostor: number;
  19540. /**
  19541. * Cylinder-Imposter type
  19542. */
  19543. static CylinderImpostor: number;
  19544. /**
  19545. * Particle-Imposter type
  19546. */
  19547. static ParticleImpostor: number;
  19548. /**
  19549. * Heightmap-Imposter type
  19550. */
  19551. static HeightmapImpostor: number;
  19552. }
  19553. }
  19554. declare module "babylonjs/Meshes/mesh" {
  19555. import { Observable } from "babylonjs/Misc/observable";
  19556. import { IAnimatable } from "babylonjs/Misc/tools";
  19557. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19558. import { Camera } from "babylonjs/Cameras/camera";
  19559. import { Scene } from "babylonjs/scene";
  19560. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19561. import { Engine } from "babylonjs/Engines/engine";
  19562. import { Node } from "babylonjs/node";
  19563. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19564. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19565. import { Buffer } from "babylonjs/Meshes/buffer";
  19566. import { Geometry } from "babylonjs/Meshes/geometry";
  19567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19569. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19570. import { Effect } from "babylonjs/Materials/effect";
  19571. import { Material } from "babylonjs/Materials/material";
  19572. import { Skeleton } from "babylonjs/Bones/skeleton";
  19573. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19574. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19575. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19576. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19577. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19578. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  19579. /**
  19580. * Class used to represent a specific level of detail of a mesh
  19581. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19582. */
  19583. export class MeshLODLevel {
  19584. /** Defines the distance where this level should star being displayed */
  19585. distance: number;
  19586. /** Defines the mesh to use to render this level */
  19587. mesh: Nullable<Mesh>;
  19588. /**
  19589. * Creates a new LOD level
  19590. * @param distance defines the distance where this level should star being displayed
  19591. * @param mesh defines the mesh to use to render this level
  19592. */
  19593. constructor(
  19594. /** Defines the distance where this level should star being displayed */
  19595. distance: number,
  19596. /** Defines the mesh to use to render this level */
  19597. mesh: Nullable<Mesh>);
  19598. }
  19599. /**
  19600. * @hidden
  19601. **/
  19602. export class _CreationDataStorage {
  19603. closePath?: boolean;
  19604. closeArray?: boolean;
  19605. idx: number[];
  19606. dashSize: number;
  19607. gapSize: number;
  19608. path3D: Path3D;
  19609. pathArray: Vector3[][];
  19610. arc: number;
  19611. radius: number;
  19612. cap: number;
  19613. tessellation: number;
  19614. }
  19615. /**
  19616. * @hidden
  19617. **/
  19618. class _InstanceDataStorage {
  19619. visibleInstances: any;
  19620. renderIdForInstances: number[];
  19621. batchCache: _InstancesBatch;
  19622. instancesBufferSize: number;
  19623. instancesBuffer: Nullable<Buffer>;
  19624. instancesData: Float32Array;
  19625. overridenInstanceCount: number;
  19626. }
  19627. /**
  19628. * @hidden
  19629. **/
  19630. export class _InstancesBatch {
  19631. mustReturn: boolean;
  19632. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19633. renderSelf: boolean[];
  19634. }
  19635. /**
  19636. * Class used to represent renderable models
  19637. */
  19638. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19639. /**
  19640. * Mesh side orientation : usually the external or front surface
  19641. */
  19642. static readonly FRONTSIDE: number;
  19643. /**
  19644. * Mesh side orientation : usually the internal or back surface
  19645. */
  19646. static readonly BACKSIDE: number;
  19647. /**
  19648. * Mesh side orientation : both internal and external or front and back surfaces
  19649. */
  19650. static readonly DOUBLESIDE: number;
  19651. /**
  19652. * Mesh side orientation : by default, `FRONTSIDE`
  19653. */
  19654. static readonly DEFAULTSIDE: number;
  19655. /**
  19656. * Mesh cap setting : no cap
  19657. */
  19658. static readonly NO_CAP: number;
  19659. /**
  19660. * Mesh cap setting : one cap at the beginning of the mesh
  19661. */
  19662. static readonly CAP_START: number;
  19663. /**
  19664. * Mesh cap setting : one cap at the end of the mesh
  19665. */
  19666. static readonly CAP_END: number;
  19667. /**
  19668. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19669. */
  19670. static readonly CAP_ALL: number;
  19671. /**
  19672. * Gets the default side orientation.
  19673. * @param orientation the orientation to value to attempt to get
  19674. * @returns the default orientation
  19675. * @hidden
  19676. */
  19677. static _GetDefaultSideOrientation(orientation?: number): number;
  19678. private _onBeforeRenderObservable;
  19679. private _onBeforeBindObservable;
  19680. private _onAfterRenderObservable;
  19681. private _onBeforeDrawObservable;
  19682. /**
  19683. * An event triggered before rendering the mesh
  19684. */
  19685. readonly onBeforeRenderObservable: Observable<Mesh>;
  19686. /**
  19687. * An event triggered before binding the mesh
  19688. */
  19689. readonly onBeforeBindObservable: Observable<Mesh>;
  19690. /**
  19691. * An event triggered after rendering the mesh
  19692. */
  19693. readonly onAfterRenderObservable: Observable<Mesh>;
  19694. /**
  19695. * An event triggered before drawing the mesh
  19696. */
  19697. readonly onBeforeDrawObservable: Observable<Mesh>;
  19698. private _onBeforeDrawObserver;
  19699. /**
  19700. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19701. */
  19702. onBeforeDraw: () => void;
  19703. /**
  19704. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19705. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19706. */
  19707. delayLoadState: number;
  19708. /**
  19709. * Gets the list of instances created from this mesh
  19710. * it is not supposed to be modified manually.
  19711. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19712. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19713. */
  19714. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19715. /**
  19716. * Gets the file containing delay loading data for this mesh
  19717. */
  19718. delayLoadingFile: string;
  19719. /** @hidden */
  19720. _binaryInfo: any;
  19721. private _LODLevels;
  19722. /**
  19723. * User defined function used to change how LOD level selection is done
  19724. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19725. */
  19726. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19727. private _morphTargetManager;
  19728. /**
  19729. * Gets or sets the morph target manager
  19730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19731. */
  19732. morphTargetManager: Nullable<MorphTargetManager>;
  19733. /** @hidden */
  19734. _creationDataStorage: Nullable<_CreationDataStorage>;
  19735. /** @hidden */
  19736. _geometry: Nullable<Geometry>;
  19737. /** @hidden */
  19738. _delayInfo: Array<string>;
  19739. /** @hidden */
  19740. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19741. /** @hidden */
  19742. _instanceDataStorage: _InstanceDataStorage;
  19743. private _effectiveMaterial;
  19744. /** @hidden */
  19745. _shouldGenerateFlatShading: boolean;
  19746. private _preActivateId;
  19747. /** @hidden */
  19748. _originalBuilderSideOrientation: number;
  19749. /**
  19750. * Use this property to change the original side orientation defined at construction time
  19751. */
  19752. overrideMaterialSideOrientation: Nullable<number>;
  19753. private _areNormalsFrozen;
  19754. private _sourcePositions;
  19755. private _sourceNormals;
  19756. private _source;
  19757. private meshMap;
  19758. /**
  19759. * Gets the source mesh (the one used to clone this one from)
  19760. */
  19761. readonly source: Nullable<Mesh>;
  19762. /**
  19763. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19764. */
  19765. isUnIndexed: boolean;
  19766. /**
  19767. * @constructor
  19768. * @param name The value used by scene.getMeshByName() to do a lookup.
  19769. * @param scene The scene to add this mesh to.
  19770. * @param parent The parent of this mesh, if it has one
  19771. * @param source An optional Mesh from which geometry is shared, cloned.
  19772. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19773. * When false, achieved by calling a clone(), also passing False.
  19774. * This will make creation of children, recursive.
  19775. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19776. */
  19777. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19778. /**
  19779. * Gets the class name
  19780. * @returns the string "Mesh".
  19781. */
  19782. getClassName(): string;
  19783. /** @hidden */
  19784. readonly _isMesh: boolean;
  19785. /**
  19786. * Returns a description of this mesh
  19787. * @param fullDetails define if full details about this mesh must be used
  19788. * @returns a descriptive string representing this mesh
  19789. */
  19790. toString(fullDetails?: boolean): string;
  19791. /** @hidden */
  19792. _unBindEffect(): void;
  19793. /**
  19794. * Gets a boolean indicating if this mesh has LOD
  19795. */
  19796. readonly hasLODLevels: boolean;
  19797. /**
  19798. * Gets the list of MeshLODLevel associated with the current mesh
  19799. * @returns an array of MeshLODLevel
  19800. */
  19801. getLODLevels(): MeshLODLevel[];
  19802. private _sortLODLevels;
  19803. /**
  19804. * Add a mesh as LOD level triggered at the given distance.
  19805. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19806. * @param distance The distance from the center of the object to show this level
  19807. * @param mesh The mesh to be added as LOD level (can be null)
  19808. * @return This mesh (for chaining)
  19809. */
  19810. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19811. /**
  19812. * Returns the LOD level mesh at the passed distance or null if not found.
  19813. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19814. * @param distance The distance from the center of the object to show this level
  19815. * @returns a Mesh or `null`
  19816. */
  19817. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19818. /**
  19819. * Remove a mesh from the LOD array
  19820. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19821. * @param mesh defines the mesh to be removed
  19822. * @return This mesh (for chaining)
  19823. */
  19824. removeLODLevel(mesh: Mesh): Mesh;
  19825. /**
  19826. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19827. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19828. * @param camera defines the camera to use to compute distance
  19829. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19830. * @return This mesh (for chaining)
  19831. */
  19832. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19833. /**
  19834. * Gets the mesh internal Geometry object
  19835. */
  19836. readonly geometry: Nullable<Geometry>;
  19837. /**
  19838. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19839. * @returns the total number of vertices
  19840. */
  19841. getTotalVertices(): number;
  19842. /**
  19843. * Returns the content of an associated vertex buffer
  19844. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19845. * - VertexBuffer.PositionKind
  19846. * - VertexBuffer.UVKind
  19847. * - VertexBuffer.UV2Kind
  19848. * - VertexBuffer.UV3Kind
  19849. * - VertexBuffer.UV4Kind
  19850. * - VertexBuffer.UV5Kind
  19851. * - VertexBuffer.UV6Kind
  19852. * - VertexBuffer.ColorKind
  19853. * - VertexBuffer.MatricesIndicesKind
  19854. * - VertexBuffer.MatricesIndicesExtraKind
  19855. * - VertexBuffer.MatricesWeightsKind
  19856. * - VertexBuffer.MatricesWeightsExtraKind
  19857. * @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
  19858. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19859. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19860. */
  19861. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19862. /**
  19863. * Returns the mesh VertexBuffer object from the requested `kind`
  19864. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19865. * - VertexBuffer.PositionKind
  19866. * - VertexBuffer.UVKind
  19867. * - VertexBuffer.UV2Kind
  19868. * - VertexBuffer.UV3Kind
  19869. * - VertexBuffer.UV4Kind
  19870. * - VertexBuffer.UV5Kind
  19871. * - VertexBuffer.UV6Kind
  19872. * - VertexBuffer.ColorKind
  19873. * - VertexBuffer.MatricesIndicesKind
  19874. * - VertexBuffer.MatricesIndicesExtraKind
  19875. * - VertexBuffer.MatricesWeightsKind
  19876. * - VertexBuffer.MatricesWeightsExtraKind
  19877. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19878. */
  19879. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19880. /**
  19881. * Tests if a specific vertex buffer is associated with this mesh
  19882. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19883. * - VertexBuffer.PositionKind
  19884. * - VertexBuffer.UVKind
  19885. * - VertexBuffer.UV2Kind
  19886. * - VertexBuffer.UV3Kind
  19887. * - VertexBuffer.UV4Kind
  19888. * - VertexBuffer.UV5Kind
  19889. * - VertexBuffer.UV6Kind
  19890. * - VertexBuffer.ColorKind
  19891. * - VertexBuffer.MatricesIndicesKind
  19892. * - VertexBuffer.MatricesIndicesExtraKind
  19893. * - VertexBuffer.MatricesWeightsKind
  19894. * - VertexBuffer.MatricesWeightsExtraKind
  19895. * @returns a boolean
  19896. */
  19897. isVerticesDataPresent(kind: string): boolean;
  19898. /**
  19899. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19900. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19901. * - VertexBuffer.PositionKind
  19902. * - VertexBuffer.UVKind
  19903. * - VertexBuffer.UV2Kind
  19904. * - VertexBuffer.UV3Kind
  19905. * - VertexBuffer.UV4Kind
  19906. * - VertexBuffer.UV5Kind
  19907. * - VertexBuffer.UV6Kind
  19908. * - VertexBuffer.ColorKind
  19909. * - VertexBuffer.MatricesIndicesKind
  19910. * - VertexBuffer.MatricesIndicesExtraKind
  19911. * - VertexBuffer.MatricesWeightsKind
  19912. * - VertexBuffer.MatricesWeightsExtraKind
  19913. * @returns a boolean
  19914. */
  19915. isVertexBufferUpdatable(kind: string): boolean;
  19916. /**
  19917. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19918. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19919. * - VertexBuffer.PositionKind
  19920. * - VertexBuffer.UVKind
  19921. * - VertexBuffer.UV2Kind
  19922. * - VertexBuffer.UV3Kind
  19923. * - VertexBuffer.UV4Kind
  19924. * - VertexBuffer.UV5Kind
  19925. * - VertexBuffer.UV6Kind
  19926. * - VertexBuffer.ColorKind
  19927. * - VertexBuffer.MatricesIndicesKind
  19928. * - VertexBuffer.MatricesIndicesExtraKind
  19929. * - VertexBuffer.MatricesWeightsKind
  19930. * - VertexBuffer.MatricesWeightsExtraKind
  19931. * @returns an array of strings
  19932. */
  19933. getVerticesDataKinds(): string[];
  19934. /**
  19935. * Returns a positive integer : the total number of indices in this mesh geometry.
  19936. * @returns the numner of indices or zero if the mesh has no geometry.
  19937. */
  19938. getTotalIndices(): number;
  19939. /**
  19940. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19941. * @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.
  19942. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19943. * @returns the indices array or an empty array if the mesh has no geometry
  19944. */
  19945. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19946. readonly isBlocked: boolean;
  19947. /**
  19948. * Determine if the current mesh is ready to be rendered
  19949. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19950. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19951. * @returns true if all associated assets are ready (material, textures, shaders)
  19952. */
  19953. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19954. /**
  19955. * 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.
  19956. */
  19957. readonly areNormalsFrozen: boolean;
  19958. /**
  19959. * 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.
  19960. * @returns the current mesh
  19961. */
  19962. freezeNormals(): Mesh;
  19963. /**
  19964. * 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
  19965. * @returns the current mesh
  19966. */
  19967. unfreezeNormals(): Mesh;
  19968. /**
  19969. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19970. */
  19971. overridenInstanceCount: number;
  19972. /** @hidden */
  19973. _preActivate(): Mesh;
  19974. /** @hidden */
  19975. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19976. /** @hidden */
  19977. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19978. /**
  19979. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19980. * This means the mesh underlying bounding box and sphere are recomputed.
  19981. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19982. * @returns the current mesh
  19983. */
  19984. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19985. /** @hidden */
  19986. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19987. /**
  19988. * This function will subdivide the mesh into multiple submeshes
  19989. * @param count defines the expected number of submeshes
  19990. */
  19991. subdivide(count: number): void;
  19992. /**
  19993. * Copy a FloatArray into a specific associated vertex buffer
  19994. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19995. * - VertexBuffer.PositionKind
  19996. * - VertexBuffer.UVKind
  19997. * - VertexBuffer.UV2Kind
  19998. * - VertexBuffer.UV3Kind
  19999. * - VertexBuffer.UV4Kind
  20000. * - VertexBuffer.UV5Kind
  20001. * - VertexBuffer.UV6Kind
  20002. * - VertexBuffer.ColorKind
  20003. * - VertexBuffer.MatricesIndicesKind
  20004. * - VertexBuffer.MatricesIndicesExtraKind
  20005. * - VertexBuffer.MatricesWeightsKind
  20006. * - VertexBuffer.MatricesWeightsExtraKind
  20007. * @param data defines the data source
  20008. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20009. * @param stride defines the data stride size (can be null)
  20010. * @returns the current mesh
  20011. */
  20012. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20013. /**
  20014. * Flags an associated vertex buffer as updatable
  20015. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20016. * - VertexBuffer.PositionKind
  20017. * - VertexBuffer.UVKind
  20018. * - VertexBuffer.UV2Kind
  20019. * - VertexBuffer.UV3Kind
  20020. * - VertexBuffer.UV4Kind
  20021. * - VertexBuffer.UV5Kind
  20022. * - VertexBuffer.UV6Kind
  20023. * - VertexBuffer.ColorKind
  20024. * - VertexBuffer.MatricesIndicesKind
  20025. * - VertexBuffer.MatricesIndicesExtraKind
  20026. * - VertexBuffer.MatricesWeightsKind
  20027. * - VertexBuffer.MatricesWeightsExtraKind
  20028. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20029. */
  20030. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20031. /**
  20032. * Sets the mesh global Vertex Buffer
  20033. * @param buffer defines the buffer to use
  20034. * @returns the current mesh
  20035. */
  20036. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20037. /**
  20038. * Update a specific associated vertex buffer
  20039. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20040. * - VertexBuffer.PositionKind
  20041. * - VertexBuffer.UVKind
  20042. * - VertexBuffer.UV2Kind
  20043. * - VertexBuffer.UV3Kind
  20044. * - VertexBuffer.UV4Kind
  20045. * - VertexBuffer.UV5Kind
  20046. * - VertexBuffer.UV6Kind
  20047. * - VertexBuffer.ColorKind
  20048. * - VertexBuffer.MatricesIndicesKind
  20049. * - VertexBuffer.MatricesIndicesExtraKind
  20050. * - VertexBuffer.MatricesWeightsKind
  20051. * - VertexBuffer.MatricesWeightsExtraKind
  20052. * @param data defines the data source
  20053. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20054. * @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)
  20055. * @returns the current mesh
  20056. */
  20057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20058. /**
  20059. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20060. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20061. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20062. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20063. * @returns the current mesh
  20064. */
  20065. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20066. /**
  20067. * Creates a un-shared specific occurence of the geometry for the mesh.
  20068. * @returns the current mesh
  20069. */
  20070. makeGeometryUnique(): Mesh;
  20071. /**
  20072. * Set the index buffer of this mesh
  20073. * @param indices defines the source data
  20074. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20075. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20076. * @returns the current mesh
  20077. */
  20078. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20079. /**
  20080. * Update the current index buffer
  20081. * @param indices defines the source data
  20082. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20083. * @returns the current mesh
  20084. */
  20085. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20086. /**
  20087. * Invert the geometry to move from a right handed system to a left handed one.
  20088. * @returns the current mesh
  20089. */
  20090. toLeftHanded(): Mesh;
  20091. /** @hidden */
  20092. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20093. /** @hidden */
  20094. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20095. /**
  20096. * Registers for this mesh a javascript function called just before the rendering process
  20097. * @param func defines the function to call before rendering this mesh
  20098. * @returns the current mesh
  20099. */
  20100. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20101. /**
  20102. * Disposes a previously registered javascript function called before the rendering
  20103. * @param func defines the function to remove
  20104. * @returns the current mesh
  20105. */
  20106. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20107. /**
  20108. * Registers for this mesh a javascript function called just after the rendering is complete
  20109. * @param func defines the function to call after rendering this mesh
  20110. * @returns the current mesh
  20111. */
  20112. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20113. /**
  20114. * Disposes a previously registered javascript function called after the rendering.
  20115. * @param func defines the function to remove
  20116. * @returns the current mesh
  20117. */
  20118. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20119. /** @hidden */
  20120. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20121. /** @hidden */
  20122. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20123. /** @hidden */
  20124. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20125. /**
  20126. * 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
  20127. * @param subMesh defines the subMesh to render
  20128. * @param enableAlphaMode defines if alpha mode can be changed
  20129. * @returns the current mesh
  20130. */
  20131. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20132. private _onBeforeDraw;
  20133. /**
  20134. * Renormalize the mesh and patch it up if there are no weights
  20135. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20136. * However in the case of zero weights then we set just a single influence to 1.
  20137. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20138. */
  20139. cleanMatrixWeights(): void;
  20140. private normalizeSkinFourWeights;
  20141. private normalizeSkinWeightsAndExtra;
  20142. /**
  20143. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20144. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20145. * the user know there was an issue with importing the mesh
  20146. * @returns a validation object with skinned, valid and report string
  20147. */
  20148. validateSkinning(): {
  20149. skinned: boolean;
  20150. valid: boolean;
  20151. report: string;
  20152. };
  20153. /** @hidden */
  20154. _checkDelayState(): Mesh;
  20155. private _queueLoad;
  20156. /**
  20157. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20158. * A mesh is in the frustum if its bounding box intersects the frustum
  20159. * @param frustumPlanes defines the frustum to test
  20160. * @returns true if the mesh is in the frustum planes
  20161. */
  20162. isInFrustum(frustumPlanes: Plane[]): boolean;
  20163. /**
  20164. * Sets the mesh material by the material or multiMaterial `id` property
  20165. * @param id is a string identifying the material or the multiMaterial
  20166. * @returns the current mesh
  20167. */
  20168. setMaterialByID(id: string): Mesh;
  20169. /**
  20170. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20171. * @returns an array of IAnimatable
  20172. */
  20173. getAnimatables(): IAnimatable[];
  20174. /**
  20175. * Modifies the mesh geometry according to the passed transformation matrix.
  20176. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20177. * The mesh normals are modified using the same transformation.
  20178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20179. * @param transform defines the transform matrix to use
  20180. * @see http://doc.babylonjs.com/resources/baking_transformations
  20181. * @returns the current mesh
  20182. */
  20183. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20184. /**
  20185. * Modifies the mesh geometry according to its own current World Matrix.
  20186. * The mesh World Matrix is then reset.
  20187. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20188. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20189. * @see http://doc.babylonjs.com/resources/baking_transformations
  20190. * @returns the current mesh
  20191. */
  20192. bakeCurrentTransformIntoVertices(): Mesh;
  20193. /** @hidden */
  20194. readonly _positions: Nullable<Vector3[]>;
  20195. /** @hidden */
  20196. _resetPointsArrayCache(): Mesh;
  20197. /** @hidden */
  20198. _generatePointsArray(): boolean;
  20199. /**
  20200. * Returns a new Mesh object generated from the current mesh properties.
  20201. * This method must not get confused with createInstance()
  20202. * @param name is a string, the name given to the new mesh
  20203. * @param newParent can be any Node object (default `null`)
  20204. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20205. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20206. * @returns a new mesh
  20207. */
  20208. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20209. /**
  20210. * Releases resources associated with this mesh.
  20211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20213. */
  20214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20215. /**
  20216. * Modifies the mesh geometry according to a displacement map.
  20217. * 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.
  20218. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20219. * @param url is a string, the URL from the image file is to be downloaded.
  20220. * @param minHeight is the lower limit of the displacement.
  20221. * @param maxHeight is the upper limit of the displacement.
  20222. * @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.
  20223. * @param uvOffset is an optional vector2 used to offset UV.
  20224. * @param uvScale is an optional vector2 used to scale UV.
  20225. * @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.
  20226. * @returns the Mesh.
  20227. */
  20228. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20229. /**
  20230. * Modifies the mesh geometry according to a displacementMap buffer.
  20231. * 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.
  20232. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20233. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20234. * @param heightMapWidth is the width of the buffer image.
  20235. * @param heightMapHeight is the height of the buffer image.
  20236. * @param minHeight is the lower limit of the displacement.
  20237. * @param maxHeight is the upper limit of the displacement.
  20238. * @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.
  20239. * @param uvOffset is an optional vector2 used to offset UV.
  20240. * @param uvScale is an optional vector2 used to scale UV.
  20241. * @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.
  20242. * @returns the Mesh.
  20243. */
  20244. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20245. /**
  20246. * Modify the mesh to get a flat shading rendering.
  20247. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20248. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20249. * @returns current mesh
  20250. */
  20251. convertToFlatShadedMesh(): Mesh;
  20252. /**
  20253. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20254. * In other words, more vertices, no more indices and a single bigger VBO.
  20255. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20256. * @returns current mesh
  20257. */
  20258. convertToUnIndexedMesh(): Mesh;
  20259. /**
  20260. * Inverses facet orientations.
  20261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20262. * @param flipNormals will also inverts the normals
  20263. * @returns current mesh
  20264. */
  20265. flipFaces(flipNormals?: boolean): Mesh;
  20266. /** @hidden */
  20267. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20268. /** @hidden */
  20269. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20270. /**
  20271. * Creates a new InstancedMesh object from the mesh model.
  20272. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20273. * @param name defines the name of the new instance
  20274. * @returns a new InstancedMesh
  20275. */
  20276. createInstance(name: string): InstancedMesh;
  20277. /**
  20278. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20279. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20280. * @returns the current mesh
  20281. */
  20282. synchronizeInstances(): Mesh;
  20283. /**
  20284. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20285. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20286. * This should be used together with the simplification to avoid disappearing triangles.
  20287. * @param successCallback an optional success callback to be called after the optimization finished.
  20288. * @returns the current mesh
  20289. */
  20290. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20291. /**
  20292. * Serialize current mesh
  20293. * @param serializationObject defines the object which will receive the serialization data
  20294. */
  20295. serialize(serializationObject: any): void;
  20296. /** @hidden */
  20297. _syncGeometryWithMorphTargetManager(): void;
  20298. /** @hidden */
  20299. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20300. /**
  20301. * Returns a new Mesh object parsed from the source provided.
  20302. * @param parsedMesh is the source
  20303. * @param scene defines the hosting scene
  20304. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20305. * @returns a new Mesh
  20306. */
  20307. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20308. /**
  20309. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20310. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20311. * @param name defines the name of the mesh to create
  20312. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20313. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20314. * @param closePath creates a seam between the first and the last points of each path of the path array
  20315. * @param offset is taken in account only if the `pathArray` is containing a single path
  20316. * @param scene defines the hosting scene
  20317. * @param updatable defines if the mesh must be flagged as updatable
  20318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20319. * @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)
  20320. * @returns a new Mesh
  20321. */
  20322. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20323. /**
  20324. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20325. * @param name defines the name of the mesh to create
  20326. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20327. * @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
  20328. * @param scene defines the hosting scene
  20329. * @param updatable defines if the mesh must be flagged as updatable
  20330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20331. * @returns a new Mesh
  20332. */
  20333. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20334. /**
  20335. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20336. * @param name defines the name of the mesh to create
  20337. * @param size sets the size (float) of each box side (default 1)
  20338. * @param scene defines the hosting scene
  20339. * @param updatable defines if the mesh must be flagged as updatable
  20340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20341. * @returns a new Mesh
  20342. */
  20343. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20344. /**
  20345. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20346. * @param name defines the name of the mesh to create
  20347. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20348. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20349. * @param scene defines the hosting scene
  20350. * @param updatable defines if the mesh must be flagged as updatable
  20351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20352. * @returns a new Mesh
  20353. */
  20354. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20355. /**
  20356. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20357. * @param name defines the name of the mesh to create
  20358. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20359. * @param diameterTop set the top cap diameter (floats, default 1)
  20360. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20361. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20362. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20363. * @param scene defines the hosting scene
  20364. * @param updatable defines if the mesh must be flagged as updatable
  20365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20366. * @returns a new Mesh
  20367. */
  20368. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20369. /**
  20370. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20371. * @param name defines the name of the mesh to create
  20372. * @param diameter sets the diameter size (float) of the torus (default 1)
  20373. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20374. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20375. * @param scene defines the hosting scene
  20376. * @param updatable defines if the mesh must be flagged as updatable
  20377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20378. * @returns a new Mesh
  20379. */
  20380. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20381. /**
  20382. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20383. * @param name defines the name of the mesh to create
  20384. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20385. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20386. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20387. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20388. * @param p the number of windings on X axis (positive integers, default 2)
  20389. * @param q the number of windings on Y axis (positive integers, default 3)
  20390. * @param scene defines the hosting scene
  20391. * @param updatable defines if the mesh must be flagged as updatable
  20392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20393. * @returns a new Mesh
  20394. */
  20395. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20396. /**
  20397. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20398. * @param name defines the name of the mesh to create
  20399. * @param points is an array successive Vector3
  20400. * @param scene defines the hosting scene
  20401. * @param updatable defines if the mesh must be flagged as updatable
  20402. * @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).
  20403. * @returns a new Mesh
  20404. */
  20405. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20406. /**
  20407. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20408. * @param name defines the name of the mesh to create
  20409. * @param points is an array successive Vector3
  20410. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20411. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20412. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20413. * @param scene defines the hosting scene
  20414. * @param updatable defines if the mesh must be flagged as updatable
  20415. * @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)
  20416. * @returns a new Mesh
  20417. */
  20418. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20419. /**
  20420. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20421. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20422. * 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.
  20423. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20425. * Remember you can only change the shape positions, not their number when updating a polygon.
  20426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20427. * @param name defines the name of the mesh to create
  20428. * @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
  20429. * @param scene defines the hosting scene
  20430. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20431. * @param updatable defines if the mesh must be flagged as updatable
  20432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20433. * @param earcutInjection can be used to inject your own earcut reference
  20434. * @returns a new Mesh
  20435. */
  20436. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20437. /**
  20438. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20440. * @param name defines the name of the mesh to create
  20441. * @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
  20442. * @param depth defines the height of extrusion
  20443. * @param scene defines the hosting scene
  20444. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20445. * @param updatable defines if the mesh must be flagged as updatable
  20446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20447. * @param earcutInjection can be used to inject your own earcut reference
  20448. * @returns a new Mesh
  20449. */
  20450. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20451. /**
  20452. * Creates an extruded shape mesh.
  20453. * 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
  20454. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20456. * @param name defines the name of the mesh to create
  20457. * @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
  20458. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20459. * @param scale is the value to scale the shape
  20460. * @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
  20461. * @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
  20462. * @param scene defines the hosting scene
  20463. * @param updatable defines if the mesh must be flagged as updatable
  20464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20465. * @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)
  20466. * @returns a new Mesh
  20467. */
  20468. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20469. /**
  20470. * Creates an custom extruded shape mesh.
  20471. * The custom extrusion is a parametric shape.
  20472. * It has no predefined shape. Its final shape will depend on the input parameters.
  20473. * Please consider using the same method from the MeshBuilder class instead
  20474. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20475. * @param name defines the name of the mesh to create
  20476. * @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
  20477. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20478. * @param scaleFunction is a custom Javascript function called on each path point
  20479. * @param rotationFunction is a custom Javascript function called on each path point
  20480. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20481. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20482. * @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
  20483. * @param scene defines the hosting scene
  20484. * @param updatable defines if the mesh must be flagged as updatable
  20485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20486. * @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)
  20487. * @returns a new Mesh
  20488. */
  20489. 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;
  20490. /**
  20491. * Creates lathe mesh.
  20492. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20493. * Please consider using the same method from the MeshBuilder class instead
  20494. * @param name defines the name of the mesh to create
  20495. * @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
  20496. * @param radius is the radius value of the lathe
  20497. * @param tessellation is the side number of the lathe.
  20498. * @param scene defines the hosting scene
  20499. * @param updatable defines if the mesh must be flagged as updatable
  20500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20501. * @returns a new Mesh
  20502. */
  20503. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20504. /**
  20505. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20506. * @param name defines the name of the mesh to create
  20507. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20508. * @param scene defines the hosting scene
  20509. * @param updatable defines if the mesh must be flagged as updatable
  20510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20511. * @returns a new Mesh
  20512. */
  20513. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20514. /**
  20515. * Creates a ground mesh.
  20516. * Please consider using the same method from the MeshBuilder class instead
  20517. * @param name defines the name of the mesh to create
  20518. * @param width set the width of the ground
  20519. * @param height set the height of the ground
  20520. * @param subdivisions sets the number of subdivisions per side
  20521. * @param scene defines the hosting scene
  20522. * @param updatable defines if the mesh must be flagged as updatable
  20523. * @returns a new Mesh
  20524. */
  20525. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20526. /**
  20527. * Creates a tiled ground mesh.
  20528. * Please consider using the same method from the MeshBuilder class instead
  20529. * @param name defines the name of the mesh to create
  20530. * @param xmin set the ground minimum X coordinate
  20531. * @param zmin set the ground minimum Y coordinate
  20532. * @param xmax set the ground maximum X coordinate
  20533. * @param zmax set the ground maximum Z coordinate
  20534. * @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
  20535. * @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
  20536. * @param scene defines the hosting scene
  20537. * @param updatable defines if the mesh must be flagged as updatable
  20538. * @returns a new Mesh
  20539. */
  20540. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20541. w: number;
  20542. h: number;
  20543. }, precision: {
  20544. w: number;
  20545. h: number;
  20546. }, scene: Scene, updatable?: boolean): Mesh;
  20547. /**
  20548. * Creates a ground mesh from a height map.
  20549. * Please consider using the same method from the MeshBuilder class instead
  20550. * @see http://doc.babylonjs.com/babylon101/height_map
  20551. * @param name defines the name of the mesh to create
  20552. * @param url sets the URL of the height map image resource
  20553. * @param width set the ground width size
  20554. * @param height set the ground height size
  20555. * @param subdivisions sets the number of subdivision per side
  20556. * @param minHeight is the minimum altitude on the ground
  20557. * @param maxHeight is the maximum altitude on the ground
  20558. * @param scene defines the hosting scene
  20559. * @param updatable defines if the mesh must be flagged as updatable
  20560. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20561. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20562. * @returns a new Mesh
  20563. */
  20564. 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;
  20565. /**
  20566. * Creates a tube mesh.
  20567. * The tube is a parametric shape.
  20568. * It has no predefined shape. Its final shape will depend on the input parameters.
  20569. * Please consider using the same method from the MeshBuilder class instead
  20570. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20571. * @param name defines the name of the mesh to create
  20572. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20573. * @param radius sets the tube radius size
  20574. * @param tessellation is the number of sides on the tubular surface
  20575. * @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
  20576. * @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
  20577. * @param scene defines the hosting scene
  20578. * @param updatable defines if the mesh must be flagged as updatable
  20579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20580. * @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)
  20581. * @returns a new Mesh
  20582. */
  20583. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20584. (i: number, distance: number): number;
  20585. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20586. /**
  20587. * Creates a polyhedron mesh.
  20588. * Please consider using the same method from the MeshBuilder class instead.
  20589. * * 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
  20590. * * The parameter `size` (positive float, default 1) sets the polygon size
  20591. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20592. * * 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`
  20593. * * 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
  20594. * * 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)`)
  20595. * * 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
  20596. * * 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
  20597. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20598. * * If you create a double-sided mesh, you can choose what parts of 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
  20599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20600. * @param name defines the name of the mesh to create
  20601. * @param options defines the options used to create the mesh
  20602. * @param scene defines the hosting scene
  20603. * @returns a new Mesh
  20604. */
  20605. static CreatePolyhedron(name: string, options: {
  20606. type?: number;
  20607. size?: number;
  20608. sizeX?: number;
  20609. sizeY?: number;
  20610. sizeZ?: number;
  20611. custom?: any;
  20612. faceUV?: Vector4[];
  20613. faceColors?: Color4[];
  20614. updatable?: boolean;
  20615. sideOrientation?: number;
  20616. }, scene: Scene): Mesh;
  20617. /**
  20618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20620. * * 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`)
  20621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20622. * * 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
  20623. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20624. * * If you create a double-sided mesh, you can choose what parts of 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
  20625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20626. * @param name defines the name of the mesh
  20627. * @param options defines the options used to create the mesh
  20628. * @param scene defines the hosting scene
  20629. * @returns a new Mesh
  20630. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20631. */
  20632. static CreateIcoSphere(name: string, options: {
  20633. radius?: number;
  20634. flat?: boolean;
  20635. subdivisions?: number;
  20636. sideOrientation?: number;
  20637. updatable?: boolean;
  20638. }, scene: Scene): Mesh;
  20639. /**
  20640. * Creates a decal mesh.
  20641. * Please consider using the same method from the MeshBuilder class instead.
  20642. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20643. * @param name defines the name of the mesh
  20644. * @param sourceMesh defines the mesh receiving the decal
  20645. * @param position sets the position of the decal in world coordinates
  20646. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20647. * @param size sets the decal scaling
  20648. * @param angle sets the angle to rotate the decal
  20649. * @returns a new Mesh
  20650. */
  20651. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20652. /**
  20653. * Prepare internal position array for software CPU skinning
  20654. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20655. */
  20656. setPositionsForCPUSkinning(): Float32Array;
  20657. /**
  20658. * Prepare internal normal array for software CPU skinning
  20659. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20660. */
  20661. setNormalsForCPUSkinning(): Float32Array;
  20662. /**
  20663. * Updates the vertex buffer by applying transformation from the bones
  20664. * @param skeleton defines the skeleton to apply to current mesh
  20665. * @returns the current mesh
  20666. */
  20667. applySkeleton(skeleton: Skeleton): Mesh;
  20668. /**
  20669. * 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
  20670. * @param meshes defines the list of meshes to scan
  20671. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20672. */
  20673. static MinMax(meshes: AbstractMesh[]): {
  20674. min: Vector3;
  20675. max: Vector3;
  20676. };
  20677. /**
  20678. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20679. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20680. * @returns a vector3
  20681. */
  20682. static Center(meshesOrMinMaxVector: {
  20683. min: Vector3;
  20684. max: Vector3;
  20685. } | AbstractMesh[]): Vector3;
  20686. /**
  20687. * Merge the array of meshes into a single mesh for performance reasons.
  20688. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20689. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20690. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20691. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20692. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20693. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20694. * @returns a new mesh
  20695. */
  20696. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20697. /** @hidden */
  20698. addInstance(instance: InstancedMesh): void;
  20699. /** @hidden */
  20700. removeInstance(instance: InstancedMesh): void;
  20701. }
  20702. }
  20703. declare module "babylonjs/Materials/material" {
  20704. import { IAnimatable } from "babylonjs/Misc/tools";
  20705. import { SmartArray } from "babylonjs/Misc/smartArray";
  20706. import { Observable } from "babylonjs/Misc/observable";
  20707. import { Nullable } from "babylonjs/types";
  20708. import { Scene } from "babylonjs/scene";
  20709. import { Matrix } from "babylonjs/Maths/math";
  20710. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20712. import { Mesh } from "babylonjs/Meshes/mesh";
  20713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20714. import { Effect } from "babylonjs/Materials/effect";
  20715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20717. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20718. import { Animation } from "babylonjs/Animations/animation";
  20719. /**
  20720. * Base class for the main features of a material in Babylon.js
  20721. */
  20722. export class Material implements IAnimatable {
  20723. /**
  20724. * Returns the triangle fill mode
  20725. */
  20726. static readonly TriangleFillMode: number;
  20727. /**
  20728. * Returns the wireframe mode
  20729. */
  20730. static readonly WireFrameFillMode: number;
  20731. /**
  20732. * Returns the point fill mode
  20733. */
  20734. static readonly PointFillMode: number;
  20735. /**
  20736. * Returns the point list draw mode
  20737. */
  20738. static readonly PointListDrawMode: number;
  20739. /**
  20740. * Returns the line list draw mode
  20741. */
  20742. static readonly LineListDrawMode: number;
  20743. /**
  20744. * Returns the line loop draw mode
  20745. */
  20746. static readonly LineLoopDrawMode: number;
  20747. /**
  20748. * Returns the line strip draw mode
  20749. */
  20750. static readonly LineStripDrawMode: number;
  20751. /**
  20752. * Returns the triangle strip draw mode
  20753. */
  20754. static readonly TriangleStripDrawMode: number;
  20755. /**
  20756. * Returns the triangle fan draw mode
  20757. */
  20758. static readonly TriangleFanDrawMode: number;
  20759. /**
  20760. * Stores the clock-wise side orientation
  20761. */
  20762. static readonly ClockWiseSideOrientation: number;
  20763. /**
  20764. * Stores the counter clock-wise side orientation
  20765. */
  20766. static readonly CounterClockWiseSideOrientation: number;
  20767. /**
  20768. * The dirty texture flag value
  20769. */
  20770. static readonly TextureDirtyFlag: number;
  20771. /**
  20772. * The dirty light flag value
  20773. */
  20774. static readonly LightDirtyFlag: number;
  20775. /**
  20776. * The dirty fresnel flag value
  20777. */
  20778. static readonly FresnelDirtyFlag: number;
  20779. /**
  20780. * The dirty attribute flag value
  20781. */
  20782. static readonly AttributesDirtyFlag: number;
  20783. /**
  20784. * The dirty misc flag value
  20785. */
  20786. static readonly MiscDirtyFlag: number;
  20787. /**
  20788. * The all dirty flag value
  20789. */
  20790. static readonly AllDirtyFlag: number;
  20791. /**
  20792. * The ID of the material
  20793. */
  20794. id: string;
  20795. /**
  20796. * Gets or sets the unique id of the material
  20797. */
  20798. uniqueId: number;
  20799. /**
  20800. * The name of the material
  20801. */
  20802. name: string;
  20803. /**
  20804. * Gets or sets user defined metadata
  20805. */
  20806. metadata: any;
  20807. /**
  20808. * For internal use only. Please do not use.
  20809. */
  20810. reservedDataStore: any;
  20811. /**
  20812. * Specifies if the ready state should be checked on each call
  20813. */
  20814. checkReadyOnEveryCall: boolean;
  20815. /**
  20816. * Specifies if the ready state should be checked once
  20817. */
  20818. checkReadyOnlyOnce: boolean;
  20819. /**
  20820. * The state of the material
  20821. */
  20822. state: string;
  20823. /**
  20824. * The alpha value of the material
  20825. */
  20826. protected _alpha: number;
  20827. /**
  20828. * Sets the alpha value of the material
  20829. */
  20830. /**
  20831. * Gets the alpha value of the material
  20832. */
  20833. alpha: number;
  20834. /**
  20835. * Specifies if back face culling is enabled
  20836. */
  20837. protected _backFaceCulling: boolean;
  20838. /**
  20839. * Sets the back-face culling state
  20840. */
  20841. /**
  20842. * Gets the back-face culling state
  20843. */
  20844. backFaceCulling: boolean;
  20845. /**
  20846. * Stores the value for side orientation
  20847. */
  20848. sideOrientation: number;
  20849. /**
  20850. * Callback triggered when the material is compiled
  20851. */
  20852. onCompiled: (effect: Effect) => void;
  20853. /**
  20854. * Callback triggered when an error occurs
  20855. */
  20856. onError: (effect: Effect, errors: string) => void;
  20857. /**
  20858. * Callback triggered to get the render target textures
  20859. */
  20860. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20861. /**
  20862. * Gets a boolean indicating that current material needs to register RTT
  20863. */
  20864. readonly hasRenderTargetTextures: boolean;
  20865. /**
  20866. * Specifies if the material should be serialized
  20867. */
  20868. doNotSerialize: boolean;
  20869. /**
  20870. * @hidden
  20871. */
  20872. _storeEffectOnSubMeshes: boolean;
  20873. /**
  20874. * Stores the animations for the material
  20875. */
  20876. animations: Array<Animation>;
  20877. /**
  20878. * An event triggered when the material is disposed
  20879. */
  20880. onDisposeObservable: Observable<Material>;
  20881. /**
  20882. * An observer which watches for dispose events
  20883. */
  20884. private _onDisposeObserver;
  20885. private _onUnBindObservable;
  20886. /**
  20887. * Called during a dispose event
  20888. */
  20889. onDispose: () => void;
  20890. private _onBindObservable;
  20891. /**
  20892. * An event triggered when the material is bound
  20893. */
  20894. readonly onBindObservable: Observable<AbstractMesh>;
  20895. /**
  20896. * An observer which watches for bind events
  20897. */
  20898. private _onBindObserver;
  20899. /**
  20900. * Called during a bind event
  20901. */
  20902. onBind: (Mesh: AbstractMesh) => void;
  20903. /**
  20904. * An event triggered when the material is unbound
  20905. */
  20906. readonly onUnBindObservable: Observable<Material>;
  20907. /**
  20908. * Stores the value of the alpha mode
  20909. */
  20910. private _alphaMode;
  20911. /**
  20912. * Sets the value of the alpha mode.
  20913. *
  20914. * | Value | Type | Description |
  20915. * | --- | --- | --- |
  20916. * | 0 | ALPHA_DISABLE | |
  20917. * | 1 | ALPHA_ADD | |
  20918. * | 2 | ALPHA_COMBINE | |
  20919. * | 3 | ALPHA_SUBTRACT | |
  20920. * | 4 | ALPHA_MULTIPLY | |
  20921. * | 5 | ALPHA_MAXIMIZED | |
  20922. * | 6 | ALPHA_ONEONE | |
  20923. * | 7 | ALPHA_PREMULTIPLIED | |
  20924. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20925. * | 9 | ALPHA_INTERPOLATE | |
  20926. * | 10 | ALPHA_SCREENMODE | |
  20927. *
  20928. */
  20929. /**
  20930. * Gets the value of the alpha mode
  20931. */
  20932. alphaMode: number;
  20933. /**
  20934. * Stores the state of the need depth pre-pass value
  20935. */
  20936. private _needDepthPrePass;
  20937. /**
  20938. * Sets the need depth pre-pass value
  20939. */
  20940. /**
  20941. * Gets the depth pre-pass value
  20942. */
  20943. needDepthPrePass: boolean;
  20944. /**
  20945. * Specifies if depth writing should be disabled
  20946. */
  20947. disableDepthWrite: boolean;
  20948. /**
  20949. * Specifies if depth writing should be forced
  20950. */
  20951. forceDepthWrite: boolean;
  20952. /**
  20953. * Specifies if there should be a separate pass for culling
  20954. */
  20955. separateCullingPass: boolean;
  20956. /**
  20957. * Stores the state specifing if fog should be enabled
  20958. */
  20959. private _fogEnabled;
  20960. /**
  20961. * Sets the state for enabling fog
  20962. */
  20963. /**
  20964. * Gets the value of the fog enabled state
  20965. */
  20966. fogEnabled: boolean;
  20967. /**
  20968. * Stores the size of points
  20969. */
  20970. pointSize: number;
  20971. /**
  20972. * Stores the z offset value
  20973. */
  20974. zOffset: number;
  20975. /**
  20976. * Gets a value specifying if wireframe mode is enabled
  20977. */
  20978. /**
  20979. * Sets the state of wireframe mode
  20980. */
  20981. wireframe: boolean;
  20982. /**
  20983. * Gets the value specifying if point clouds are enabled
  20984. */
  20985. /**
  20986. * Sets the state of point cloud mode
  20987. */
  20988. pointsCloud: boolean;
  20989. /**
  20990. * Gets the material fill mode
  20991. */
  20992. /**
  20993. * Sets the material fill mode
  20994. */
  20995. fillMode: number;
  20996. /**
  20997. * @hidden
  20998. * Stores the effects for the material
  20999. */
  21000. _effect: Nullable<Effect>;
  21001. /**
  21002. * @hidden
  21003. * Specifies if the material was previously ready
  21004. */
  21005. _wasPreviouslyReady: boolean;
  21006. /**
  21007. * Specifies if uniform buffers should be used
  21008. */
  21009. private _useUBO;
  21010. /**
  21011. * Stores a reference to the scene
  21012. */
  21013. private _scene;
  21014. /**
  21015. * Stores the fill mode state
  21016. */
  21017. private _fillMode;
  21018. /**
  21019. * Specifies if the depth write state should be cached
  21020. */
  21021. private _cachedDepthWriteState;
  21022. /**
  21023. * Stores the uniform buffer
  21024. */
  21025. protected _uniformBuffer: UniformBuffer;
  21026. /** @hidden */
  21027. _indexInSceneMaterialArray: number;
  21028. /** @hidden */
  21029. meshMap: Nullable<{
  21030. [id: string]: AbstractMesh | undefined;
  21031. }>;
  21032. /**
  21033. * Creates a material instance
  21034. * @param name defines the name of the material
  21035. * @param scene defines the scene to reference
  21036. * @param doNotAdd specifies if the material should be added to the scene
  21037. */
  21038. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21039. /**
  21040. * Returns a string representation of the current material
  21041. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21042. * @returns a string with material information
  21043. */
  21044. toString(fullDetails?: boolean): string;
  21045. /**
  21046. * Gets the class name of the material
  21047. * @returns a string with the class name of the material
  21048. */
  21049. getClassName(): string;
  21050. /**
  21051. * Specifies if updates for the material been locked
  21052. */
  21053. readonly isFrozen: boolean;
  21054. /**
  21055. * Locks updates for the material
  21056. */
  21057. freeze(): void;
  21058. /**
  21059. * Unlocks updates for the material
  21060. */
  21061. unfreeze(): void;
  21062. /**
  21063. * Specifies if the material is ready to be used
  21064. * @param mesh defines the mesh to check
  21065. * @param useInstances specifies if instances should be used
  21066. * @returns a boolean indicating if the material is ready to be used
  21067. */
  21068. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21069. /**
  21070. * Specifies that the submesh is ready to be used
  21071. * @param mesh defines the mesh to check
  21072. * @param subMesh defines which submesh to check
  21073. * @param useInstances specifies that instances should be used
  21074. * @returns a boolean indicating that the submesh is ready or not
  21075. */
  21076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21077. /**
  21078. * Returns the material effect
  21079. * @returns the effect associated with the material
  21080. */
  21081. getEffect(): Nullable<Effect>;
  21082. /**
  21083. * Returns the current scene
  21084. * @returns a Scene
  21085. */
  21086. getScene(): Scene;
  21087. /**
  21088. * Specifies if the material will require alpha blending
  21089. * @returns a boolean specifying if alpha blending is needed
  21090. */
  21091. needAlphaBlending(): boolean;
  21092. /**
  21093. * Specifies if the mesh will require alpha blending
  21094. * @param mesh defines the mesh to check
  21095. * @returns a boolean specifying if alpha blending is needed for the mesh
  21096. */
  21097. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21098. /**
  21099. * Specifies if this material should be rendered in alpha test mode
  21100. * @returns a boolean specifying if an alpha test is needed.
  21101. */
  21102. needAlphaTesting(): boolean;
  21103. /**
  21104. * Gets the texture used for the alpha test
  21105. * @returns the texture to use for alpha testing
  21106. */
  21107. getAlphaTestTexture(): Nullable<BaseTexture>;
  21108. /**
  21109. * Marks the material to indicate that it needs to be re-calculated
  21110. */
  21111. markDirty(): void;
  21112. /** @hidden */
  21113. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21114. /**
  21115. * Binds the material to the mesh
  21116. * @param world defines the world transformation matrix
  21117. * @param mesh defines the mesh to bind the material to
  21118. */
  21119. bind(world: Matrix, mesh?: Mesh): void;
  21120. /**
  21121. * Binds the submesh to the material
  21122. * @param world defines the world transformation matrix
  21123. * @param mesh defines the mesh containing the submesh
  21124. * @param subMesh defines the submesh to bind the material to
  21125. */
  21126. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21127. /**
  21128. * Binds the world matrix to the material
  21129. * @param world defines the world transformation matrix
  21130. */
  21131. bindOnlyWorldMatrix(world: Matrix): void;
  21132. /**
  21133. * Binds the scene's uniform buffer to the effect.
  21134. * @param effect defines the effect to bind to the scene uniform buffer
  21135. * @param sceneUbo defines the uniform buffer storing scene data
  21136. */
  21137. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21138. /**
  21139. * Binds the view matrix to the effect
  21140. * @param effect defines the effect to bind the view matrix to
  21141. */
  21142. bindView(effect: Effect): void;
  21143. /**
  21144. * Binds the view projection matrix to the effect
  21145. * @param effect defines the effect to bind the view projection matrix to
  21146. */
  21147. bindViewProjection(effect: Effect): void;
  21148. /**
  21149. * Specifies if material alpha testing should be turned on for the mesh
  21150. * @param mesh defines the mesh to check
  21151. */
  21152. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21153. /**
  21154. * Processes to execute after binding the material to a mesh
  21155. * @param mesh defines the rendered mesh
  21156. */
  21157. protected _afterBind(mesh?: Mesh): void;
  21158. /**
  21159. * Unbinds the material from the mesh
  21160. */
  21161. unbind(): void;
  21162. /**
  21163. * Gets the active textures from the material
  21164. * @returns an array of textures
  21165. */
  21166. getActiveTextures(): BaseTexture[];
  21167. /**
  21168. * Specifies if the material uses a texture
  21169. * @param texture defines the texture to check against the material
  21170. * @returns a boolean specifying if the material uses the texture
  21171. */
  21172. hasTexture(texture: BaseTexture): boolean;
  21173. /**
  21174. * Makes a duplicate of the material, and gives it a new name
  21175. * @param name defines the new name for the duplicated material
  21176. * @returns the cloned material
  21177. */
  21178. clone(name: string): Nullable<Material>;
  21179. /**
  21180. * Gets the meshes bound to the material
  21181. * @returns an array of meshes bound to the material
  21182. */
  21183. getBindedMeshes(): AbstractMesh[];
  21184. /**
  21185. * Force shader compilation
  21186. * @param mesh defines the mesh associated with this material
  21187. * @param onCompiled defines a function to execute once the material is compiled
  21188. * @param options defines the options to configure the compilation
  21189. */
  21190. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21191. clipPlane: boolean;
  21192. }>): void;
  21193. /**
  21194. * Force shader compilation
  21195. * @param mesh defines the mesh that will use this material
  21196. * @param options defines additional options for compiling the shaders
  21197. * @returns a promise that resolves when the compilation completes
  21198. */
  21199. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21200. clipPlane: boolean;
  21201. }>): Promise<void>;
  21202. private static readonly _ImageProcessingDirtyCallBack;
  21203. private static readonly _TextureDirtyCallBack;
  21204. private static readonly _FresnelDirtyCallBack;
  21205. private static readonly _MiscDirtyCallBack;
  21206. private static readonly _LightsDirtyCallBack;
  21207. private static readonly _AttributeDirtyCallBack;
  21208. private static _FresnelAndMiscDirtyCallBack;
  21209. private static _TextureAndMiscDirtyCallBack;
  21210. private static readonly _DirtyCallbackArray;
  21211. private static readonly _RunDirtyCallBacks;
  21212. /**
  21213. * Marks a define in the material to indicate that it needs to be re-computed
  21214. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21215. */
  21216. markAsDirty(flag: number): void;
  21217. /**
  21218. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21219. * @param func defines a function which checks material defines against the submeshes
  21220. */
  21221. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21222. /**
  21223. * Indicates that image processing needs to be re-calculated for all submeshes
  21224. */
  21225. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21226. /**
  21227. * Indicates that textures need to be re-calculated for all submeshes
  21228. */
  21229. protected _markAllSubMeshesAsTexturesDirty(): void;
  21230. /**
  21231. * Indicates that fresnel needs to be re-calculated for all submeshes
  21232. */
  21233. protected _markAllSubMeshesAsFresnelDirty(): void;
  21234. /**
  21235. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21236. */
  21237. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21238. /**
  21239. * Indicates that lights need to be re-calculated for all submeshes
  21240. */
  21241. protected _markAllSubMeshesAsLightsDirty(): void;
  21242. /**
  21243. * Indicates that attributes need to be re-calculated for all submeshes
  21244. */
  21245. protected _markAllSubMeshesAsAttributesDirty(): void;
  21246. /**
  21247. * Indicates that misc needs to be re-calculated for all submeshes
  21248. */
  21249. protected _markAllSubMeshesAsMiscDirty(): void;
  21250. /**
  21251. * Indicates that textures and misc need to be re-calculated for all submeshes
  21252. */
  21253. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21254. /**
  21255. * Disposes the material
  21256. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21257. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21258. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21259. */
  21260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21261. /** @hidden */
  21262. private releaseVertexArrayObject;
  21263. /**
  21264. * Serializes this material
  21265. * @returns the serialized material object
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * Creates a material from parsed material data
  21270. * @param parsedMaterial defines parsed material data
  21271. * @param scene defines the hosting scene
  21272. * @param rootUrl defines the root URL to use to load textures
  21273. * @returns a new material
  21274. */
  21275. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21276. }
  21277. }
  21278. declare module "babylonjs/Meshes/subMesh" {
  21279. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21280. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21281. import { Engine } from "babylonjs/Engines/engine";
  21282. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21283. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21284. import { Effect } from "babylonjs/Materials/effect";
  21285. import { Collider } from "babylonjs/Collisions/collider";
  21286. import { Material } from "babylonjs/Materials/material";
  21287. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21289. import { Mesh } from "babylonjs/Meshes/mesh";
  21290. import { Ray } from "babylonjs/Culling/ray";
  21291. /**
  21292. * Base class for submeshes
  21293. */
  21294. export class BaseSubMesh {
  21295. /** @hidden */
  21296. _materialDefines: Nullable<MaterialDefines>;
  21297. /** @hidden */
  21298. _materialEffect: Nullable<Effect>;
  21299. /**
  21300. * Gets associated effect
  21301. */
  21302. readonly effect: Nullable<Effect>;
  21303. /**
  21304. * Sets associated effect (effect used to render this submesh)
  21305. * @param effect defines the effect to associate with
  21306. * @param defines defines the set of defines used to compile this effect
  21307. */
  21308. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21309. }
  21310. /**
  21311. * Defines a subdivision inside a mesh
  21312. */
  21313. export class SubMesh extends BaseSubMesh implements ICullable {
  21314. /** the material index to use */
  21315. materialIndex: number;
  21316. /** vertex index start */
  21317. verticesStart: number;
  21318. /** vertices count */
  21319. verticesCount: number;
  21320. /** index start */
  21321. indexStart: number;
  21322. /** indices count */
  21323. indexCount: number;
  21324. /** @hidden */
  21325. _linesIndexCount: number;
  21326. private _mesh;
  21327. private _renderingMesh;
  21328. private _boundingInfo;
  21329. private _linesIndexBuffer;
  21330. /** @hidden */
  21331. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21332. /** @hidden */
  21333. _trianglePlanes: Plane[];
  21334. /** @hidden */
  21335. _lastColliderTransformMatrix: Matrix;
  21336. /** @hidden */
  21337. _renderId: number;
  21338. /** @hidden */
  21339. _alphaIndex: number;
  21340. /** @hidden */
  21341. _distanceToCamera: number;
  21342. /** @hidden */
  21343. _id: number;
  21344. private _currentMaterial;
  21345. /**
  21346. * Add a new submesh to a mesh
  21347. * @param materialIndex defines the material index to use
  21348. * @param verticesStart defines vertex index start
  21349. * @param verticesCount defines vertices count
  21350. * @param indexStart defines index start
  21351. * @param indexCount defines indices count
  21352. * @param mesh defines the parent mesh
  21353. * @param renderingMesh defines an optional rendering mesh
  21354. * @param createBoundingBox defines if bounding box should be created for this submesh
  21355. * @returns the new submesh
  21356. */
  21357. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21358. /**
  21359. * Creates a new submesh
  21360. * @param materialIndex defines the material index to use
  21361. * @param verticesStart defines vertex index start
  21362. * @param verticesCount defines vertices count
  21363. * @param indexStart defines index start
  21364. * @param indexCount defines indices count
  21365. * @param mesh defines the parent mesh
  21366. * @param renderingMesh defines an optional rendering mesh
  21367. * @param createBoundingBox defines if bounding box should be created for this submesh
  21368. */
  21369. constructor(
  21370. /** the material index to use */
  21371. materialIndex: number,
  21372. /** vertex index start */
  21373. verticesStart: number,
  21374. /** vertices count */
  21375. verticesCount: number,
  21376. /** index start */
  21377. indexStart: number,
  21378. /** indices count */
  21379. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21380. /**
  21381. * Returns true if this submesh covers the entire parent mesh
  21382. * @ignorenaming
  21383. */
  21384. readonly IsGlobal: boolean;
  21385. /**
  21386. * Returns the submesh BoudingInfo object
  21387. * @returns current bounding info (or mesh's one if the submesh is global)
  21388. */
  21389. getBoundingInfo(): BoundingInfo;
  21390. /**
  21391. * Sets the submesh BoundingInfo
  21392. * @param boundingInfo defines the new bounding info to use
  21393. * @returns the SubMesh
  21394. */
  21395. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21396. /**
  21397. * Returns the mesh of the current submesh
  21398. * @return the parent mesh
  21399. */
  21400. getMesh(): AbstractMesh;
  21401. /**
  21402. * Returns the rendering mesh of the submesh
  21403. * @returns the rendering mesh (could be different from parent mesh)
  21404. */
  21405. getRenderingMesh(): Mesh;
  21406. /**
  21407. * Returns the submesh material
  21408. * @returns null or the current material
  21409. */
  21410. getMaterial(): Nullable<Material>;
  21411. /**
  21412. * Sets a new updated BoundingInfo object to the submesh
  21413. * @returns the SubMesh
  21414. */
  21415. refreshBoundingInfo(): SubMesh;
  21416. /** @hidden */
  21417. _checkCollision(collider: Collider): boolean;
  21418. /**
  21419. * Updates the submesh BoundingInfo
  21420. * @param world defines the world matrix to use to update the bounding info
  21421. * @returns the submesh
  21422. */
  21423. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21424. /**
  21425. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is intersecting with the frustum
  21428. */
  21429. isInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21432. * @param frustumPlanes defines the frustum planes
  21433. * @returns true if the submesh is inside the frustum
  21434. */
  21435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21436. /**
  21437. * Renders the submesh
  21438. * @param enableAlphaMode defines if alpha needs to be used
  21439. * @returns the submesh
  21440. */
  21441. render(enableAlphaMode: boolean): SubMesh;
  21442. /**
  21443. * @hidden
  21444. */
  21445. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21446. /**
  21447. * Checks if the submesh intersects with a ray
  21448. * @param ray defines the ray to test
  21449. * @returns true is the passed ray intersects the submesh bounding box
  21450. */
  21451. canIntersects(ray: Ray): boolean;
  21452. /**
  21453. * Intersects current submesh with a ray
  21454. * @param ray defines the ray to test
  21455. * @param positions defines mesh's positions array
  21456. * @param indices defines mesh's indices array
  21457. * @param fastCheck defines if only bounding info should be used
  21458. * @returns intersection info or null if no intersection
  21459. */
  21460. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21461. /** @hidden */
  21462. private _intersectLines;
  21463. /** @hidden */
  21464. private _intersectTriangles;
  21465. /** @hidden */
  21466. _rebuild(): void;
  21467. /**
  21468. * Creates a new submesh from the passed mesh
  21469. * @param newMesh defines the new hosting mesh
  21470. * @param newRenderingMesh defines an optional rendering mesh
  21471. * @returns the new submesh
  21472. */
  21473. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21474. /**
  21475. * Release associated resources
  21476. */
  21477. dispose(): void;
  21478. /**
  21479. * Gets the class name
  21480. * @returns the string "SubMesh".
  21481. */
  21482. getClassName(): string;
  21483. /**
  21484. * Creates a new submesh from indices data
  21485. * @param materialIndex the index of the main mesh material
  21486. * @param startIndex the index where to start the copy in the mesh indices array
  21487. * @param indexCount the number of indices to copy then from the startIndex
  21488. * @param mesh the main mesh to create the submesh from
  21489. * @param renderingMesh the optional rendering mesh
  21490. * @returns a new submesh
  21491. */
  21492. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21493. }
  21494. }
  21495. declare module "babylonjs/Meshes/geometry" {
  21496. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21497. import { Scene } from "babylonjs/scene";
  21498. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21499. import { Engine } from "babylonjs/Engines/engine";
  21500. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21501. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21502. import { Effect } from "babylonjs/Materials/effect";
  21503. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21504. import { Mesh } from "babylonjs/Meshes/mesh";
  21505. /**
  21506. * Class used to store geometry data (vertex buffers + index buffer)
  21507. */
  21508. export class Geometry implements IGetSetVerticesData {
  21509. /**
  21510. * Gets or sets the ID of the geometry
  21511. */
  21512. id: string;
  21513. /**
  21514. * Gets or sets the unique ID of the geometry
  21515. */
  21516. uniqueId: number;
  21517. /**
  21518. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21519. */
  21520. delayLoadState: number;
  21521. /**
  21522. * Gets the file containing the data to load when running in delay load state
  21523. */
  21524. delayLoadingFile: Nullable<string>;
  21525. /**
  21526. * Callback called when the geometry is updated
  21527. */
  21528. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21529. private _scene;
  21530. private _engine;
  21531. private _meshes;
  21532. private _totalVertices;
  21533. /** @hidden */
  21534. _indices: IndicesArray;
  21535. /** @hidden */
  21536. _vertexBuffers: {
  21537. [key: string]: VertexBuffer;
  21538. };
  21539. private _isDisposed;
  21540. private _extend;
  21541. private _boundingBias;
  21542. /** @hidden */
  21543. _delayInfo: Array<string>;
  21544. private _indexBuffer;
  21545. private _indexBufferIsUpdatable;
  21546. /** @hidden */
  21547. _boundingInfo: Nullable<BoundingInfo>;
  21548. /** @hidden */
  21549. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21550. /** @hidden */
  21551. _softwareSkinningFrameId: number;
  21552. private _vertexArrayObjects;
  21553. private _updatable;
  21554. /** @hidden */
  21555. _positions: Nullable<Vector3[]>;
  21556. /**
  21557. * 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
  21558. */
  21559. /**
  21560. * 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
  21561. */
  21562. boundingBias: Vector2;
  21563. /**
  21564. * Static function used to attach a new empty geometry to a mesh
  21565. * @param mesh defines the mesh to attach the geometry to
  21566. * @returns the new Geometry
  21567. */
  21568. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21569. /**
  21570. * Creates a new geometry
  21571. * @param id defines the unique ID
  21572. * @param scene defines the hosting scene
  21573. * @param vertexData defines the VertexData used to get geometry data
  21574. * @param updatable defines if geometry must be updatable (false by default)
  21575. * @param mesh defines the mesh that will be associated with the geometry
  21576. */
  21577. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21578. /**
  21579. * Gets the current extend of the geometry
  21580. */
  21581. readonly extend: {
  21582. minimum: Vector3;
  21583. maximum: Vector3;
  21584. };
  21585. /**
  21586. * Gets the hosting scene
  21587. * @returns the hosting Scene
  21588. */
  21589. getScene(): Scene;
  21590. /**
  21591. * Gets the hosting engine
  21592. * @returns the hosting Engine
  21593. */
  21594. getEngine(): Engine;
  21595. /**
  21596. * Defines if the geometry is ready to use
  21597. * @returns true if the geometry is ready to be used
  21598. */
  21599. isReady(): boolean;
  21600. /**
  21601. * Gets a value indicating that the geometry should not be serialized
  21602. */
  21603. readonly doNotSerialize: boolean;
  21604. /** @hidden */
  21605. _rebuild(): void;
  21606. /**
  21607. * Affects all geometry data in one call
  21608. * @param vertexData defines the geometry data
  21609. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21610. */
  21611. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21612. /**
  21613. * Set specific vertex data
  21614. * @param kind defines the data kind (Position, normal, etc...)
  21615. * @param data defines the vertex data to use
  21616. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21617. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21618. */
  21619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21620. /**
  21621. * Removes a specific vertex data
  21622. * @param kind defines the data kind (Position, normal, etc...)
  21623. */
  21624. removeVerticesData(kind: string): void;
  21625. /**
  21626. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21627. * @param buffer defines the vertex buffer to use
  21628. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21629. */
  21630. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21631. /**
  21632. * Update a specific vertex buffer
  21633. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21634. * It will do nothing if the buffer is not updatable
  21635. * @param kind defines the data kind (Position, normal, etc...)
  21636. * @param data defines the data to use
  21637. * @param offset defines the offset in the target buffer where to store the data
  21638. * @param useBytes set to true if the offset is in bytes
  21639. */
  21640. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21641. /**
  21642. * Update a specific vertex buffer
  21643. * This function will create a new buffer if the current one is not updatable
  21644. * @param kind defines the data kind (Position, normal, etc...)
  21645. * @param data defines the data to use
  21646. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21647. */
  21648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21649. private _updateBoundingInfo;
  21650. /** @hidden */
  21651. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21652. /**
  21653. * Gets total number of vertices
  21654. * @returns the total number of vertices
  21655. */
  21656. getTotalVertices(): number;
  21657. /**
  21658. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21659. * @param kind defines the data kind (Position, normal, etc...)
  21660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21662. * @returns a float array containing vertex data
  21663. */
  21664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21665. /**
  21666. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21667. * @param kind defines the data kind (Position, normal, etc...)
  21668. * @returns true if the vertex buffer with the specified kind is updatable
  21669. */
  21670. isVertexBufferUpdatable(kind: string): boolean;
  21671. /**
  21672. * Gets a specific vertex buffer
  21673. * @param kind defines the data kind (Position, normal, etc...)
  21674. * @returns a VertexBuffer
  21675. */
  21676. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21677. /**
  21678. * Returns all vertex buffers
  21679. * @return an object holding all vertex buffers indexed by kind
  21680. */
  21681. getVertexBuffers(): Nullable<{
  21682. [key: string]: VertexBuffer;
  21683. }>;
  21684. /**
  21685. * Gets a boolean indicating if specific vertex buffer is present
  21686. * @param kind defines the data kind (Position, normal, etc...)
  21687. * @returns true if data is present
  21688. */
  21689. isVerticesDataPresent(kind: string): boolean;
  21690. /**
  21691. * Gets a list of all attached data kinds (Position, normal, etc...)
  21692. * @returns a list of string containing all kinds
  21693. */
  21694. getVerticesDataKinds(): string[];
  21695. /**
  21696. * Update index buffer
  21697. * @param indices defines the indices to store in the index buffer
  21698. * @param offset defines the offset in the target buffer where to store the data
  21699. */
  21700. updateIndices(indices: IndicesArray, offset?: number): void;
  21701. /**
  21702. * Creates a new index buffer
  21703. * @param indices defines the indices to store in the index buffer
  21704. * @param totalVertices defines the total number of vertices (could be null)
  21705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21706. */
  21707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21708. /**
  21709. * Return the total number of indices
  21710. * @returns the total number of indices
  21711. */
  21712. getTotalIndices(): number;
  21713. /**
  21714. * Gets the index buffer array
  21715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21717. * @returns the index buffer array
  21718. */
  21719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21720. /**
  21721. * Gets the index buffer
  21722. * @return the index buffer
  21723. */
  21724. getIndexBuffer(): Nullable<WebGLBuffer>;
  21725. /** @hidden */
  21726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21727. /**
  21728. * Release the associated resources for a specific mesh
  21729. * @param mesh defines the source mesh
  21730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21731. */
  21732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21733. /**
  21734. * Apply current geometry to a given mesh
  21735. * @param mesh defines the mesh to apply geometry to
  21736. */
  21737. applyToMesh(mesh: Mesh): void;
  21738. private _updateExtend;
  21739. private _applyToMesh;
  21740. private notifyUpdate;
  21741. /**
  21742. * Load the geometry if it was flagged as delay loaded
  21743. * @param scene defines the hosting scene
  21744. * @param onLoaded defines a callback called when the geometry is loaded
  21745. */
  21746. load(scene: Scene, onLoaded?: () => void): void;
  21747. private _queueLoad;
  21748. /**
  21749. * Invert the geometry to move from a right handed system to a left handed one.
  21750. */
  21751. toLeftHanded(): void;
  21752. /** @hidden */
  21753. _resetPointsArrayCache(): void;
  21754. /** @hidden */
  21755. _generatePointsArray(): boolean;
  21756. /**
  21757. * Gets a value indicating if the geometry is disposed
  21758. * @returns true if the geometry was disposed
  21759. */
  21760. isDisposed(): boolean;
  21761. private _disposeVertexArrayObjects;
  21762. /**
  21763. * Free all associated resources
  21764. */
  21765. dispose(): void;
  21766. /**
  21767. * Clone the current geometry into a new geometry
  21768. * @param id defines the unique ID of the new geometry
  21769. * @returns a new geometry object
  21770. */
  21771. copy(id: string): Geometry;
  21772. /**
  21773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21774. * @return a JSON representation of the current geometry data (without the vertices data)
  21775. */
  21776. serialize(): any;
  21777. private toNumberArray;
  21778. /**
  21779. * Serialize all vertices data into a JSON oject
  21780. * @returns a JSON representation of the current geometry data
  21781. */
  21782. serializeVerticeData(): any;
  21783. /**
  21784. * Extracts a clone of a mesh geometry
  21785. * @param mesh defines the source mesh
  21786. * @param id defines the unique ID of the new geometry object
  21787. * @returns the new geometry object
  21788. */
  21789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21790. /**
  21791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21793. * Be aware Math.random() could cause collisions, but:
  21794. * "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"
  21795. * @returns a string containing a new GUID
  21796. */
  21797. static RandomId(): string;
  21798. /** @hidden */
  21799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21800. private static _CleanMatricesWeights;
  21801. /**
  21802. * Create a new geometry from persisted data (Using .babylon file format)
  21803. * @param parsedVertexData defines the persisted data
  21804. * @param scene defines the hosting scene
  21805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21806. * @returns the new geometry object
  21807. */
  21808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21809. }
  21810. }
  21811. declare module "babylonjs/Meshes/mesh.vertexData" {
  21812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21813. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  21814. import { Geometry } from "babylonjs/Meshes/geometry";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. /**
  21817. * Define an interface for all classes that will get and set the data on vertices
  21818. */
  21819. export interface IGetSetVerticesData {
  21820. /**
  21821. * Gets a boolean indicating if specific vertex data is present
  21822. * @param kind defines the vertex data kind to use
  21823. * @returns true is data kind is present
  21824. */
  21825. isVerticesDataPresent(kind: string): boolean;
  21826. /**
  21827. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21830. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21831. * @returns a float array containing vertex data
  21832. */
  21833. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21834. /**
  21835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21836. * @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.
  21837. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21838. * @returns the indices array or an empty array if the mesh has no geometry
  21839. */
  21840. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21841. /**
  21842. * Set specific vertex data
  21843. * @param kind defines the data kind (Position, normal, etc...)
  21844. * @param data defines the vertex data to use
  21845. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21846. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21847. */
  21848. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21849. /**
  21850. * Update a specific associated vertex buffer
  21851. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21852. * - VertexBuffer.PositionKind
  21853. * - VertexBuffer.UVKind
  21854. * - VertexBuffer.UV2Kind
  21855. * - VertexBuffer.UV3Kind
  21856. * - VertexBuffer.UV4Kind
  21857. * - VertexBuffer.UV5Kind
  21858. * - VertexBuffer.UV6Kind
  21859. * - VertexBuffer.ColorKind
  21860. * - VertexBuffer.MatricesIndicesKind
  21861. * - VertexBuffer.MatricesIndicesExtraKind
  21862. * - VertexBuffer.MatricesWeightsKind
  21863. * - VertexBuffer.MatricesWeightsExtraKind
  21864. * @param data defines the data source
  21865. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21866. * @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)
  21867. */
  21868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21869. /**
  21870. * Creates a new index buffer
  21871. * @param indices defines the indices to store in the index buffer
  21872. * @param totalVertices defines the total number of vertices (could be null)
  21873. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21874. */
  21875. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21876. }
  21877. /**
  21878. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21879. */
  21880. export class VertexData {
  21881. /**
  21882. * Mesh side orientation : usually the external or front surface
  21883. */
  21884. static readonly FRONTSIDE: number;
  21885. /**
  21886. * Mesh side orientation : usually the internal or back surface
  21887. */
  21888. static readonly BACKSIDE: number;
  21889. /**
  21890. * Mesh side orientation : both internal and external or front and back surfaces
  21891. */
  21892. static readonly DOUBLESIDE: number;
  21893. /**
  21894. * Mesh side orientation : by default, `FRONTSIDE`
  21895. */
  21896. static readonly DEFAULTSIDE: number;
  21897. /**
  21898. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21899. */
  21900. positions: Nullable<FloatArray>;
  21901. /**
  21902. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21903. */
  21904. normals: Nullable<FloatArray>;
  21905. /**
  21906. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21907. */
  21908. tangents: Nullable<FloatArray>;
  21909. /**
  21910. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21911. */
  21912. uvs: Nullable<FloatArray>;
  21913. /**
  21914. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21915. */
  21916. uvs2: Nullable<FloatArray>;
  21917. /**
  21918. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21919. */
  21920. uvs3: Nullable<FloatArray>;
  21921. /**
  21922. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21923. */
  21924. uvs4: Nullable<FloatArray>;
  21925. /**
  21926. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21927. */
  21928. uvs5: Nullable<FloatArray>;
  21929. /**
  21930. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21931. */
  21932. uvs6: Nullable<FloatArray>;
  21933. /**
  21934. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21935. */
  21936. colors: Nullable<FloatArray>;
  21937. /**
  21938. * 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).
  21939. */
  21940. matricesIndices: Nullable<FloatArray>;
  21941. /**
  21942. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21943. */
  21944. matricesWeights: Nullable<FloatArray>;
  21945. /**
  21946. * An array extending the number of possible indices
  21947. */
  21948. matricesIndicesExtra: Nullable<FloatArray>;
  21949. /**
  21950. * An array extending the number of possible weights when the number of indices is extended
  21951. */
  21952. matricesWeightsExtra: Nullable<FloatArray>;
  21953. /**
  21954. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21955. */
  21956. indices: Nullable<IndicesArray>;
  21957. /**
  21958. * Uses the passed data array to set the set the values for the specified kind of data
  21959. * @param data a linear array of floating numbers
  21960. * @param kind the type of data that is being set, eg positions, colors etc
  21961. */
  21962. set(data: FloatArray, kind: string): void;
  21963. /**
  21964. * Associates the vertexData to the passed Mesh.
  21965. * Sets it as updatable or not (default `false`)
  21966. * @param mesh the mesh the vertexData is applied to
  21967. * @param updatable when used and having the value true allows new data to update the vertexData
  21968. * @returns the VertexData
  21969. */
  21970. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21971. /**
  21972. * Associates the vertexData to the passed Geometry.
  21973. * Sets it as updatable or not (default `false`)
  21974. * @param geometry the geometry the vertexData is applied to
  21975. * @param updatable when used and having the value true allows new data to update the vertexData
  21976. * @returns VertexData
  21977. */
  21978. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21979. /**
  21980. * Updates the associated mesh
  21981. * @param mesh the mesh to be updated
  21982. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21983. * @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
  21984. * @returns VertexData
  21985. */
  21986. updateMesh(mesh: Mesh): VertexData;
  21987. /**
  21988. * Updates the associated geometry
  21989. * @param geometry the geometry to be updated
  21990. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21991. * @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
  21992. * @returns VertexData.
  21993. */
  21994. updateGeometry(geometry: Geometry): VertexData;
  21995. private _applyTo;
  21996. private _update;
  21997. /**
  21998. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21999. * @param matrix the transforming matrix
  22000. * @returns the VertexData
  22001. */
  22002. transform(matrix: Matrix): VertexData;
  22003. /**
  22004. * Merges the passed VertexData into the current one
  22005. * @param other the VertexData to be merged into the current one
  22006. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22007. * @returns the modified VertexData
  22008. */
  22009. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22010. private _mergeElement;
  22011. private _validate;
  22012. /**
  22013. * Serializes the VertexData
  22014. * @returns a serialized object
  22015. */
  22016. serialize(): any;
  22017. /**
  22018. * Extracts the vertexData from a mesh
  22019. * @param mesh the mesh from which to extract the VertexData
  22020. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22021. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22022. * @returns the object VertexData associated to the passed mesh
  22023. */
  22024. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22025. /**
  22026. * Extracts the vertexData from the geometry
  22027. * @param geometry the geometry from which to extract the VertexData
  22028. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22029. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22030. * @returns the object VertexData associated to the passed mesh
  22031. */
  22032. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22033. private static _ExtractFrom;
  22034. /**
  22035. * Creates the VertexData for a Ribbon
  22036. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22037. * * pathArray array of paths, each of which an array of successive Vector3
  22038. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22039. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22040. * * 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
  22041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22042. * * 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)
  22043. * * 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)
  22044. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22045. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22046. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22047. * @returns the VertexData of the ribbon
  22048. */
  22049. static CreateRibbon(options: {
  22050. pathArray: Vector3[][];
  22051. closeArray?: boolean;
  22052. closePath?: boolean;
  22053. offset?: number;
  22054. sideOrientation?: number;
  22055. frontUVs?: Vector4;
  22056. backUVs?: Vector4;
  22057. invertUV?: boolean;
  22058. uvs?: Vector2[];
  22059. colors?: Color4[];
  22060. }): VertexData;
  22061. /**
  22062. * Creates the VertexData for a box
  22063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22064. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22065. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22066. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22067. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22068. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22069. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22071. * * 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)
  22072. * * 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)
  22073. * @returns the VertexData of the box
  22074. */
  22075. static CreateBox(options: {
  22076. size?: number;
  22077. width?: number;
  22078. height?: number;
  22079. depth?: number;
  22080. faceUV?: Vector4[];
  22081. faceColors?: Color4[];
  22082. sideOrientation?: number;
  22083. frontUVs?: Vector4;
  22084. backUVs?: Vector4;
  22085. }): VertexData;
  22086. /**
  22087. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22089. * * segments sets the number of horizontal strips optional, default 32
  22090. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22091. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22092. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22093. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22094. * * 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
  22095. * * 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
  22096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22097. * * 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)
  22098. * * 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)
  22099. * @returns the VertexData of the ellipsoid
  22100. */
  22101. static CreateSphere(options: {
  22102. segments?: number;
  22103. diameter?: number;
  22104. diameterX?: number;
  22105. diameterY?: number;
  22106. diameterZ?: number;
  22107. arc?: number;
  22108. slice?: number;
  22109. sideOrientation?: number;
  22110. frontUVs?: Vector4;
  22111. backUVs?: Vector4;
  22112. }): VertexData;
  22113. /**
  22114. * Creates the VertexData for a cylinder, cone or prism
  22115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22116. * * height sets the height (y direction) of the cylinder, optional, default 2
  22117. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22118. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22119. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22120. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22121. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22122. * * 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
  22123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22125. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22126. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the cylinder, cone or prism
  22131. */
  22132. static CreateCylinder(options: {
  22133. height?: number;
  22134. diameterTop?: number;
  22135. diameterBottom?: number;
  22136. diameter?: number;
  22137. tessellation?: number;
  22138. subdivisions?: number;
  22139. arc?: number;
  22140. faceColors?: Color4[];
  22141. faceUV?: Vector4[];
  22142. hasRings?: boolean;
  22143. enclose?: boolean;
  22144. sideOrientation?: number;
  22145. frontUVs?: Vector4;
  22146. backUVs?: Vector4;
  22147. }): VertexData;
  22148. /**
  22149. * Creates the VertexData for a torus
  22150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22151. * * diameter the diameter of the torus, optional default 1
  22152. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22153. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22155. * * 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)
  22156. * * 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)
  22157. * @returns the VertexData of the torus
  22158. */
  22159. static CreateTorus(options: {
  22160. diameter?: number;
  22161. thickness?: number;
  22162. tessellation?: number;
  22163. sideOrientation?: number;
  22164. frontUVs?: Vector4;
  22165. backUVs?: Vector4;
  22166. }): VertexData;
  22167. /**
  22168. * Creates the VertexData of the LineSystem
  22169. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22170. * - lines an array of lines, each line being an array of successive Vector3
  22171. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22172. * @returns the VertexData of the LineSystem
  22173. */
  22174. static CreateLineSystem(options: {
  22175. lines: Vector3[][];
  22176. colors?: Nullable<Color4[][]>;
  22177. }): VertexData;
  22178. /**
  22179. * Create the VertexData for a DashedLines
  22180. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22181. * - points an array successive Vector3
  22182. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22183. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22184. * - dashNb the intended total number of dashes, optional, default 200
  22185. * @returns the VertexData for the DashedLines
  22186. */
  22187. static CreateDashedLines(options: {
  22188. points: Vector3[];
  22189. dashSize?: number;
  22190. gapSize?: number;
  22191. dashNb?: number;
  22192. }): VertexData;
  22193. /**
  22194. * Creates the VertexData for a Ground
  22195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22196. * - width the width (x direction) of the ground, optional, default 1
  22197. * - height the height (z direction) of the ground, optional, default 1
  22198. * - subdivisions the number of subdivisions per side, optional, default 1
  22199. * @returns the VertexData of the Ground
  22200. */
  22201. static CreateGround(options: {
  22202. width?: number;
  22203. height?: number;
  22204. subdivisions?: number;
  22205. subdivisionsX?: number;
  22206. subdivisionsY?: number;
  22207. }): VertexData;
  22208. /**
  22209. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22210. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22211. * * xmin the ground minimum X coordinate, optional, default -1
  22212. * * zmin the ground minimum Z coordinate, optional, default -1
  22213. * * xmax the ground maximum X coordinate, optional, default 1
  22214. * * zmax the ground maximum Z coordinate, optional, default 1
  22215. * * 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}
  22216. * * 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}
  22217. * @returns the VertexData of the TiledGround
  22218. */
  22219. static CreateTiledGround(options: {
  22220. xmin: number;
  22221. zmin: number;
  22222. xmax: number;
  22223. zmax: number;
  22224. subdivisions?: {
  22225. w: number;
  22226. h: number;
  22227. };
  22228. precision?: {
  22229. w: number;
  22230. h: number;
  22231. };
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData of the Ground designed from a heightmap
  22235. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22236. * * width the width (x direction) of the ground
  22237. * * height the height (z direction) of the ground
  22238. * * subdivisions the number of subdivisions per side
  22239. * * minHeight the minimum altitude on the ground, optional, default 0
  22240. * * maxHeight the maximum altitude on the ground, optional default 1
  22241. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22242. * * buffer the array holding the image color data
  22243. * * bufferWidth the width of image
  22244. * * bufferHeight the height of image
  22245. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22246. * @returns the VertexData of the Ground designed from a heightmap
  22247. */
  22248. static CreateGroundFromHeightMap(options: {
  22249. width: number;
  22250. height: number;
  22251. subdivisions: number;
  22252. minHeight: number;
  22253. maxHeight: number;
  22254. colorFilter: Color3;
  22255. buffer: Uint8Array;
  22256. bufferWidth: number;
  22257. bufferHeight: number;
  22258. alphaFilter: number;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a Plane
  22262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22263. * * size sets the width and height of the plane to the value of size, optional default 1
  22264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * @returns the VertexData of the box
  22270. */
  22271. static CreatePlane(options: {
  22272. size?: number;
  22273. width?: number;
  22274. height?: number;
  22275. sideOrientation?: number;
  22276. frontUVs?: Vector4;
  22277. backUVs?: Vector4;
  22278. }): VertexData;
  22279. /**
  22280. * Creates the VertexData of the Disc or regular Polygon
  22281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22282. * * radius the radius of the disc, optional default 0.5
  22283. * * tessellation the number of polygon sides, optional, default 64
  22284. * * 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
  22285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * @returns the VertexData of the box
  22289. */
  22290. static CreateDisc(options: {
  22291. radius?: number;
  22292. tessellation?: number;
  22293. arc?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22301. * @param polygon a mesh built from polygonTriangulation.build()
  22302. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22305. * @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)
  22306. * @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)
  22307. * @returns the VertexData of the Polygon
  22308. */
  22309. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22310. /**
  22311. * Creates the VertexData of the IcoSphere
  22312. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22313. * * radius the radius of the IcoSphere, optional default 1
  22314. * * radiusX allows stretching in the x direction, optional, default radius
  22315. * * radiusY allows stretching in the y direction, optional, default radius
  22316. * * radiusZ allows stretching in the z direction, optional, default radius
  22317. * * flat when true creates a flat shaded mesh, optional, default true
  22318. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * * 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)
  22321. * * 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)
  22322. * @returns the VertexData of the IcoSphere
  22323. */
  22324. static CreateIcoSphere(options: {
  22325. radius?: number;
  22326. radiusX?: number;
  22327. radiusY?: number;
  22328. radiusZ?: number;
  22329. flat?: boolean;
  22330. subdivisions?: number;
  22331. sideOrientation?: number;
  22332. frontUVs?: Vector4;
  22333. backUVs?: Vector4;
  22334. }): VertexData;
  22335. /**
  22336. * Creates the VertexData for a Polyhedron
  22337. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22338. * * type provided types are:
  22339. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22340. * * 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)
  22341. * * size the size of the IcoSphere, optional default 1
  22342. * * sizeX allows stretching in the x direction, optional, default size
  22343. * * sizeY allows stretching in the y direction, optional, default size
  22344. * * sizeZ allows stretching in the z direction, optional, default size
  22345. * * 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
  22346. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22347. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22348. * * flat when true creates a flat shaded mesh, optional, default true
  22349. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22351. * * 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)
  22352. * * 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)
  22353. * @returns the VertexData of the Polyhedron
  22354. */
  22355. static CreatePolyhedron(options: {
  22356. type?: number;
  22357. size?: number;
  22358. sizeX?: number;
  22359. sizeY?: number;
  22360. sizeZ?: number;
  22361. custom?: any;
  22362. faceUV?: Vector4[];
  22363. faceColors?: Color4[];
  22364. flat?: boolean;
  22365. sideOrientation?: number;
  22366. frontUVs?: Vector4;
  22367. backUVs?: Vector4;
  22368. }): VertexData;
  22369. /**
  22370. * Creates the VertexData for a TorusKnot
  22371. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22372. * * radius the radius of the torus knot, optional, default 2
  22373. * * tube the thickness of the tube, optional, default 0.5
  22374. * * radialSegments the number of sides on each tube segments, optional, default 32
  22375. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22376. * * p the number of windings around the z axis, optional, default 2
  22377. * * q the number of windings around the x axis, optional, default 3
  22378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22379. * * 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)
  22380. * * 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)
  22381. * @returns the VertexData of the Torus Knot
  22382. */
  22383. static CreateTorusKnot(options: {
  22384. radius?: number;
  22385. tube?: number;
  22386. radialSegments?: number;
  22387. tubularSegments?: number;
  22388. p?: number;
  22389. q?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Compute normals for given positions and indices
  22396. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22397. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22398. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22399. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22400. * * facetNormals : optional array of facet normals (vector3)
  22401. * * facetPositions : optional array of facet positions (vector3)
  22402. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22403. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22404. * * bInfo : optional bounding info, required for facetPartitioning computation
  22405. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22406. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22407. * * useRightHandedSystem: optional boolean to for right handed system computation
  22408. * * depthSort : optional boolean to enable the facet depth sort computation
  22409. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22410. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22411. */
  22412. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22413. facetNormals?: any;
  22414. facetPositions?: any;
  22415. facetPartitioning?: any;
  22416. ratio?: number;
  22417. bInfo?: any;
  22418. bbSize?: Vector3;
  22419. subDiv?: any;
  22420. useRightHandedSystem?: boolean;
  22421. depthSort?: boolean;
  22422. distanceTo?: Vector3;
  22423. depthSortedFacets?: any;
  22424. }): void;
  22425. /** @hidden */
  22426. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22427. /**
  22428. * Applies VertexData created from the imported parameters to the geometry
  22429. * @param parsedVertexData the parsed data from an imported file
  22430. * @param geometry the geometry to apply the VertexData to
  22431. */
  22432. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22433. }
  22434. }
  22435. declare module "babylonjs/Meshes/Builders/discBuilder" {
  22436. import { Nullable } from "babylonjs/types";
  22437. import { Scene } from "babylonjs/scene";
  22438. import { Vector4 } from "babylonjs/Maths/math";
  22439. import { Mesh } from "babylonjs/Meshes/mesh";
  22440. /**
  22441. * Class containing static functions to help procedurally build meshes
  22442. */
  22443. export class DiscBuilder {
  22444. /**
  22445. * Creates a plane polygonal mesh. By default, this is a disc
  22446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22447. * * 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
  22448. * * 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
  22449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22452. * @param name defines the name of the mesh
  22453. * @param options defines the options used to create the mesh
  22454. * @param scene defines the hosting scene
  22455. * @returns the plane polygonal mesh
  22456. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22457. */
  22458. static CreateDisc(name: string, options: {
  22459. radius?: number;
  22460. tessellation?: number;
  22461. arc?: number;
  22462. updatable?: boolean;
  22463. sideOrientation?: number;
  22464. frontUVs?: Vector4;
  22465. backUVs?: Vector4;
  22466. }, scene?: Nullable<Scene>): Mesh;
  22467. }
  22468. }
  22469. declare module "babylonjs/Particles/solidParticleSystem" {
  22470. import { Vector3 } from "babylonjs/Maths/math";
  22471. import { Mesh } from "babylonjs/Meshes/mesh";
  22472. import { Scene, IDisposable } from "babylonjs/scene";
  22473. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  22474. /**
  22475. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22476. *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.
  22477. * The SPS is also a particle system. It provides some methods to manage the particles.
  22478. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22479. *
  22480. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22481. */
  22482. export class SolidParticleSystem implements IDisposable {
  22483. /**
  22484. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22485. * Example : var p = SPS.particles[i];
  22486. */
  22487. particles: SolidParticle[];
  22488. /**
  22489. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22490. */
  22491. nbParticles: number;
  22492. /**
  22493. * If the particles must ever face the camera (default false). Useful for planar particles.
  22494. */
  22495. billboard: boolean;
  22496. /**
  22497. * Recompute normals when adding a shape
  22498. */
  22499. recomputeNormals: boolean;
  22500. /**
  22501. * This a counter ofr your own usage. It's not set by any SPS functions.
  22502. */
  22503. counter: number;
  22504. /**
  22505. * The SPS name. This name is also given to the underlying mesh.
  22506. */
  22507. name: string;
  22508. /**
  22509. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22510. */
  22511. mesh: Mesh;
  22512. /**
  22513. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22514. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22515. */
  22516. vars: any;
  22517. /**
  22518. * This array is populated when the SPS is set as 'pickable'.
  22519. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22520. * Each element of this array is an object `{idx: int, faceId: int}`.
  22521. * `idx` is the picked particle index in the `SPS.particles` array
  22522. * `faceId` is the picked face index counted within this particle.
  22523. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22524. */
  22525. pickedParticles: {
  22526. idx: number;
  22527. faceId: number;
  22528. }[];
  22529. /**
  22530. * This array is populated when `enableDepthSort` is set to true.
  22531. * Each element of this array is an instance of the class DepthSortedParticle.
  22532. */
  22533. depthSortedParticles: DepthSortedParticle[];
  22534. /**
  22535. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22536. * @hidden
  22537. */
  22538. _bSphereOnly: boolean;
  22539. /**
  22540. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22541. * @hidden
  22542. */
  22543. _bSphereRadiusFactor: number;
  22544. private _scene;
  22545. private _positions;
  22546. private _indices;
  22547. private _normals;
  22548. private _colors;
  22549. private _uvs;
  22550. private _indices32;
  22551. private _positions32;
  22552. private _normals32;
  22553. private _fixedNormal32;
  22554. private _colors32;
  22555. private _uvs32;
  22556. private _index;
  22557. private _updatable;
  22558. private _pickable;
  22559. private _isVisibilityBoxLocked;
  22560. private _alwaysVisible;
  22561. private _depthSort;
  22562. private _shapeCounter;
  22563. private _copy;
  22564. private _color;
  22565. private _computeParticleColor;
  22566. private _computeParticleTexture;
  22567. private _computeParticleRotation;
  22568. private _computeParticleVertex;
  22569. private _computeBoundingBox;
  22570. private _depthSortParticles;
  22571. private _camera;
  22572. private _mustUnrotateFixedNormals;
  22573. private _particlesIntersect;
  22574. private _needs32Bits;
  22575. /**
  22576. * Creates a SPS (Solid Particle System) object.
  22577. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22578. * @param scene (Scene) is the scene in which the SPS is added.
  22579. * @param options defines the options of the sps e.g.
  22580. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22581. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22582. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22583. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22584. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22585. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22586. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22587. */
  22588. constructor(name: string, scene: Scene, options?: {
  22589. updatable?: boolean;
  22590. isPickable?: boolean;
  22591. enableDepthSort?: boolean;
  22592. particleIntersection?: boolean;
  22593. boundingSphereOnly?: boolean;
  22594. bSphereRadiusFactor?: number;
  22595. });
  22596. /**
  22597. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22598. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22599. * @returns the created mesh
  22600. */
  22601. buildMesh(): Mesh;
  22602. /**
  22603. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22604. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22605. * Thus the particles generated from `digest()` have their property `position` set yet.
  22606. * @param mesh ( Mesh ) is the mesh to be digested
  22607. * @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
  22608. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22609. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22610. * @returns the current SPS
  22611. */
  22612. digest(mesh: Mesh, options?: {
  22613. facetNb?: number;
  22614. number?: number;
  22615. delta?: number;
  22616. }): SolidParticleSystem;
  22617. private _unrotateFixedNormals;
  22618. private _resetCopy;
  22619. private _meshBuilder;
  22620. private _posToShape;
  22621. private _uvsToShapeUV;
  22622. private _addParticle;
  22623. /**
  22624. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22625. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22626. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22627. * @param nb (positive integer) the number of particles to be created from this model
  22628. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22629. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22630. * @returns the number of shapes in the system
  22631. */
  22632. addShape(mesh: Mesh, nb: number, options?: {
  22633. positionFunction?: any;
  22634. vertexFunction?: any;
  22635. }): number;
  22636. private _rebuildParticle;
  22637. /**
  22638. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22639. * @returns the SPS.
  22640. */
  22641. rebuildMesh(): SolidParticleSystem;
  22642. /**
  22643. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22644. * This method calls `updateParticle()` for each particle of the SPS.
  22645. * For an animated SPS, it is usually called within the render loop.
  22646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22649. * @returns the SPS.
  22650. */
  22651. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22652. /**
  22653. * Disposes the SPS.
  22654. */
  22655. dispose(): void;
  22656. /**
  22657. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22658. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22659. * @returns the SPS.
  22660. */
  22661. refreshVisibleSize(): SolidParticleSystem;
  22662. /**
  22663. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22664. * @param size the size (float) of the visibility box
  22665. * note : this doesn't lock the SPS mesh bounding box.
  22666. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22667. */
  22668. setVisibilityBox(size: number): void;
  22669. /**
  22670. * Gets whether the SPS as always visible or not
  22671. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22672. */
  22673. /**
  22674. * Sets the SPS as always visible or not
  22675. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22676. */
  22677. isAlwaysVisible: boolean;
  22678. /**
  22679. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22681. */
  22682. /**
  22683. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22684. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22685. */
  22686. isVisibilityBoxLocked: boolean;
  22687. /**
  22688. * Tells to `setParticles()` to compute the particle rotations or not.
  22689. * Default value : true. The SPS is faster when it's set to false.
  22690. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22691. */
  22692. /**
  22693. * Gets if `setParticles()` computes the particle rotations or not.
  22694. * Default value : true. The SPS is faster when it's set to false.
  22695. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22696. */
  22697. computeParticleRotation: boolean;
  22698. /**
  22699. * Tells to `setParticles()` to compute the particle colors or not.
  22700. * Default value : true. The SPS is faster when it's set to false.
  22701. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22702. */
  22703. /**
  22704. * Gets if `setParticles()` computes the particle colors or not.
  22705. * Default value : true. The SPS is faster when it's set to false.
  22706. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22707. */
  22708. computeParticleColor: boolean;
  22709. /**
  22710. * Gets if `setParticles()` computes the particle textures or not.
  22711. * Default value : true. The SPS is faster when it's set to false.
  22712. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22713. */
  22714. computeParticleTexture: boolean;
  22715. /**
  22716. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22717. * Default value : false. The SPS is faster when it's set to false.
  22718. * Note : the particle custom vertex positions aren't stored values.
  22719. */
  22720. /**
  22721. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22722. * Default value : false. The SPS is faster when it's set to false.
  22723. * Note : the particle custom vertex positions aren't stored values.
  22724. */
  22725. computeParticleVertex: boolean;
  22726. /**
  22727. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22728. */
  22729. /**
  22730. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22731. */
  22732. computeBoundingBox: boolean;
  22733. /**
  22734. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22735. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22736. * Default : `true`
  22737. */
  22738. /**
  22739. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22740. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22741. * Default : `true`
  22742. */
  22743. depthSortParticles: boolean;
  22744. /**
  22745. * This function does nothing. It may be overwritten to set all the particle first values.
  22746. * The SPS doesn't call this function, you may have to call it by your own.
  22747. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22748. */
  22749. initParticles(): void;
  22750. /**
  22751. * This function does nothing. It may be overwritten to recycle a particle.
  22752. * The SPS doesn't call this function, you may have to call it by your own.
  22753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22754. * @param particle The particle to recycle
  22755. * @returns the recycled particle
  22756. */
  22757. recycleParticle(particle: SolidParticle): SolidParticle;
  22758. /**
  22759. * Updates a particle : this function should be overwritten by the user.
  22760. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22761. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22762. * @example : just set a particle position or velocity and recycle conditions
  22763. * @param particle The particle to update
  22764. * @returns the updated particle
  22765. */
  22766. updateParticle(particle: SolidParticle): SolidParticle;
  22767. /**
  22768. * Updates a vertex of a particle : it can be overwritten by the user.
  22769. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22770. * @param particle the current particle
  22771. * @param vertex the current index of the current particle
  22772. * @param pt the index of the current vertex in the particle shape
  22773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22774. * @example : just set a vertex particle position
  22775. * @returns the updated vertex
  22776. */
  22777. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22778. /**
  22779. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22780. * This does nothing and may be overwritten by the user.
  22781. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22782. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22783. * @param update the boolean update value actually passed to setParticles()
  22784. */
  22785. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22786. /**
  22787. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22788. * This will be passed three parameters.
  22789. * This does nothing and may be overwritten by the user.
  22790. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22791. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22792. * @param update the boolean update value actually passed to setParticles()
  22793. */
  22794. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22795. }
  22796. }
  22797. declare module "babylonjs/Particles/solidParticle" {
  22798. import { Nullable } from "babylonjs/types";
  22799. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  22800. import { Mesh } from "babylonjs/Meshes/mesh";
  22801. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22802. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  22803. /**
  22804. * Represents one particle of a solid particle system.
  22805. */
  22806. export class SolidParticle {
  22807. /**
  22808. * particle global index
  22809. */
  22810. idx: number;
  22811. /**
  22812. * The color of the particle
  22813. */
  22814. color: Nullable<Color4>;
  22815. /**
  22816. * The world space position of the particle.
  22817. */
  22818. position: Vector3;
  22819. /**
  22820. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22821. */
  22822. rotation: Vector3;
  22823. /**
  22824. * The world space rotation quaternion of the particle.
  22825. */
  22826. rotationQuaternion: Nullable<Quaternion>;
  22827. /**
  22828. * The scaling of the particle.
  22829. */
  22830. scaling: Vector3;
  22831. /**
  22832. * The uvs of the particle.
  22833. */
  22834. uvs: Vector4;
  22835. /**
  22836. * The current speed of the particle.
  22837. */
  22838. velocity: Vector3;
  22839. /**
  22840. * The pivot point in the particle local space.
  22841. */
  22842. pivot: Vector3;
  22843. /**
  22844. * Must the particle be translated from its pivot point in its local space ?
  22845. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22846. * Default : false
  22847. */
  22848. translateFromPivot: boolean;
  22849. /**
  22850. * Is the particle active or not ?
  22851. */
  22852. alive: boolean;
  22853. /**
  22854. * Is the particle visible or not ?
  22855. */
  22856. isVisible: boolean;
  22857. /**
  22858. * Index of this particle in the global "positions" array (Internal use)
  22859. * @hidden
  22860. */
  22861. _pos: number;
  22862. /**
  22863. * @hidden Index of this particle in the global "indices" array (Internal use)
  22864. */
  22865. _ind: number;
  22866. /**
  22867. * @hidden ModelShape of this particle (Internal use)
  22868. */
  22869. _model: ModelShape;
  22870. /**
  22871. * ModelShape id of this particle
  22872. */
  22873. shapeId: number;
  22874. /**
  22875. * Index of the particle in its shape id (Internal use)
  22876. */
  22877. idxInShape: number;
  22878. /**
  22879. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22880. */
  22881. _modelBoundingInfo: BoundingInfo;
  22882. /**
  22883. * @hidden Particle BoundingInfo object (Internal use)
  22884. */
  22885. _boundingInfo: BoundingInfo;
  22886. /**
  22887. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22888. */
  22889. _sps: SolidParticleSystem;
  22890. /**
  22891. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22892. */
  22893. _stillInvisible: boolean;
  22894. /**
  22895. * @hidden Last computed particle rotation matrix
  22896. */
  22897. _rotationMatrix: number[];
  22898. /**
  22899. * Parent particle Id, if any.
  22900. * Default null.
  22901. */
  22902. parentId: Nullable<number>;
  22903. /**
  22904. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22905. * The possible values are :
  22906. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22907. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22910. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22911. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22912. * */
  22913. cullingStrategy: number;
  22914. /**
  22915. * @hidden Internal global position in the SPS.
  22916. */
  22917. _globalPosition: Vector3;
  22918. /**
  22919. * Creates a Solid Particle object.
  22920. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22921. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22922. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22923. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22924. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22925. * @param shapeId (integer) is the model shape identifier in the SPS.
  22926. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22927. * @param sps defines the sps it is associated to
  22928. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22929. */
  22930. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22931. /**
  22932. * Legacy support, changed scale to scaling
  22933. */
  22934. /**
  22935. * Legacy support, changed scale to scaling
  22936. */
  22937. scale: Vector3;
  22938. /**
  22939. * Legacy support, changed quaternion to rotationQuaternion
  22940. */
  22941. /**
  22942. * Legacy support, changed quaternion to rotationQuaternion
  22943. */
  22944. quaternion: Nullable<Quaternion>;
  22945. /**
  22946. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22947. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22948. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22949. * @returns true if it intersects
  22950. */
  22951. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22952. /**
  22953. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22954. * A particle is in the frustum if its bounding box intersects the frustum
  22955. * @param frustumPlanes defines the frustum to test
  22956. * @returns true if the particle is in the frustum planes
  22957. */
  22958. isInFrustum(frustumPlanes: Plane[]): boolean;
  22959. /**
  22960. * get the rotation matrix of the particle
  22961. * @hidden
  22962. */
  22963. getRotationMatrix(m: Matrix): void;
  22964. }
  22965. /**
  22966. * Represents the shape of the model used by one particle of a solid particle system.
  22967. * SPS internal tool, don't use it manually.
  22968. */
  22969. export class ModelShape {
  22970. /**
  22971. * The shape id
  22972. * @hidden
  22973. */
  22974. shapeID: number;
  22975. /**
  22976. * flat array of model positions (internal use)
  22977. * @hidden
  22978. */
  22979. _shape: Vector3[];
  22980. /**
  22981. * flat array of model UVs (internal use)
  22982. * @hidden
  22983. */
  22984. _shapeUV: number[];
  22985. /**
  22986. * length of the shape in the model indices array (internal use)
  22987. * @hidden
  22988. */
  22989. _indicesLength: number;
  22990. /**
  22991. * Custom position function (internal use)
  22992. * @hidden
  22993. */
  22994. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22995. /**
  22996. * Custom vertex function (internal use)
  22997. * @hidden
  22998. */
  22999. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23000. /**
  23001. * 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.
  23002. * SPS internal tool, don't use it manually.
  23003. * @hidden
  23004. */
  23005. 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>);
  23006. }
  23007. /**
  23008. * Represents a Depth Sorted Particle in the solid particle system.
  23009. */
  23010. export class DepthSortedParticle {
  23011. /**
  23012. * Index of the particle in the "indices" array
  23013. */
  23014. ind: number;
  23015. /**
  23016. * Length of the particle shape in the "indices" array
  23017. */
  23018. indicesLength: number;
  23019. /**
  23020. * Squared distance from the particle to the camera
  23021. */
  23022. sqDistance: number;
  23023. }
  23024. }
  23025. declare module "babylonjs/Meshes/abstractMesh" {
  23026. import { Observable } from "babylonjs/Misc/observable";
  23027. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23028. import { Camera } from "babylonjs/Cameras/camera";
  23029. import { Scene, IDisposable } from "babylonjs/scene";
  23030. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23031. import { Node } from "babylonjs/node";
  23032. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23034. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23036. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23037. import { Material } from "babylonjs/Materials/material";
  23038. import { Light } from "babylonjs/Lights/light";
  23039. import { Skeleton } from "babylonjs/Bones/skeleton";
  23040. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23041. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23042. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23043. import { Ray } from "babylonjs/Culling/ray";
  23044. import { Collider } from "babylonjs/Collisions/collider";
  23045. /**
  23046. * Class used to store all common mesh properties
  23047. */
  23048. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23049. /** No occlusion */
  23050. static OCCLUSION_TYPE_NONE: number;
  23051. /** Occlusion set to optimisitic */
  23052. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23053. /** Occlusion set to strict */
  23054. static OCCLUSION_TYPE_STRICT: number;
  23055. /** Use an accurante occlusion algorithm */
  23056. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23057. /** Use a conservative occlusion algorithm */
  23058. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23059. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23060. * Test order :
  23061. * Is the bounding sphere outside the frustum ?
  23062. * If not, are the bounding box vertices outside the frustum ?
  23063. * It not, then the cullable object is in the frustum.
  23064. */
  23065. static readonly CULLINGSTRATEGY_STANDARD: number;
  23066. /** Culling strategy : Bounding Sphere Only.
  23067. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23068. * It's also less accurate than the standard because some not visible objects can still be selected.
  23069. * Test : is the bounding sphere outside the frustum ?
  23070. * If not, then the cullable object is in the frustum.
  23071. */
  23072. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23073. /** Culling strategy : Optimistic Inclusion.
  23074. * This in an inclusion test first, then the standard exclusion test.
  23075. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23076. * 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.
  23077. * Anyway, it's as accurate as the standard strategy.
  23078. * Test :
  23079. * Is the cullable object bounding sphere center in the frustum ?
  23080. * If not, apply the default culling strategy.
  23081. */
  23082. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23083. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23084. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23085. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23086. * 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.
  23087. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23088. * Test :
  23089. * Is the cullable object bounding sphere center in the frustum ?
  23090. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23091. */
  23092. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23093. /**
  23094. * No billboard
  23095. */
  23096. static readonly BILLBOARDMODE_NONE: number;
  23097. /** Billboard on X axis */
  23098. static readonly BILLBOARDMODE_X: number;
  23099. /** Billboard on Y axis */
  23100. static readonly BILLBOARDMODE_Y: number;
  23101. /** Billboard on Z axis */
  23102. static readonly BILLBOARDMODE_Z: number;
  23103. /** Billboard on all axes */
  23104. static readonly BILLBOARDMODE_ALL: number;
  23105. private _facetData;
  23106. /**
  23107. * The culling strategy to use to check whether the mesh must be rendered or not.
  23108. * This value can be changed at any time and will be used on the next render mesh selection.
  23109. * The possible values are :
  23110. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23111. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23114. * Please read each static variable documentation to get details about the culling process.
  23115. * */
  23116. cullingStrategy: number;
  23117. /**
  23118. * Gets the number of facets in the mesh
  23119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23120. */
  23121. readonly facetNb: number;
  23122. /**
  23123. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23125. */
  23126. partitioningSubdivisions: number;
  23127. /**
  23128. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23129. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23131. */
  23132. partitioningBBoxRatio: number;
  23133. /**
  23134. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23135. * Works only for updatable meshes.
  23136. * Doesn't work with multi-materials
  23137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23138. */
  23139. mustDepthSortFacets: boolean;
  23140. /**
  23141. * The location (Vector3) where the facet depth sort must be computed from.
  23142. * By default, the active camera position.
  23143. * Used only when facet depth sort is enabled
  23144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23145. */
  23146. facetDepthSortFrom: Vector3;
  23147. /**
  23148. * gets a boolean indicating if facetData is enabled
  23149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23150. */
  23151. readonly isFacetDataEnabled: boolean;
  23152. /** @hidden */
  23153. _updateNonUniformScalingState(value: boolean): boolean;
  23154. /**
  23155. * An event triggered when this mesh collides with another one
  23156. */
  23157. onCollideObservable: Observable<AbstractMesh>;
  23158. private _onCollideObserver;
  23159. /** Set a function to call when this mesh collides with another one */
  23160. onCollide: () => void;
  23161. /**
  23162. * An event triggered when the collision's position changes
  23163. */
  23164. onCollisionPositionChangeObservable: Observable<Vector3>;
  23165. private _onCollisionPositionChangeObserver;
  23166. /** Set a function to call when the collision's position changes */
  23167. onCollisionPositionChange: () => void;
  23168. /**
  23169. * An event triggered when material is changed
  23170. */
  23171. onMaterialChangedObservable: Observable<AbstractMesh>;
  23172. /**
  23173. * Gets or sets the orientation for POV movement & rotation
  23174. */
  23175. definedFacingForward: boolean;
  23176. /** @hidden */
  23177. _occlusionQuery: Nullable<WebGLQuery>;
  23178. private _visibility;
  23179. /**
  23180. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23181. */
  23182. /**
  23183. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23184. */
  23185. visibility: number;
  23186. /** Gets or sets the alpha index used to sort transparent meshes
  23187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23188. */
  23189. alphaIndex: number;
  23190. /**
  23191. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23192. */
  23193. isVisible: boolean;
  23194. /**
  23195. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23196. */
  23197. isPickable: boolean;
  23198. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23199. showSubMeshesBoundingBox: boolean;
  23200. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23201. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23202. */
  23203. isBlocker: boolean;
  23204. /**
  23205. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23206. */
  23207. enablePointerMoveEvents: boolean;
  23208. /**
  23209. * Specifies the rendering group id for this mesh (0 by default)
  23210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23211. */
  23212. renderingGroupId: number;
  23213. private _material;
  23214. /** Gets or sets current material */
  23215. material: Nullable<Material>;
  23216. private _receiveShadows;
  23217. /**
  23218. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23219. * @see http://doc.babylonjs.com/babylon101/shadows
  23220. */
  23221. receiveShadows: boolean;
  23222. /** Defines color to use when rendering outline */
  23223. outlineColor: Color3;
  23224. /** Define width to use when rendering outline */
  23225. outlineWidth: number;
  23226. /** Defines color to use when rendering overlay */
  23227. overlayColor: Color3;
  23228. /** Defines alpha to use when rendering overlay */
  23229. overlayAlpha: number;
  23230. private _hasVertexAlpha;
  23231. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23232. hasVertexAlpha: boolean;
  23233. private _useVertexColors;
  23234. /** 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) */
  23235. useVertexColors: boolean;
  23236. private _computeBonesUsingShaders;
  23237. /**
  23238. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23239. */
  23240. computeBonesUsingShaders: boolean;
  23241. private _numBoneInfluencers;
  23242. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23243. numBoneInfluencers: number;
  23244. private _applyFog;
  23245. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23246. applyFog: boolean;
  23247. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23248. useOctreeForRenderingSelection: boolean;
  23249. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23250. useOctreeForPicking: boolean;
  23251. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23252. useOctreeForCollisions: boolean;
  23253. private _layerMask;
  23254. /**
  23255. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23256. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23257. */
  23258. layerMask: number;
  23259. /**
  23260. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23261. */
  23262. alwaysSelectAsActiveMesh: boolean;
  23263. /**
  23264. * Gets or sets the current action manager
  23265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23266. */
  23267. actionManager: Nullable<AbstractActionManager>;
  23268. private _checkCollisions;
  23269. private _collisionMask;
  23270. private _collisionGroup;
  23271. /**
  23272. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23274. */
  23275. ellipsoid: Vector3;
  23276. /**
  23277. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23279. */
  23280. ellipsoidOffset: Vector3;
  23281. private _collider;
  23282. private _oldPositionForCollisions;
  23283. private _diffPositionForCollisions;
  23284. /**
  23285. * Gets or sets a collision mask used to mask collisions (default is -1).
  23286. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23287. */
  23288. collisionMask: number;
  23289. /**
  23290. * Gets or sets the current collision group mask (-1 by default).
  23291. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23292. */
  23293. collisionGroup: number;
  23294. /**
  23295. * Defines edge width used when edgesRenderer is enabled
  23296. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23297. */
  23298. edgesWidth: number;
  23299. /**
  23300. * Defines edge color used when edgesRenderer is enabled
  23301. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23302. */
  23303. edgesColor: Color4;
  23304. /** @hidden */
  23305. _edgesRenderer: Nullable<IEdgesRenderer>;
  23306. /** @hidden */
  23307. _masterMesh: Nullable<AbstractMesh>;
  23308. /** @hidden */
  23309. _boundingInfo: Nullable<BoundingInfo>;
  23310. /** @hidden */
  23311. _renderId: number;
  23312. /**
  23313. * Gets or sets the list of subMeshes
  23314. * @see http://doc.babylonjs.com/how_to/multi_materials
  23315. */
  23316. subMeshes: SubMesh[];
  23317. /** @hidden */
  23318. _intersectionsInProgress: AbstractMesh[];
  23319. /** @hidden */
  23320. _unIndexed: boolean;
  23321. /** @hidden */
  23322. _lightSources: Light[];
  23323. /** @hidden */
  23324. readonly _positions: Nullable<Vector3[]>;
  23325. /** @hidden */
  23326. _waitingActions: any;
  23327. /** @hidden */
  23328. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23329. private _skeleton;
  23330. /** @hidden */
  23331. _bonesTransformMatrices: Nullable<Float32Array>;
  23332. /**
  23333. * Gets or sets a skeleton to apply skining transformations
  23334. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23335. */
  23336. skeleton: Nullable<Skeleton>;
  23337. /**
  23338. * An event triggered when the mesh is rebuilt.
  23339. */
  23340. onRebuildObservable: Observable<AbstractMesh>;
  23341. /**
  23342. * Creates a new AbstractMesh
  23343. * @param name defines the name of the mesh
  23344. * @param scene defines the hosting scene
  23345. */
  23346. constructor(name: string, scene?: Nullable<Scene>);
  23347. /**
  23348. * Returns the string "AbstractMesh"
  23349. * @returns "AbstractMesh"
  23350. */
  23351. getClassName(): string;
  23352. /**
  23353. * Gets a string representation of the current mesh
  23354. * @param fullDetails defines a boolean indicating if full details must be included
  23355. * @returns a string representation of the current mesh
  23356. */
  23357. toString(fullDetails?: boolean): string;
  23358. /** @hidden */
  23359. _rebuild(): void;
  23360. /** @hidden */
  23361. _resyncLightSources(): void;
  23362. /** @hidden */
  23363. _resyncLighSource(light: Light): void;
  23364. /** @hidden */
  23365. _unBindEffect(): void;
  23366. /** @hidden */
  23367. _removeLightSource(light: Light): void;
  23368. private _markSubMeshesAsDirty;
  23369. /** @hidden */
  23370. _markSubMeshesAsLightDirty(): void;
  23371. /** @hidden */
  23372. _markSubMeshesAsAttributesDirty(): void;
  23373. /** @hidden */
  23374. _markSubMeshesAsMiscDirty(): void;
  23375. /**
  23376. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23377. */
  23378. scaling: Vector3;
  23379. /**
  23380. * Returns true if the mesh is blocked. Implemented by child classes
  23381. */
  23382. readonly isBlocked: boolean;
  23383. /**
  23384. * Returns the mesh itself by default. Implemented by child classes
  23385. * @param camera defines the camera to use to pick the right LOD level
  23386. * @returns the currentAbstractMesh
  23387. */
  23388. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23389. /**
  23390. * Returns 0 by default. Implemented by child classes
  23391. * @returns an integer
  23392. */
  23393. getTotalVertices(): number;
  23394. /**
  23395. * Returns a positive integer : the total number of indices in this mesh geometry.
  23396. * @returns the numner of indices or zero if the mesh has no geometry.
  23397. */
  23398. getTotalIndices(): number;
  23399. /**
  23400. * Returns null by default. Implemented by child classes
  23401. * @returns null
  23402. */
  23403. getIndices(): Nullable<IndicesArray>;
  23404. /**
  23405. * Returns the array of the requested vertex data kind. Implemented by child classes
  23406. * @param kind defines the vertex data kind to use
  23407. * @returns null
  23408. */
  23409. getVerticesData(kind: string): Nullable<FloatArray>;
  23410. /**
  23411. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23412. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23413. * Note that a new underlying VertexBuffer object is created each call.
  23414. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23415. * @param kind defines vertex data kind:
  23416. * * VertexBuffer.PositionKind
  23417. * * VertexBuffer.UVKind
  23418. * * VertexBuffer.UV2Kind
  23419. * * VertexBuffer.UV3Kind
  23420. * * VertexBuffer.UV4Kind
  23421. * * VertexBuffer.UV5Kind
  23422. * * VertexBuffer.UV6Kind
  23423. * * VertexBuffer.ColorKind
  23424. * * VertexBuffer.MatricesIndicesKind
  23425. * * VertexBuffer.MatricesIndicesExtraKind
  23426. * * VertexBuffer.MatricesWeightsKind
  23427. * * VertexBuffer.MatricesWeightsExtraKind
  23428. * @param data defines the data source
  23429. * @param updatable defines if the data must be flagged as updatable (or static)
  23430. * @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
  23431. * @returns the current mesh
  23432. */
  23433. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23434. /**
  23435. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23436. * If the mesh has no geometry, it is simply returned as it is.
  23437. * @param kind defines vertex data kind:
  23438. * * VertexBuffer.PositionKind
  23439. * * VertexBuffer.UVKind
  23440. * * VertexBuffer.UV2Kind
  23441. * * VertexBuffer.UV3Kind
  23442. * * VertexBuffer.UV4Kind
  23443. * * VertexBuffer.UV5Kind
  23444. * * VertexBuffer.UV6Kind
  23445. * * VertexBuffer.ColorKind
  23446. * * VertexBuffer.MatricesIndicesKind
  23447. * * VertexBuffer.MatricesIndicesExtraKind
  23448. * * VertexBuffer.MatricesWeightsKind
  23449. * * VertexBuffer.MatricesWeightsExtraKind
  23450. * @param data defines the data source
  23451. * @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
  23452. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23453. * @returns the current mesh
  23454. */
  23455. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23456. /**
  23457. * Sets the mesh indices,
  23458. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23459. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23460. * @param totalVertices Defines the total number of vertices
  23461. * @returns the current mesh
  23462. */
  23463. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23464. /**
  23465. * Gets a boolean indicating if specific vertex data is present
  23466. * @param kind defines the vertex data kind to use
  23467. * @returns true is data kind is present
  23468. */
  23469. isVerticesDataPresent(kind: string): boolean;
  23470. /**
  23471. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23472. * @returns a BoundingInfo
  23473. */
  23474. getBoundingInfo(): BoundingInfo;
  23475. /**
  23476. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23477. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23478. * @returns the current mesh
  23479. */
  23480. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23481. /**
  23482. * Overwrite the current bounding info
  23483. * @param boundingInfo defines the new bounding info
  23484. * @returns the current mesh
  23485. */
  23486. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23487. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23488. readonly useBones: boolean;
  23489. /** @hidden */
  23490. _preActivate(): void;
  23491. /** @hidden */
  23492. _preActivateForIntermediateRendering(renderId: number): void;
  23493. /** @hidden */
  23494. _activate(renderId: number): void;
  23495. /**
  23496. * Gets the current world matrix
  23497. * @returns a Matrix
  23498. */
  23499. getWorldMatrix(): Matrix;
  23500. /** @hidden */
  23501. _getWorldMatrixDeterminant(): number;
  23502. /**
  23503. * Perform relative position change from the point of view of behind the front of the mesh.
  23504. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23505. * Supports definition of mesh facing forward or backward
  23506. * @param amountRight defines the distance on the right axis
  23507. * @param amountUp defines the distance on the up axis
  23508. * @param amountForward defines the distance on the forward axis
  23509. * @returns the current mesh
  23510. */
  23511. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23512. /**
  23513. * Calculate relative position change from the point of view of behind the front of the mesh.
  23514. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23515. * Supports definition of mesh facing forward or backward
  23516. * @param amountRight defines the distance on the right axis
  23517. * @param amountUp defines the distance on the up axis
  23518. * @param amountForward defines the distance on the forward axis
  23519. * @returns the new displacement vector
  23520. */
  23521. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23522. /**
  23523. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23524. * Supports definition of mesh facing forward or backward
  23525. * @param flipBack defines the flip
  23526. * @param twirlClockwise defines the twirl
  23527. * @param tiltRight defines the tilt
  23528. * @returns the current mesh
  23529. */
  23530. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23531. /**
  23532. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23533. * Supports definition of mesh facing forward or backward.
  23534. * @param flipBack defines the flip
  23535. * @param twirlClockwise defines the twirl
  23536. * @param tiltRight defines the tilt
  23537. * @returns the new rotation vector
  23538. */
  23539. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23540. /**
  23541. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23542. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23543. * @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
  23544. * @returns the new bounding vectors
  23545. */
  23546. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23547. min: Vector3;
  23548. max: Vector3;
  23549. };
  23550. /**
  23551. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23552. * This means the mesh underlying bounding box and sphere are recomputed.
  23553. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23554. * @returns the current mesh
  23555. */
  23556. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23557. /** @hidden */
  23558. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23559. /** @hidden */
  23560. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23561. /** @hidden */
  23562. _updateBoundingInfo(): AbstractMesh;
  23563. /** @hidden */
  23564. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23565. /** @hidden */
  23566. protected _afterComputeWorldMatrix(): void;
  23567. /**
  23568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23569. * A mesh is in the frustum if its bounding box intersects the frustum
  23570. * @param frustumPlanes defines the frustum to test
  23571. * @returns true if the mesh is in the frustum planes
  23572. */
  23573. isInFrustum(frustumPlanes: Plane[]): boolean;
  23574. /**
  23575. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23576. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23577. * @param frustumPlanes defines the frustum to test
  23578. * @returns true if the mesh is completely in the frustum planes
  23579. */
  23580. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23581. /**
  23582. * True if the mesh intersects another mesh or a SolidParticle object
  23583. * @param mesh defines a target mesh or SolidParticle to test
  23584. * @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)
  23585. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23586. * @returns true if there is an intersection
  23587. */
  23588. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23589. /**
  23590. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23591. * @param point defines the point to test
  23592. * @returns true if there is an intersection
  23593. */
  23594. intersectsPoint(point: Vector3): boolean;
  23595. /**
  23596. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23598. */
  23599. checkCollisions: boolean;
  23600. /**
  23601. * Gets Collider object used to compute collisions (not physics)
  23602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23603. */
  23604. readonly collider: Collider;
  23605. /**
  23606. * Move the mesh using collision engine
  23607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23608. * @param displacement defines the requested displacement vector
  23609. * @returns the current mesh
  23610. */
  23611. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23612. private _onCollisionPositionChange;
  23613. /** @hidden */
  23614. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23615. /** @hidden */
  23616. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23617. /** @hidden */
  23618. _checkCollision(collider: Collider): AbstractMesh;
  23619. /** @hidden */
  23620. _generatePointsArray(): boolean;
  23621. /**
  23622. * Checks if the passed Ray intersects with the mesh
  23623. * @param ray defines the ray to use
  23624. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23625. * @returns the picking info
  23626. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23627. */
  23628. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23629. /**
  23630. * Clones the current mesh
  23631. * @param name defines the mesh name
  23632. * @param newParent defines the new mesh parent
  23633. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23634. * @returns the new mesh
  23635. */
  23636. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23637. /**
  23638. * Disposes all the submeshes of the current meshnp
  23639. * @returns the current mesh
  23640. */
  23641. releaseSubMeshes(): AbstractMesh;
  23642. /**
  23643. * Releases resources associated with this abstract mesh.
  23644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23646. */
  23647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23648. /**
  23649. * Adds the passed mesh as a child to the current mesh
  23650. * @param mesh defines the child mesh
  23651. * @returns the current mesh
  23652. */
  23653. addChild(mesh: AbstractMesh): AbstractMesh;
  23654. /**
  23655. * Removes the passed mesh from the current mesh children list
  23656. * @param mesh defines the child mesh
  23657. * @returns the current mesh
  23658. */
  23659. removeChild(mesh: AbstractMesh): AbstractMesh;
  23660. /** @hidden */
  23661. private _initFacetData;
  23662. /**
  23663. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23664. * This method can be called within the render loop.
  23665. * 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
  23666. * @returns the current mesh
  23667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23668. */
  23669. updateFacetData(): AbstractMesh;
  23670. /**
  23671. * Returns the facetLocalNormals array.
  23672. * The normals are expressed in the mesh local spac
  23673. * @returns an array of Vector3
  23674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23675. */
  23676. getFacetLocalNormals(): Vector3[];
  23677. /**
  23678. * Returns the facetLocalPositions array.
  23679. * The facet positions are expressed in the mesh local space
  23680. * @returns an array of Vector3
  23681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23682. */
  23683. getFacetLocalPositions(): Vector3[];
  23684. /**
  23685. * Returns the facetLocalPartioning array
  23686. * @returns an array of array of numbers
  23687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23688. */
  23689. getFacetLocalPartitioning(): number[][];
  23690. /**
  23691. * Returns the i-th facet position in the world system.
  23692. * This method allocates a new Vector3 per call
  23693. * @param i defines the facet index
  23694. * @returns a new Vector3
  23695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23696. */
  23697. getFacetPosition(i: number): Vector3;
  23698. /**
  23699. * Sets the reference Vector3 with the i-th facet position in the world system
  23700. * @param i defines the facet index
  23701. * @param ref defines the target vector
  23702. * @returns the current mesh
  23703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23704. */
  23705. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23706. /**
  23707. * Returns the i-th facet normal in the world system.
  23708. * This method allocates a new Vector3 per call
  23709. * @param i defines the facet index
  23710. * @returns a new Vector3
  23711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23712. */
  23713. getFacetNormal(i: number): Vector3;
  23714. /**
  23715. * Sets the reference Vector3 with the i-th facet normal in the world system
  23716. * @param i defines the facet index
  23717. * @param ref defines the target vector
  23718. * @returns the current mesh
  23719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23720. */
  23721. getFacetNormalToRef(i: number, ref: Vector3): this;
  23722. /**
  23723. * 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)
  23724. * @param x defines x coordinate
  23725. * @param y defines y coordinate
  23726. * @param z defines z coordinate
  23727. * @returns the array of facet indexes
  23728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23729. */
  23730. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23731. /**
  23732. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23733. * @param projected sets as the (x,y,z) world projection on the facet
  23734. * @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
  23735. * @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
  23736. * @param x defines x coordinate
  23737. * @param y defines y coordinate
  23738. * @param z defines z coordinate
  23739. * @returns the face index if found (or null instead)
  23740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23741. */
  23742. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23743. /**
  23744. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23745. * @param projected sets as the (x,y,z) local projection on the facet
  23746. * @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
  23747. * @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
  23748. * @param x defines x coordinate
  23749. * @param y defines y coordinate
  23750. * @param z defines z coordinate
  23751. * @returns the face index if found (or null instead)
  23752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23753. */
  23754. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23755. /**
  23756. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23757. * @returns the parameters
  23758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23759. */
  23760. getFacetDataParameters(): any;
  23761. /**
  23762. * Disables the feature FacetData and frees the related memory
  23763. * @returns the current mesh
  23764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23765. */
  23766. disableFacetData(): AbstractMesh;
  23767. /**
  23768. * Updates the AbstractMesh indices array
  23769. * @param indices defines the data source
  23770. * @returns the current mesh
  23771. */
  23772. updateIndices(indices: IndicesArray): AbstractMesh;
  23773. /**
  23774. * Creates new normals data for the mesh
  23775. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23776. * @returns the current mesh
  23777. */
  23778. createNormals(updatable: boolean): AbstractMesh;
  23779. /**
  23780. * Align the mesh with a normal
  23781. * @param normal defines the normal to use
  23782. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23783. * @returns the current mesh
  23784. */
  23785. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23786. /** @hidden */
  23787. _checkOcclusionQuery(): boolean;
  23788. }
  23789. }
  23790. declare module "babylonjs/Bones/skeleton" {
  23791. import { Bone } from "babylonjs/Bones/bone";
  23792. import { IAnimatable } from "babylonjs/Misc/tools";
  23793. import { Observable } from "babylonjs/Misc/observable";
  23794. import { Vector3, Matrix } from "babylonjs/Maths/math";
  23795. import { Scene } from "babylonjs/scene";
  23796. import { Nullable } from "babylonjs/types";
  23797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23798. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  23799. import { Animatable } from "babylonjs/Animations/animatable";
  23800. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23801. import { Animation } from "babylonjs/Animations/animation";
  23802. import { AnimationRange } from "babylonjs/Animations/animationRange";
  23803. /**
  23804. * Class used to handle skinning animations
  23805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23806. */
  23807. export class Skeleton implements IAnimatable {
  23808. /** defines the skeleton name */
  23809. name: string;
  23810. /** defines the skeleton Id */
  23811. id: string;
  23812. /**
  23813. * Defines the list of child bones
  23814. */
  23815. bones: Bone[];
  23816. /**
  23817. * Defines an estimate of the dimension of the skeleton at rest
  23818. */
  23819. dimensionsAtRest: Vector3;
  23820. /**
  23821. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23822. */
  23823. needInitialSkinMatrix: boolean;
  23824. /**
  23825. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23826. */
  23827. overrideMesh: Nullable<AbstractMesh>;
  23828. /**
  23829. * Gets the list of animations attached to this skeleton
  23830. */
  23831. animations: Array<Animation>;
  23832. private _scene;
  23833. private _isDirty;
  23834. private _transformMatrices;
  23835. private _transformMatrixTexture;
  23836. private _meshesWithPoseMatrix;
  23837. private _animatables;
  23838. private _identity;
  23839. private _synchronizedWithMesh;
  23840. private _ranges;
  23841. private _lastAbsoluteTransformsUpdateId;
  23842. private _canUseTextureForBones;
  23843. /** @hidden */
  23844. _numBonesWithLinkedTransformNode: number;
  23845. /**
  23846. * Specifies if the skeleton should be serialized
  23847. */
  23848. doNotSerialize: boolean;
  23849. /**
  23850. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23851. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23852. */
  23853. useTextureToStoreBoneMatrices: boolean;
  23854. private _animationPropertiesOverride;
  23855. /**
  23856. * Gets or sets the animation properties override
  23857. */
  23858. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23859. /**
  23860. * An observable triggered before computing the skeleton's matrices
  23861. */
  23862. onBeforeComputeObservable: Observable<Skeleton>;
  23863. /**
  23864. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23865. */
  23866. readonly isUsingTextureForMatrices: boolean;
  23867. /**
  23868. * Creates a new skeleton
  23869. * @param name defines the skeleton name
  23870. * @param id defines the skeleton Id
  23871. * @param scene defines the hosting scene
  23872. */
  23873. constructor(
  23874. /** defines the skeleton name */
  23875. name: string,
  23876. /** defines the skeleton Id */
  23877. id: string, scene: Scene);
  23878. /**
  23879. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23880. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23881. * @returns a Float32Array containing matrices data
  23882. */
  23883. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23884. /**
  23885. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23886. * @returns a raw texture containing the data
  23887. */
  23888. getTransformMatrixTexture(): Nullable<RawTexture>;
  23889. /**
  23890. * Gets the current hosting scene
  23891. * @returns a scene object
  23892. */
  23893. getScene(): Scene;
  23894. /**
  23895. * Gets a string representing the current skeleton data
  23896. * @param fullDetails defines a boolean indicating if we want a verbose version
  23897. * @returns a string representing the current skeleton data
  23898. */
  23899. toString(fullDetails?: boolean): string;
  23900. /**
  23901. * Get bone's index searching by name
  23902. * @param name defines bone's name to search for
  23903. * @return the indice of the bone. Returns -1 if not found
  23904. */
  23905. getBoneIndexByName(name: string): number;
  23906. /**
  23907. * Creater a new animation range
  23908. * @param name defines the name of the range
  23909. * @param from defines the start key
  23910. * @param to defines the end key
  23911. */
  23912. createAnimationRange(name: string, from: number, to: number): void;
  23913. /**
  23914. * Delete a specific animation range
  23915. * @param name defines the name of the range
  23916. * @param deleteFrames defines if frames must be removed as well
  23917. */
  23918. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23919. /**
  23920. * Gets a specific animation range
  23921. * @param name defines the name of the range to look for
  23922. * @returns the requested animation range or null if not found
  23923. */
  23924. getAnimationRange(name: string): Nullable<AnimationRange>;
  23925. /**
  23926. * Gets the list of all animation ranges defined on this skeleton
  23927. * @returns an array
  23928. */
  23929. getAnimationRanges(): Nullable<AnimationRange>[];
  23930. /**
  23931. * Copy animation range from a source skeleton.
  23932. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23933. * @param source defines the source skeleton
  23934. * @param name defines the name of the range to copy
  23935. * @param rescaleAsRequired defines if rescaling must be applied if required
  23936. * @returns true if operation was successful
  23937. */
  23938. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23939. /**
  23940. * Forces the skeleton to go to rest pose
  23941. */
  23942. returnToRest(): void;
  23943. private _getHighestAnimationFrame;
  23944. /**
  23945. * Begin a specific animation range
  23946. * @param name defines the name of the range to start
  23947. * @param loop defines if looping must be turned on (false by default)
  23948. * @param speedRatio defines the speed ratio to apply (1 by default)
  23949. * @param onAnimationEnd defines a callback which will be called when animation will end
  23950. * @returns a new animatable
  23951. */
  23952. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23953. /** @hidden */
  23954. _markAsDirty(): void;
  23955. /** @hidden */
  23956. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23957. /** @hidden */
  23958. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23959. private _computeTransformMatrices;
  23960. /**
  23961. * Build all resources required to render a skeleton
  23962. */
  23963. prepare(): void;
  23964. /**
  23965. * Gets the list of animatables currently running for this skeleton
  23966. * @returns an array of animatables
  23967. */
  23968. getAnimatables(): IAnimatable[];
  23969. /**
  23970. * Clone the current skeleton
  23971. * @param name defines the name of the new skeleton
  23972. * @param id defines the id of the enw skeleton
  23973. * @returns the new skeleton
  23974. */
  23975. clone(name: string, id: string): Skeleton;
  23976. /**
  23977. * Enable animation blending for this skeleton
  23978. * @param blendingSpeed defines the blending speed to apply
  23979. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23980. */
  23981. enableBlending(blendingSpeed?: number): void;
  23982. /**
  23983. * Releases all resources associated with the current skeleton
  23984. */
  23985. dispose(): void;
  23986. /**
  23987. * Serialize the skeleton in a JSON object
  23988. * @returns a JSON object
  23989. */
  23990. serialize(): any;
  23991. /**
  23992. * Creates a new skeleton from serialized data
  23993. * @param parsedSkeleton defines the serialized data
  23994. * @param scene defines the hosting scene
  23995. * @returns a new skeleton
  23996. */
  23997. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23998. /**
  23999. * Compute all node absolute transforms
  24000. * @param forceUpdate defines if computation must be done even if cache is up to date
  24001. */
  24002. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  24003. /**
  24004. * Gets the root pose matrix
  24005. * @returns a matrix
  24006. */
  24007. getPoseMatrix(): Nullable<Matrix>;
  24008. /**
  24009. * Sorts bones per internal index
  24010. */
  24011. sortBones(): void;
  24012. private _sortBones;
  24013. }
  24014. }
  24015. declare module "babylonjs/Bones/bone" {
  24016. import { Skeleton } from "babylonjs/Bones/skeleton";
  24017. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  24018. import { Nullable } from "babylonjs/types";
  24019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24021. import { Node } from "babylonjs/node";
  24022. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24023. /**
  24024. * Class used to store bone information
  24025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24026. */
  24027. export class Bone extends Node {
  24028. /**
  24029. * defines the bone name
  24030. */
  24031. name: string;
  24032. private static _tmpVecs;
  24033. private static _tmpQuat;
  24034. private static _tmpMats;
  24035. /**
  24036. * Gets the list of child bones
  24037. */
  24038. children: Bone[];
  24039. /** Gets the animations associated with this bone */
  24040. animations: import("babylonjs/Animations/animation").Animation[];
  24041. /**
  24042. * Gets or sets bone length
  24043. */
  24044. length: number;
  24045. /**
  24046. * @hidden Internal only
  24047. * Set this value to map this bone to a different index in the transform matrices
  24048. * Set this value to -1 to exclude the bone from the transform matrices
  24049. */
  24050. _index: Nullable<number>;
  24051. private _skeleton;
  24052. private _localMatrix;
  24053. private _restPose;
  24054. private _baseMatrix;
  24055. private _absoluteTransform;
  24056. private _invertedAbsoluteTransform;
  24057. private _parent;
  24058. private _scalingDeterminant;
  24059. private _worldTransform;
  24060. private _localScaling;
  24061. private _localRotation;
  24062. private _localPosition;
  24063. private _needToDecompose;
  24064. private _needToCompose;
  24065. /** @hidden */
  24066. _linkedTransformNode: Nullable<TransformNode>;
  24067. /** @hidden */
  24068. /** @hidden */
  24069. _matrix: Matrix;
  24070. /**
  24071. * Create a new bone
  24072. * @param name defines the bone name
  24073. * @param skeleton defines the parent skeleton
  24074. * @param parentBone defines the parent (can be null if the bone is the root)
  24075. * @param localMatrix defines the local matrix
  24076. * @param restPose defines the rest pose matrix
  24077. * @param baseMatrix defines the base matrix
  24078. * @param index defines index of the bone in the hiearchy
  24079. */
  24080. constructor(
  24081. /**
  24082. * defines the bone name
  24083. */
  24084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  24085. /**
  24086. * Gets the parent skeleton
  24087. * @returns a skeleton
  24088. */
  24089. getSkeleton(): Skeleton;
  24090. /**
  24091. * Gets parent bone
  24092. * @returns a bone or null if the bone is the root of the bone hierarchy
  24093. */
  24094. getParent(): Nullable<Bone>;
  24095. /**
  24096. * Sets the parent bone
  24097. * @param parent defines the parent (can be null if the bone is the root)
  24098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24099. */
  24100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  24101. /**
  24102. * Gets the local matrix
  24103. * @returns a matrix
  24104. */
  24105. getLocalMatrix(): Matrix;
  24106. /**
  24107. * Gets the base matrix (initial matrix which remains unchanged)
  24108. * @returns a matrix
  24109. */
  24110. getBaseMatrix(): Matrix;
  24111. /**
  24112. * Gets the rest pose matrix
  24113. * @returns a matrix
  24114. */
  24115. getRestPose(): Matrix;
  24116. /**
  24117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  24118. */
  24119. getWorldMatrix(): Matrix;
  24120. /**
  24121. * Sets the local matrix to rest pose matrix
  24122. */
  24123. returnToRest(): void;
  24124. /**
  24125. * Gets the inverse of the absolute transform matrix.
  24126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  24127. * @returns a matrix
  24128. */
  24129. getInvertedAbsoluteTransform(): Matrix;
  24130. /**
  24131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  24132. * @returns a matrix
  24133. */
  24134. getAbsoluteTransform(): Matrix;
  24135. /**
  24136. * Links with the given transform node.
  24137. * The local matrix of this bone is copied from the transform node every frame.
  24138. * @param transformNode defines the transform node to link to
  24139. */
  24140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  24141. /** Gets or sets current position (in local space) */
  24142. position: Vector3;
  24143. /** Gets or sets current rotation (in local space) */
  24144. rotation: Vector3;
  24145. /** Gets or sets current rotation quaternion (in local space) */
  24146. rotationQuaternion: Quaternion;
  24147. /** Gets or sets current scaling (in local space) */
  24148. scaling: Vector3;
  24149. /**
  24150. * Gets the animation properties override
  24151. */
  24152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24153. private _decompose;
  24154. private _compose;
  24155. /**
  24156. * Update the base and local matrices
  24157. * @param matrix defines the new base or local matrix
  24158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24159. * @param updateLocalMatrix defines if the local matrix should be updated
  24160. */
  24161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  24162. /** @hidden */
  24163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  24164. /**
  24165. * Flag the bone as dirty (Forcing it to update everything)
  24166. */
  24167. markAsDirty(): void;
  24168. private _markAsDirtyAndCompose;
  24169. private _markAsDirtyAndDecompose;
  24170. /**
  24171. * Translate the bone in local or world space
  24172. * @param vec The amount to translate the bone
  24173. * @param space The space that the translation is in
  24174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24175. */
  24176. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24177. /**
  24178. * Set the postion of the bone in local or world space
  24179. * @param position The position to set the bone
  24180. * @param space The space that the position is in
  24181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24182. */
  24183. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24184. /**
  24185. * Set the absolute position of the bone (world space)
  24186. * @param position The position to set the bone
  24187. * @param mesh The mesh that this bone is attached to
  24188. */
  24189. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  24190. /**
  24191. * Scale the bone on the x, y and z axes (in local space)
  24192. * @param x The amount to scale the bone on the x axis
  24193. * @param y The amount to scale the bone on the y axis
  24194. * @param z The amount to scale the bone on the z axis
  24195. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  24196. */
  24197. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  24198. /**
  24199. * Set the bone scaling in local space
  24200. * @param scale defines the scaling vector
  24201. */
  24202. setScale(scale: Vector3): void;
  24203. /**
  24204. * Gets the current scaling in local space
  24205. * @returns the current scaling vector
  24206. */
  24207. getScale(): Vector3;
  24208. /**
  24209. * Gets the current scaling in local space and stores it in a target vector
  24210. * @param result defines the target vector
  24211. */
  24212. getScaleToRef(result: Vector3): void;
  24213. /**
  24214. * Set the yaw, pitch, and roll of the bone in local or world space
  24215. * @param yaw The rotation of the bone on the y axis
  24216. * @param pitch The rotation of the bone on the x axis
  24217. * @param roll The rotation of the bone on the z axis
  24218. * @param space The space that the axes of rotation are in
  24219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24220. */
  24221. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  24222. /**
  24223. * Add a rotation to the bone on an axis in local or world space
  24224. * @param axis The axis to rotate the bone on
  24225. * @param amount The amount to rotate the bone
  24226. * @param space The space that the axis is in
  24227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24228. */
  24229. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  24230. /**
  24231. * Set the rotation of the bone to a particular axis angle in local or world space
  24232. * @param axis The axis to rotate the bone on
  24233. * @param angle The angle that the bone should be rotated to
  24234. * @param space The space that the axis is in
  24235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24236. */
  24237. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  24238. /**
  24239. * Set the euler rotation of the bone in local of world space
  24240. * @param rotation The euler rotation that the bone should be set to
  24241. * @param space The space that the rotation is in
  24242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24243. */
  24244. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24245. /**
  24246. * Set the quaternion rotation of the bone in local of world space
  24247. * @param quat The quaternion rotation that the bone should be set to
  24248. * @param space The space that the rotation is in
  24249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24250. */
  24251. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  24252. /**
  24253. * Set the rotation matrix of the bone in local of world space
  24254. * @param rotMat The rotation matrix that the bone should be set to
  24255. * @param space The space that the rotation is in
  24256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24257. */
  24258. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  24259. private _rotateWithMatrix;
  24260. private _getNegativeRotationToRef;
  24261. /**
  24262. * Get the position of the bone in local or world space
  24263. * @param space The space that the returned position is in
  24264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24265. * @returns The position of the bone
  24266. */
  24267. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24268. /**
  24269. * Copy the position of the bone to a vector3 in local or world space
  24270. * @param space The space that the returned position is in
  24271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24272. * @param result The vector3 to copy the position to
  24273. */
  24274. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  24275. /**
  24276. * Get the absolute position of the bone (world space)
  24277. * @param mesh The mesh that this bone is attached to
  24278. * @returns The absolute position of the bone
  24279. */
  24280. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  24281. /**
  24282. * Copy the absolute position of the bone (world space) to the result param
  24283. * @param mesh The mesh that this bone is attached to
  24284. * @param result The vector3 to copy the absolute position to
  24285. */
  24286. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  24287. /**
  24288. * Compute the absolute transforms of this bone and its children
  24289. */
  24290. computeAbsoluteTransforms(): void;
  24291. /**
  24292. * Get the world direction from an axis that is in the local space of the bone
  24293. * @param localAxis The local direction that is used to compute the world direction
  24294. * @param mesh The mesh that this bone is attached to
  24295. * @returns The world direction
  24296. */
  24297. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24298. /**
  24299. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  24300. * @param localAxis The local direction that is used to compute the world direction
  24301. * @param mesh The mesh that this bone is attached to
  24302. * @param result The vector3 that the world direction will be copied to
  24303. */
  24304. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24305. /**
  24306. * Get the euler rotation of the bone in local or world space
  24307. * @param space The space that the rotation should be in
  24308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24309. * @returns The euler rotation
  24310. */
  24311. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24312. /**
  24313. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  24314. * @param space The space that the rotation should be in
  24315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24316. * @param result The vector3 that the rotation should be copied to
  24317. */
  24318. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24319. /**
  24320. * Get the quaternion rotation of the bone in either local or world space
  24321. * @param space The space that the rotation should be in
  24322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24323. * @returns The quaternion rotation
  24324. */
  24325. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  24326. /**
  24327. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  24328. * @param space The space that the rotation should be in
  24329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24330. * @param result The quaternion that the rotation should be copied to
  24331. */
  24332. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  24333. /**
  24334. * Get the rotation matrix of the bone in local or world space
  24335. * @param space The space that the rotation should be in
  24336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24337. * @returns The rotation matrix
  24338. */
  24339. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  24340. /**
  24341. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  24342. * @param space The space that the rotation should be in
  24343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24344. * @param result The quaternion that the rotation should be copied to
  24345. */
  24346. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  24347. /**
  24348. * Get the world position of a point that is in the local space of the bone
  24349. * @param position The local position
  24350. * @param mesh The mesh that this bone is attached to
  24351. * @returns The world position
  24352. */
  24353. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24354. /**
  24355. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  24356. * @param position The local position
  24357. * @param mesh The mesh that this bone is attached to
  24358. * @param result The vector3 that the world position should be copied to
  24359. */
  24360. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24361. /**
  24362. * Get the local position of a point that is in world space
  24363. * @param position The world position
  24364. * @param mesh The mesh that this bone is attached to
  24365. * @returns The local position
  24366. */
  24367. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24368. /**
  24369. * Get the local position of a point that is in world space and copy it to the result param
  24370. * @param position The world position
  24371. * @param mesh The mesh that this bone is attached to
  24372. * @param result The vector3 that the local position should be copied to
  24373. */
  24374. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24375. }
  24376. }
  24377. declare module "babylonjs/Animations/animatable" {
  24378. import { Animation } from "babylonjs/Animations/animation";
  24379. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24380. import { Nullable } from "babylonjs/types";
  24381. import { Observable } from "babylonjs/Misc/observable";
  24382. import { Scene } from "babylonjs/scene";
  24383. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  24384. import { Node } from "babylonjs/node";
  24385. /**
  24386. * Class used to store an actual running animation
  24387. */
  24388. export class Animatable {
  24389. /** defines the target object */
  24390. target: any;
  24391. /** defines the starting frame number (default is 0) */
  24392. fromFrame: number;
  24393. /** defines the ending frame number (default is 100) */
  24394. toFrame: number;
  24395. /** defines if the animation must loop (default is false) */
  24396. loopAnimation: boolean;
  24397. /** defines a callback to call when animation ends if it is not looping */
  24398. onAnimationEnd?: (() => void) | null | undefined;
  24399. /** defines a callback to call when animation loops */
  24400. onAnimationLoop?: (() => void) | null | undefined;
  24401. private _localDelayOffset;
  24402. private _pausedDelay;
  24403. private _runtimeAnimations;
  24404. private _paused;
  24405. private _scene;
  24406. private _speedRatio;
  24407. private _weight;
  24408. private _syncRoot;
  24409. /**
  24410. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24411. * This will only apply for non looping animation (default is true)
  24412. */
  24413. disposeOnEnd: boolean;
  24414. /**
  24415. * Gets a boolean indicating if the animation has started
  24416. */
  24417. animationStarted: boolean;
  24418. /**
  24419. * Observer raised when the animation ends
  24420. */
  24421. onAnimationEndObservable: Observable<Animatable>;
  24422. /**
  24423. * Observer raised when the animation loops
  24424. */
  24425. onAnimationLoopObservable: Observable<Animatable>;
  24426. /**
  24427. * Gets the root Animatable used to synchronize and normalize animations
  24428. */
  24429. readonly syncRoot: Animatable;
  24430. /**
  24431. * Gets the current frame of the first RuntimeAnimation
  24432. * Used to synchronize Animatables
  24433. */
  24434. readonly masterFrame: number;
  24435. /**
  24436. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24437. */
  24438. weight: number;
  24439. /**
  24440. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24441. */
  24442. speedRatio: number;
  24443. /**
  24444. * Creates a new Animatable
  24445. * @param scene defines the hosting scene
  24446. * @param target defines the target object
  24447. * @param fromFrame defines the starting frame number (default is 0)
  24448. * @param toFrame defines the ending frame number (default is 100)
  24449. * @param loopAnimation defines if the animation must loop (default is false)
  24450. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24451. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24452. * @param animations defines a group of animation to add to the new Animatable
  24453. * @param onAnimationLoop defines a callback to call when animation loops
  24454. */
  24455. constructor(scene: Scene,
  24456. /** defines the target object */
  24457. target: any,
  24458. /** defines the starting frame number (default is 0) */
  24459. fromFrame?: number,
  24460. /** defines the ending frame number (default is 100) */
  24461. toFrame?: number,
  24462. /** defines if the animation must loop (default is false) */
  24463. loopAnimation?: boolean, speedRatio?: number,
  24464. /** defines a callback to call when animation ends if it is not looping */
  24465. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24466. /** defines a callback to call when animation loops */
  24467. onAnimationLoop?: (() => void) | null | undefined);
  24468. /**
  24469. * Synchronize and normalize current Animatable with a source Animatable
  24470. * This is useful when using animation weights and when animations are not of the same length
  24471. * @param root defines the root Animatable to synchronize with
  24472. * @returns the current Animatable
  24473. */
  24474. syncWith(root: Animatable): Animatable;
  24475. /**
  24476. * Gets the list of runtime animations
  24477. * @returns an array of RuntimeAnimation
  24478. */
  24479. getAnimations(): RuntimeAnimation[];
  24480. /**
  24481. * Adds more animations to the current animatable
  24482. * @param target defines the target of the animations
  24483. * @param animations defines the new animations to add
  24484. */
  24485. appendAnimations(target: any, animations: Animation[]): void;
  24486. /**
  24487. * Gets the source animation for a specific property
  24488. * @param property defines the propertyu to look for
  24489. * @returns null or the source animation for the given property
  24490. */
  24491. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24492. /**
  24493. * Gets the runtime animation for a specific property
  24494. * @param property defines the propertyu to look for
  24495. * @returns null or the runtime animation for the given property
  24496. */
  24497. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24498. /**
  24499. * Resets the animatable to its original state
  24500. */
  24501. reset(): void;
  24502. /**
  24503. * Allows the animatable to blend with current running animations
  24504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24505. * @param blendingSpeed defines the blending speed to use
  24506. */
  24507. enableBlending(blendingSpeed: number): void;
  24508. /**
  24509. * Disable animation blending
  24510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24511. */
  24512. disableBlending(): void;
  24513. /**
  24514. * Jump directly to a given frame
  24515. * @param frame defines the frame to jump to
  24516. */
  24517. goToFrame(frame: number): void;
  24518. /**
  24519. * Pause the animation
  24520. */
  24521. pause(): void;
  24522. /**
  24523. * Restart the animation
  24524. */
  24525. restart(): void;
  24526. private _raiseOnAnimationEnd;
  24527. /**
  24528. * Stop and delete the current animation
  24529. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24530. * @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)
  24531. */
  24532. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24533. /**
  24534. * Wait asynchronously for the animation to end
  24535. * @returns a promise which will be fullfilled when the animation ends
  24536. */
  24537. waitAsync(): Promise<Animatable>;
  24538. /** @hidden */
  24539. _animate(delay: number): boolean;
  24540. }
  24541. module "babylonjs/scene" {
  24542. interface Scene {
  24543. /** @hidden */
  24544. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24545. /** @hidden */
  24546. _processLateAnimationBindingsForMatrices(holder: {
  24547. totalWeight: number;
  24548. animations: RuntimeAnimation[];
  24549. originalValue: Matrix;
  24550. }): any;
  24551. /** @hidden */
  24552. _processLateAnimationBindingsForQuaternions(holder: {
  24553. totalWeight: number;
  24554. animations: RuntimeAnimation[];
  24555. originalValue: Quaternion;
  24556. }, refQuaternion: Quaternion): Quaternion;
  24557. /** @hidden */
  24558. _processLateAnimationBindings(): void;
  24559. /**
  24560. * Will start the animation sequence of a given target
  24561. * @param target defines the target
  24562. * @param from defines from which frame should animation start
  24563. * @param to defines until which frame should animation run.
  24564. * @param weight defines the weight to apply to the animation (1.0 by default)
  24565. * @param loop defines if the animation loops
  24566. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24567. * @param onAnimationEnd defines the function to be executed when the animation ends
  24568. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24569. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24570. * @param onAnimationLoop defines the callback to call when an animation loops
  24571. * @returns the animatable object created for this animation
  24572. */
  24573. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24574. /**
  24575. * Will start the animation sequence of a given target
  24576. * @param target defines the target
  24577. * @param from defines from which frame should animation start
  24578. * @param to defines until which frame should animation run.
  24579. * @param loop defines if the animation loops
  24580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24581. * @param onAnimationEnd defines the function to be executed when the animation ends
  24582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24583. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24584. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24585. * @param onAnimationLoop defines the callback to call when an animation loops
  24586. * @returns the animatable object created for this animation
  24587. */
  24588. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24589. /**
  24590. * Will start the animation sequence of a given target and its hierarchy
  24591. * @param target defines the target
  24592. * @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.
  24593. * @param from defines from which frame should animation start
  24594. * @param to defines until which frame should animation run.
  24595. * @param loop defines if the animation loops
  24596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24597. * @param onAnimationEnd defines the function to be executed when the animation ends
  24598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24599. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24600. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24601. * @param onAnimationLoop defines the callback to call when an animation loops
  24602. * @returns the list of created animatables
  24603. */
  24604. 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[];
  24605. /**
  24606. * Begin a new animation on a given node
  24607. * @param target defines the target where the animation will take place
  24608. * @param animations defines the list of animations to start
  24609. * @param from defines the initial value
  24610. * @param to defines the final value
  24611. * @param loop defines if you want animation to loop (off by default)
  24612. * @param speedRatio defines the speed ratio to apply to all animations
  24613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24614. * @param onAnimationLoop defines the callback to call when an animation loops
  24615. * @returns the list of created animatables
  24616. */
  24617. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24618. /**
  24619. * Begin a new animation on a given node and its hierarchy
  24620. * @param target defines the root node where the animation will take place
  24621. * @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.
  24622. * @param animations defines the list of animations to start
  24623. * @param from defines the initial value
  24624. * @param to defines the final value
  24625. * @param loop defines if you want animation to loop (off by default)
  24626. * @param speedRatio defines the speed ratio to apply to all animations
  24627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24628. * @param onAnimationLoop defines the callback to call when an animation loops
  24629. * @returns the list of animatables created for all nodes
  24630. */
  24631. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24632. /**
  24633. * Gets the animatable associated with a specific target
  24634. * @param target defines the target of the animatable
  24635. * @returns the required animatable if found
  24636. */
  24637. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24638. /**
  24639. * Gets all animatables associated with a given target
  24640. * @param target defines the target to look animatables for
  24641. * @returns an array of Animatables
  24642. */
  24643. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24644. /**
  24645. * Will stop the animation of the given target
  24646. * @param target - the target
  24647. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24648. * @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)
  24649. */
  24650. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24651. /**
  24652. * Stops and removes all animations that have been applied to the scene
  24653. */
  24654. stopAllAnimations(): void;
  24655. }
  24656. }
  24657. module "babylonjs/Bones/bone" {
  24658. interface Bone {
  24659. /**
  24660. * Copy an animation range from another bone
  24661. * @param source defines the source bone
  24662. * @param rangeName defines the range name to copy
  24663. * @param frameOffset defines the frame offset
  24664. * @param rescaleAsRequired defines if rescaling must be applied if required
  24665. * @param skelDimensionsRatio defines the scaling ratio
  24666. * @returns true if operation was successful
  24667. */
  24668. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24669. }
  24670. }
  24671. }
  24672. declare module "babylonjs/node" {
  24673. import { Scene } from "babylonjs/scene";
  24674. import { Nullable } from "babylonjs/types";
  24675. import { Matrix } from "babylonjs/Maths/math";
  24676. import { Engine } from "babylonjs/Engines/engine";
  24677. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24678. import { Observable } from "babylonjs/Misc/observable";
  24679. import { Animatable } from "babylonjs/Animations/animatable";
  24680. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24681. import { Animation } from "babylonjs/Animations/animation";
  24682. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24684. /**
  24685. * Defines how a node can be built from a string name.
  24686. */
  24687. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24688. /**
  24689. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24690. */
  24691. export class Node implements IBehaviorAware<Node> {
  24692. /** @hidden */
  24693. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24694. private static _NodeConstructors;
  24695. /**
  24696. * Add a new node constructor
  24697. * @param type defines the type name of the node to construct
  24698. * @param constructorFunc defines the constructor function
  24699. */
  24700. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24701. /**
  24702. * Returns a node constructor based on type name
  24703. * @param type defines the type name
  24704. * @param name defines the new node name
  24705. * @param scene defines the hosting scene
  24706. * @param options defines optional options to transmit to constructors
  24707. * @returns the new constructor or null
  24708. */
  24709. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24710. /**
  24711. * Gets or sets the name of the node
  24712. */
  24713. name: string;
  24714. /**
  24715. * Gets or sets the id of the node
  24716. */
  24717. id: string;
  24718. /**
  24719. * Gets or sets the unique id of the node
  24720. */
  24721. uniqueId: number;
  24722. /**
  24723. * Gets or sets a string used to store user defined state for the node
  24724. */
  24725. state: string;
  24726. /**
  24727. * Gets or sets an object used to store user defined information for the node
  24728. */
  24729. metadata: any;
  24730. /**
  24731. * For internal use only. Please do not use.
  24732. */
  24733. reservedDataStore: any;
  24734. /**
  24735. * Gets or sets a boolean used to define if the node must be serialized
  24736. */
  24737. doNotSerialize: boolean;
  24738. /** @hidden */
  24739. _isDisposed: boolean;
  24740. /**
  24741. * Gets a list of Animations associated with the node
  24742. */
  24743. animations: import("babylonjs/Animations/animation").Animation[];
  24744. protected _ranges: {
  24745. [name: string]: Nullable<AnimationRange>;
  24746. };
  24747. /**
  24748. * Callback raised when the node is ready to be used
  24749. */
  24750. onReady: (node: Node) => void;
  24751. private _isEnabled;
  24752. private _isParentEnabled;
  24753. private _isReady;
  24754. /** @hidden */
  24755. _currentRenderId: number;
  24756. private _parentRenderId;
  24757. protected _childRenderId: number;
  24758. /** @hidden */
  24759. _waitingParentId: Nullable<string>;
  24760. /** @hidden */
  24761. _scene: Scene;
  24762. /** @hidden */
  24763. _cache: any;
  24764. private _parentNode;
  24765. private _children;
  24766. /** @hidden */
  24767. _worldMatrix: Matrix;
  24768. /** @hidden */
  24769. _worldMatrixDeterminant: number;
  24770. /** @hidden */
  24771. private _sceneRootNodesIndex;
  24772. /**
  24773. * Gets a boolean indicating if the node has been disposed
  24774. * @returns true if the node was disposed
  24775. */
  24776. isDisposed(): boolean;
  24777. /**
  24778. * Gets or sets the parent of the node
  24779. */
  24780. parent: Nullable<Node>;
  24781. private addToSceneRootNodes;
  24782. private removeFromSceneRootNodes;
  24783. private _animationPropertiesOverride;
  24784. /**
  24785. * Gets or sets the animation properties override
  24786. */
  24787. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24788. /**
  24789. * Gets a string idenfifying the name of the class
  24790. * @returns "Node" string
  24791. */
  24792. getClassName(): string;
  24793. /** @hidden */
  24794. readonly _isNode: boolean;
  24795. /**
  24796. * An event triggered when the mesh is disposed
  24797. */
  24798. onDisposeObservable: Observable<Node>;
  24799. private _onDisposeObserver;
  24800. /**
  24801. * Sets a callback that will be raised when the node will be disposed
  24802. */
  24803. onDispose: () => void;
  24804. /**
  24805. * Creates a new Node
  24806. * @param name the name and id to be given to this node
  24807. * @param scene the scene this node will be added to
  24808. * @param addToRootNodes the node will be added to scene.rootNodes
  24809. */
  24810. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24811. /**
  24812. * Gets the scene of the node
  24813. * @returns a scene
  24814. */
  24815. getScene(): Scene;
  24816. /**
  24817. * Gets the engine of the node
  24818. * @returns a Engine
  24819. */
  24820. getEngine(): Engine;
  24821. private _behaviors;
  24822. /**
  24823. * Attach a behavior to the node
  24824. * @see http://doc.babylonjs.com/features/behaviour
  24825. * @param behavior defines the behavior to attach
  24826. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24827. * @returns the current Node
  24828. */
  24829. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24830. /**
  24831. * Remove an attached behavior
  24832. * @see http://doc.babylonjs.com/features/behaviour
  24833. * @param behavior defines the behavior to attach
  24834. * @returns the current Node
  24835. */
  24836. removeBehavior(behavior: Behavior<Node>): Node;
  24837. /**
  24838. * Gets the list of attached behaviors
  24839. * @see http://doc.babylonjs.com/features/behaviour
  24840. */
  24841. readonly behaviors: Behavior<Node>[];
  24842. /**
  24843. * Gets an attached behavior by name
  24844. * @param name defines the name of the behavior to look for
  24845. * @see http://doc.babylonjs.com/features/behaviour
  24846. * @returns null if behavior was not found else the requested behavior
  24847. */
  24848. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24849. /**
  24850. * Returns the latest update of the World matrix
  24851. * @returns a Matrix
  24852. */
  24853. getWorldMatrix(): Matrix;
  24854. /** @hidden */
  24855. _getWorldMatrixDeterminant(): number;
  24856. /**
  24857. * Returns directly the latest state of the mesh World matrix.
  24858. * A Matrix is returned.
  24859. */
  24860. readonly worldMatrixFromCache: Matrix;
  24861. /** @hidden */
  24862. _initCache(): void;
  24863. /** @hidden */
  24864. updateCache(force?: boolean): void;
  24865. /** @hidden */
  24866. _updateCache(ignoreParentClass?: boolean): void;
  24867. /** @hidden */
  24868. _isSynchronized(): boolean;
  24869. /** @hidden */
  24870. _markSyncedWithParent(): void;
  24871. /** @hidden */
  24872. isSynchronizedWithParent(): boolean;
  24873. /** @hidden */
  24874. isSynchronized(): boolean;
  24875. /**
  24876. * Is this node ready to be used/rendered
  24877. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24878. * @return true if the node is ready
  24879. */
  24880. isReady(completeCheck?: boolean): boolean;
  24881. /**
  24882. * Is this node enabled?
  24883. * 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
  24884. * @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
  24885. * @return whether this node (and its parent) is enabled
  24886. */
  24887. isEnabled(checkAncestors?: boolean): boolean;
  24888. /** @hidden */
  24889. protected _syncParentEnabledState(): void;
  24890. /**
  24891. * Set the enabled state of this node
  24892. * @param value defines the new enabled state
  24893. */
  24894. setEnabled(value: boolean): void;
  24895. /**
  24896. * Is this node a descendant of the given node?
  24897. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24898. * @param ancestor defines the parent node to inspect
  24899. * @returns a boolean indicating if this node is a descendant of the given node
  24900. */
  24901. isDescendantOf(ancestor: Node): boolean;
  24902. /** @hidden */
  24903. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24904. /**
  24905. * Will return all nodes that have this node as ascendant
  24906. * @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
  24907. * @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
  24908. * @return all children nodes of all types
  24909. */
  24910. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24911. /**
  24912. * Get all child-meshes of this node
  24913. * @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
  24914. * @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
  24915. * @returns an array of AbstractMesh
  24916. */
  24917. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24918. /**
  24919. * Get all direct children of this node
  24920. * @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
  24921. * @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)
  24922. * @returns an array of Node
  24923. */
  24924. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24925. /** @hidden */
  24926. _setReady(state: boolean): void;
  24927. /**
  24928. * Get an animation by name
  24929. * @param name defines the name of the animation to look for
  24930. * @returns null if not found else the requested animation
  24931. */
  24932. getAnimationByName(name: string): Nullable<Animation>;
  24933. /**
  24934. * Creates an animation range for this node
  24935. * @param name defines the name of the range
  24936. * @param from defines the starting key
  24937. * @param to defines the end key
  24938. */
  24939. createAnimationRange(name: string, from: number, to: number): void;
  24940. /**
  24941. * Delete a specific animation range
  24942. * @param name defines the name of the range to delete
  24943. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24944. */
  24945. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24946. /**
  24947. * Get an animation range by name
  24948. * @param name defines the name of the animation range to look for
  24949. * @returns null if not found else the requested animation range
  24950. */
  24951. getAnimationRange(name: string): Nullable<AnimationRange>;
  24952. /**
  24953. * Will start the animation sequence
  24954. * @param name defines the range frames for animation sequence
  24955. * @param loop defines if the animation should loop (false by default)
  24956. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24957. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24958. * @returns the object created for this animation. If range does not exist, it will return null
  24959. */
  24960. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24961. /**
  24962. * Serialize animation ranges into a JSON compatible object
  24963. * @returns serialization object
  24964. */
  24965. serializeAnimationRanges(): any;
  24966. /**
  24967. * Computes the world matrix of the node
  24968. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24969. * @returns the world matrix
  24970. */
  24971. computeWorldMatrix(force?: boolean): Matrix;
  24972. /**
  24973. * Releases resources associated with this node.
  24974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24976. */
  24977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24978. /**
  24979. * Parse animation range data from a serialization object and store them into a given node
  24980. * @param node defines where to store the animation ranges
  24981. * @param parsedNode defines the serialization object to read data from
  24982. * @param scene defines the hosting scene
  24983. */
  24984. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24985. }
  24986. }
  24987. declare module "babylonjs/Animations/animation" {
  24988. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24989. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24990. import { Nullable } from "babylonjs/types";
  24991. import { Scene } from "babylonjs/scene";
  24992. import { IAnimatable } from "babylonjs/Misc/tools";
  24993. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  24994. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24995. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  24996. import { Node } from "babylonjs/node";
  24997. import { Animatable } from "babylonjs/Animations/animatable";
  24998. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24999. /**
  25000. * Class used to store any kind of animation
  25001. */
  25002. export class Animation {
  25003. /**Name of the animation */
  25004. name: string;
  25005. /**Property to animate */
  25006. targetProperty: string;
  25007. /**The frames per second of the animation */
  25008. framePerSecond: number;
  25009. /**The data type of the animation */
  25010. dataType: number;
  25011. /**The loop mode of the animation */
  25012. loopMode?: number | undefined;
  25013. /**Specifies if blending should be enabled */
  25014. enableBlending?: boolean | undefined;
  25015. /**
  25016. * Use matrix interpolation instead of using direct key value when animating matrices
  25017. */
  25018. static AllowMatricesInterpolation: boolean;
  25019. /**
  25020. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25021. */
  25022. static AllowMatrixDecomposeForInterpolation: boolean;
  25023. /**
  25024. * Stores the key frames of the animation
  25025. */
  25026. private _keys;
  25027. /**
  25028. * Stores the easing function of the animation
  25029. */
  25030. private _easingFunction;
  25031. /**
  25032. * @hidden Internal use only
  25033. */
  25034. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25035. /**
  25036. * The set of event that will be linked to this animation
  25037. */
  25038. private _events;
  25039. /**
  25040. * Stores an array of target property paths
  25041. */
  25042. targetPropertyPath: string[];
  25043. /**
  25044. * Stores the blending speed of the animation
  25045. */
  25046. blendingSpeed: number;
  25047. /**
  25048. * Stores the animation ranges for the animation
  25049. */
  25050. private _ranges;
  25051. /**
  25052. * @hidden Internal use
  25053. */
  25054. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25055. /**
  25056. * Sets up an animation
  25057. * @param property The property to animate
  25058. * @param animationType The animation type to apply
  25059. * @param framePerSecond The frames per second of the animation
  25060. * @param easingFunction The easing function used in the animation
  25061. * @returns The created animation
  25062. */
  25063. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25064. /**
  25065. * Create and start an animation on a node
  25066. * @param name defines the name of the global animation that will be run on all nodes
  25067. * @param node defines the root node where the animation will take place
  25068. * @param targetProperty defines property to animate
  25069. * @param framePerSecond defines the number of frame per second yo use
  25070. * @param totalFrame defines the number of frames in total
  25071. * @param from defines the initial value
  25072. * @param to defines the final value
  25073. * @param loopMode defines which loop mode you want to use (off by default)
  25074. * @param easingFunction defines the easing function to use (linear by default)
  25075. * @param onAnimationEnd defines the callback to call when animation end
  25076. * @returns the animatable created for this animation
  25077. */
  25078. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25079. /**
  25080. * Create and start an animation on a node and its descendants
  25081. * @param name defines the name of the global animation that will be run on all nodes
  25082. * @param node defines the root node where the animation will take place
  25083. * @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
  25084. * @param targetProperty defines property to animate
  25085. * @param framePerSecond defines the number of frame per second to use
  25086. * @param totalFrame defines the number of frames in total
  25087. * @param from defines the initial value
  25088. * @param to defines the final value
  25089. * @param loopMode defines which loop mode you want to use (off by default)
  25090. * @param easingFunction defines the easing function to use (linear by default)
  25091. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25092. * @returns the list of animatables created for all nodes
  25093. * @example https://www.babylonjs-playground.com/#MH0VLI
  25094. */
  25095. 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[]>;
  25096. /**
  25097. * Creates a new animation, merges it with the existing animations and starts it
  25098. * @param name Name of the animation
  25099. * @param node Node which contains the scene that begins the animations
  25100. * @param targetProperty Specifies which property to animate
  25101. * @param framePerSecond The frames per second of the animation
  25102. * @param totalFrame The total number of frames
  25103. * @param from The frame at the beginning of the animation
  25104. * @param to The frame at the end of the animation
  25105. * @param loopMode Specifies the loop mode of the animation
  25106. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25107. * @param onAnimationEnd Callback to run once the animation is complete
  25108. * @returns Nullable animation
  25109. */
  25110. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25111. /**
  25112. * Transition property of an host to the target Value
  25113. * @param property The property to transition
  25114. * @param targetValue The target Value of the property
  25115. * @param host The object where the property to animate belongs
  25116. * @param scene Scene used to run the animation
  25117. * @param frameRate Framerate (in frame/s) to use
  25118. * @param transition The transition type we want to use
  25119. * @param duration The duration of the animation, in milliseconds
  25120. * @param onAnimationEnd Callback trigger at the end of the animation
  25121. * @returns Nullable animation
  25122. */
  25123. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25124. /**
  25125. * Return the array of runtime animations currently using this animation
  25126. */
  25127. readonly runtimeAnimations: RuntimeAnimation[];
  25128. /**
  25129. * Specifies if any of the runtime animations are currently running
  25130. */
  25131. readonly hasRunningRuntimeAnimations: boolean;
  25132. /**
  25133. * Initializes the animation
  25134. * @param name Name of the animation
  25135. * @param targetProperty Property to animate
  25136. * @param framePerSecond The frames per second of the animation
  25137. * @param dataType The data type of the animation
  25138. * @param loopMode The loop mode of the animation
  25139. * @param enableBlending Specifies if blending should be enabled
  25140. */
  25141. constructor(
  25142. /**Name of the animation */
  25143. name: string,
  25144. /**Property to animate */
  25145. targetProperty: string,
  25146. /**The frames per second of the animation */
  25147. framePerSecond: number,
  25148. /**The data type of the animation */
  25149. dataType: number,
  25150. /**The loop mode of the animation */
  25151. loopMode?: number | undefined,
  25152. /**Specifies if blending should be enabled */
  25153. enableBlending?: boolean | undefined);
  25154. /**
  25155. * Converts the animation to a string
  25156. * @param fullDetails support for multiple levels of logging within scene loading
  25157. * @returns String form of the animation
  25158. */
  25159. toString(fullDetails?: boolean): string;
  25160. /**
  25161. * Add an event to this animation
  25162. * @param event Event to add
  25163. */
  25164. addEvent(event: AnimationEvent): void;
  25165. /**
  25166. * Remove all events found at the given frame
  25167. * @param frame The frame to remove events from
  25168. */
  25169. removeEvents(frame: number): void;
  25170. /**
  25171. * Retrieves all the events from the animation
  25172. * @returns Events from the animation
  25173. */
  25174. getEvents(): AnimationEvent[];
  25175. /**
  25176. * Creates an animation range
  25177. * @param name Name of the animation range
  25178. * @param from Starting frame of the animation range
  25179. * @param to Ending frame of the animation
  25180. */
  25181. createRange(name: string, from: number, to: number): void;
  25182. /**
  25183. * Deletes an animation range by name
  25184. * @param name Name of the animation range to delete
  25185. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25186. */
  25187. deleteRange(name: string, deleteFrames?: boolean): void;
  25188. /**
  25189. * Gets the animation range by name, or null if not defined
  25190. * @param name Name of the animation range
  25191. * @returns Nullable animation range
  25192. */
  25193. getRange(name: string): Nullable<AnimationRange>;
  25194. /**
  25195. * Gets the key frames from the animation
  25196. * @returns The key frames of the animation
  25197. */
  25198. getKeys(): Array<IAnimationKey>;
  25199. /**
  25200. * Gets the highest frame rate of the animation
  25201. * @returns Highest frame rate of the animation
  25202. */
  25203. getHighestFrame(): number;
  25204. /**
  25205. * Gets the easing function of the animation
  25206. * @returns Easing function of the animation
  25207. */
  25208. getEasingFunction(): IEasingFunction;
  25209. /**
  25210. * Sets the easing function of the animation
  25211. * @param easingFunction A custom mathematical formula for animation
  25212. */
  25213. setEasingFunction(easingFunction: EasingFunction): void;
  25214. /**
  25215. * Interpolates a scalar linearly
  25216. * @param startValue Start value of the animation curve
  25217. * @param endValue End value of the animation curve
  25218. * @param gradient Scalar amount to interpolate
  25219. * @returns Interpolated scalar value
  25220. */
  25221. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25222. /**
  25223. * Interpolates a scalar cubically
  25224. * @param startValue Start value of the animation curve
  25225. * @param outTangent End tangent of the animation
  25226. * @param endValue End value of the animation curve
  25227. * @param inTangent Start tangent of the animation curve
  25228. * @param gradient Scalar amount to interpolate
  25229. * @returns Interpolated scalar value
  25230. */
  25231. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25232. /**
  25233. * Interpolates a quaternion using a spherical linear interpolation
  25234. * @param startValue Start value of the animation curve
  25235. * @param endValue End value of the animation curve
  25236. * @param gradient Scalar amount to interpolate
  25237. * @returns Interpolated quaternion value
  25238. */
  25239. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25240. /**
  25241. * Interpolates a quaternion cubically
  25242. * @param startValue Start value of the animation curve
  25243. * @param outTangent End tangent of the animation curve
  25244. * @param endValue End value of the animation curve
  25245. * @param inTangent Start tangent of the animation curve
  25246. * @param gradient Scalar amount to interpolate
  25247. * @returns Interpolated quaternion value
  25248. */
  25249. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25250. /**
  25251. * Interpolates a Vector3 linearl
  25252. * @param startValue Start value of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param gradient Scalar amount to interpolate
  25255. * @returns Interpolated scalar value
  25256. */
  25257. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25258. /**
  25259. * Interpolates a Vector3 cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation
  25262. * @param endValue End value of the animation curve
  25263. * @param inTangent Start tangent of the animation curve
  25264. * @param gradient Scalar amount to interpolate
  25265. * @returns InterpolatedVector3 value
  25266. */
  25267. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25268. /**
  25269. * Interpolates a Vector2 linearly
  25270. * @param startValue Start value of the animation curve
  25271. * @param endValue End value of the animation curve
  25272. * @param gradient Scalar amount to interpolate
  25273. * @returns Interpolated Vector2 value
  25274. */
  25275. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25276. /**
  25277. * Interpolates a Vector2 cubically
  25278. * @param startValue Start value of the animation curve
  25279. * @param outTangent End tangent of the animation
  25280. * @param endValue End value of the animation curve
  25281. * @param inTangent Start tangent of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns Interpolated Vector2 value
  25284. */
  25285. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25286. /**
  25287. * Interpolates a size linearly
  25288. * @param startValue Start value of the animation curve
  25289. * @param endValue End value of the animation curve
  25290. * @param gradient Scalar amount to interpolate
  25291. * @returns Interpolated Size value
  25292. */
  25293. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25294. /**
  25295. * Interpolates a Color3 linearly
  25296. * @param startValue Start value of the animation curve
  25297. * @param endValue End value of the animation curve
  25298. * @param gradient Scalar amount to interpolate
  25299. * @returns Interpolated Color3 value
  25300. */
  25301. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25302. /**
  25303. * @hidden Internal use only
  25304. */
  25305. _getKeyValue(value: any): any;
  25306. /**
  25307. * @hidden Internal use only
  25308. */
  25309. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25310. /**
  25311. * Defines the function to use to interpolate matrices
  25312. * @param startValue defines the start matrix
  25313. * @param endValue defines the end matrix
  25314. * @param gradient defines the gradient between both matrices
  25315. * @param result defines an optional target matrix where to store the interpolation
  25316. * @returns the interpolated matrix
  25317. */
  25318. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25319. /**
  25320. * Makes a copy of the animation
  25321. * @returns Cloned animation
  25322. */
  25323. clone(): Animation;
  25324. /**
  25325. * Sets the key frames of the animation
  25326. * @param values The animation key frames to set
  25327. */
  25328. setKeys(values: Array<IAnimationKey>): void;
  25329. /**
  25330. * Serializes the animation to an object
  25331. * @returns Serialized object
  25332. */
  25333. serialize(): any;
  25334. /**
  25335. * Float animation type
  25336. */
  25337. private static _ANIMATIONTYPE_FLOAT;
  25338. /**
  25339. * Vector3 animation type
  25340. */
  25341. private static _ANIMATIONTYPE_VECTOR3;
  25342. /**
  25343. * Quaternion animation type
  25344. */
  25345. private static _ANIMATIONTYPE_QUATERNION;
  25346. /**
  25347. * Matrix animation type
  25348. */
  25349. private static _ANIMATIONTYPE_MATRIX;
  25350. /**
  25351. * Color3 animation type
  25352. */
  25353. private static _ANIMATIONTYPE_COLOR3;
  25354. /**
  25355. * Vector2 animation type
  25356. */
  25357. private static _ANIMATIONTYPE_VECTOR2;
  25358. /**
  25359. * Size animation type
  25360. */
  25361. private static _ANIMATIONTYPE_SIZE;
  25362. /**
  25363. * Relative Loop Mode
  25364. */
  25365. private static _ANIMATIONLOOPMODE_RELATIVE;
  25366. /**
  25367. * Cycle Loop Mode
  25368. */
  25369. private static _ANIMATIONLOOPMODE_CYCLE;
  25370. /**
  25371. * Constant Loop Mode
  25372. */
  25373. private static _ANIMATIONLOOPMODE_CONSTANT;
  25374. /**
  25375. * Get the float animation type
  25376. */
  25377. static readonly ANIMATIONTYPE_FLOAT: number;
  25378. /**
  25379. * Get the Vector3 animation type
  25380. */
  25381. static readonly ANIMATIONTYPE_VECTOR3: number;
  25382. /**
  25383. * Get the Vector2 animation type
  25384. */
  25385. static readonly ANIMATIONTYPE_VECTOR2: number;
  25386. /**
  25387. * Get the Size animation type
  25388. */
  25389. static readonly ANIMATIONTYPE_SIZE: number;
  25390. /**
  25391. * Get the Quaternion animation type
  25392. */
  25393. static readonly ANIMATIONTYPE_QUATERNION: number;
  25394. /**
  25395. * Get the Matrix animation type
  25396. */
  25397. static readonly ANIMATIONTYPE_MATRIX: number;
  25398. /**
  25399. * Get the Color3 animation type
  25400. */
  25401. static readonly ANIMATIONTYPE_COLOR3: number;
  25402. /**
  25403. * Get the Relative Loop Mode
  25404. */
  25405. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25406. /**
  25407. * Get the Cycle Loop Mode
  25408. */
  25409. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25410. /**
  25411. * Get the Constant Loop Mode
  25412. */
  25413. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25414. /** @hidden */
  25415. static _UniversalLerp(left: any, right: any, amount: number): any;
  25416. /**
  25417. * Parses an animation object and creates an animation
  25418. * @param parsedAnimation Parsed animation object
  25419. * @returns Animation object
  25420. */
  25421. static Parse(parsedAnimation: any): Animation;
  25422. /**
  25423. * Appends the serialized animations from the source animations
  25424. * @param source Source containing the animations
  25425. * @param destination Target to store the animations
  25426. */
  25427. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25428. }
  25429. }
  25430. declare module "babylonjs/Materials/Textures/baseTexture" {
  25431. import { Observable } from "babylonjs/Misc/observable";
  25432. import { IAnimatable } from "babylonjs/Misc/tools";
  25433. import { Nullable } from "babylonjs/types";
  25434. import { Scene } from "babylonjs/scene";
  25435. import { Matrix, ISize } from "babylonjs/Maths/math";
  25436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25437. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25438. /**
  25439. * Base class of all the textures in babylon.
  25440. * It groups all the common properties the materials, post process, lights... might need
  25441. * in order to make a correct use of the texture.
  25442. */
  25443. export class BaseTexture implements IAnimatable {
  25444. /**
  25445. * Default anisotropic filtering level for the application.
  25446. * It is set to 4 as a good tradeoff between perf and quality.
  25447. */
  25448. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25449. /**
  25450. * Gets or sets the unique id of the texture
  25451. */
  25452. uniqueId: number;
  25453. /**
  25454. * Define the name of the texture.
  25455. */
  25456. name: string;
  25457. /**
  25458. * Gets or sets an object used to store user defined information.
  25459. */
  25460. metadata: any;
  25461. /**
  25462. * For internal use only. Please do not use.
  25463. */
  25464. reservedDataStore: any;
  25465. private _hasAlpha;
  25466. /**
  25467. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25468. */
  25469. hasAlpha: boolean;
  25470. /**
  25471. * Defines if the alpha value should be determined via the rgb values.
  25472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25473. */
  25474. getAlphaFromRGB: boolean;
  25475. /**
  25476. * Intensity or strength of the texture.
  25477. * It is commonly used by materials to fine tune the intensity of the texture
  25478. */
  25479. level: number;
  25480. /**
  25481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25482. * This is part of the texture as textures usually maps to one uv set.
  25483. */
  25484. coordinatesIndex: number;
  25485. private _coordinatesMode;
  25486. /**
  25487. * How a texture is mapped.
  25488. *
  25489. * | Value | Type | Description |
  25490. * | ----- | ----------------------------------- | ----------- |
  25491. * | 0 | EXPLICIT_MODE | |
  25492. * | 1 | SPHERICAL_MODE | |
  25493. * | 2 | PLANAR_MODE | |
  25494. * | 3 | CUBIC_MODE | |
  25495. * | 4 | PROJECTION_MODE | |
  25496. * | 5 | SKYBOX_MODE | |
  25497. * | 6 | INVCUBIC_MODE | |
  25498. * | 7 | EQUIRECTANGULAR_MODE | |
  25499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25501. */
  25502. coordinatesMode: number;
  25503. /**
  25504. * | Value | Type | Description |
  25505. * | ----- | ------------------ | ----------- |
  25506. * | 0 | CLAMP_ADDRESSMODE | |
  25507. * | 1 | WRAP_ADDRESSMODE | |
  25508. * | 2 | MIRROR_ADDRESSMODE | |
  25509. */
  25510. wrapU: number;
  25511. /**
  25512. * | Value | Type | Description |
  25513. * | ----- | ------------------ | ----------- |
  25514. * | 0 | CLAMP_ADDRESSMODE | |
  25515. * | 1 | WRAP_ADDRESSMODE | |
  25516. * | 2 | MIRROR_ADDRESSMODE | |
  25517. */
  25518. wrapV: number;
  25519. /**
  25520. * | Value | Type | Description |
  25521. * | ----- | ------------------ | ----------- |
  25522. * | 0 | CLAMP_ADDRESSMODE | |
  25523. * | 1 | WRAP_ADDRESSMODE | |
  25524. * | 2 | MIRROR_ADDRESSMODE | |
  25525. */
  25526. wrapR: number;
  25527. /**
  25528. * With compliant hardware and browser (supporting anisotropic filtering)
  25529. * this defines the level of anisotropic filtering in the texture.
  25530. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25531. */
  25532. anisotropicFilteringLevel: number;
  25533. /**
  25534. * Define if the texture is a cube texture or if false a 2d texture.
  25535. */
  25536. isCube: boolean;
  25537. /**
  25538. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25539. */
  25540. is3D: boolean;
  25541. /**
  25542. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25543. * HDR texture are usually stored in linear space.
  25544. * This only impacts the PBR and Background materials
  25545. */
  25546. gammaSpace: boolean;
  25547. /**
  25548. * Gets whether or not the texture contains RGBD data.
  25549. */
  25550. readonly isRGBD: boolean;
  25551. /**
  25552. * Is Z inverted in the texture (useful in a cube texture).
  25553. */
  25554. invertZ: boolean;
  25555. /**
  25556. * Are mip maps generated for this texture or not.
  25557. */
  25558. readonly noMipmap: boolean;
  25559. /**
  25560. * @hidden
  25561. */
  25562. lodLevelInAlpha: boolean;
  25563. /**
  25564. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25565. */
  25566. lodGenerationOffset: number;
  25567. /**
  25568. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25569. */
  25570. lodGenerationScale: number;
  25571. /**
  25572. * Define if the texture is a render target.
  25573. */
  25574. isRenderTarget: boolean;
  25575. /**
  25576. * Define the unique id of the texture in the scene.
  25577. */
  25578. readonly uid: string;
  25579. /**
  25580. * Return a string representation of the texture.
  25581. * @returns the texture as a string
  25582. */
  25583. toString(): string;
  25584. /**
  25585. * Get the class name of the texture.
  25586. * @returns "BaseTexture"
  25587. */
  25588. getClassName(): string;
  25589. /**
  25590. * Define the list of animation attached to the texture.
  25591. */
  25592. animations: import("babylonjs/Animations/animation").Animation[];
  25593. /**
  25594. * An event triggered when the texture is disposed.
  25595. */
  25596. onDisposeObservable: Observable<BaseTexture>;
  25597. private _onDisposeObserver;
  25598. /**
  25599. * Callback triggered when the texture has been disposed.
  25600. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25601. */
  25602. onDispose: () => void;
  25603. /**
  25604. * Define the current state of the loading sequence when in delayed load mode.
  25605. */
  25606. delayLoadState: number;
  25607. private _scene;
  25608. /** @hidden */
  25609. _texture: Nullable<InternalTexture>;
  25610. private _uid;
  25611. /**
  25612. * Define if the texture is preventinga material to render or not.
  25613. * If not and the texture is not ready, the engine will use a default black texture instead.
  25614. */
  25615. readonly isBlocking: boolean;
  25616. /**
  25617. * Instantiates a new BaseTexture.
  25618. * Base class of all the textures in babylon.
  25619. * It groups all the common properties the materials, post process, lights... might need
  25620. * in order to make a correct use of the texture.
  25621. * @param scene Define the scene the texture blongs to
  25622. */
  25623. constructor(scene: Nullable<Scene>);
  25624. /**
  25625. * Get the scene the texture belongs to.
  25626. * @returns the scene or null if undefined
  25627. */
  25628. getScene(): Nullable<Scene>;
  25629. /**
  25630. * Get the texture transform matrix used to offset tile the texture for istance.
  25631. * @returns the transformation matrix
  25632. */
  25633. getTextureMatrix(): Matrix;
  25634. /**
  25635. * Get the texture reflection matrix used to rotate/transform the reflection.
  25636. * @returns the reflection matrix
  25637. */
  25638. getReflectionTextureMatrix(): Matrix;
  25639. /**
  25640. * Get the underlying lower level texture from Babylon.
  25641. * @returns the insternal texture
  25642. */
  25643. getInternalTexture(): Nullable<InternalTexture>;
  25644. /**
  25645. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25646. * @returns true if ready or not blocking
  25647. */
  25648. isReadyOrNotBlocking(): boolean;
  25649. /**
  25650. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25651. * @returns true if fully ready
  25652. */
  25653. isReady(): boolean;
  25654. private _cachedSize;
  25655. /**
  25656. * Get the size of the texture.
  25657. * @returns the texture size.
  25658. */
  25659. getSize(): ISize;
  25660. /**
  25661. * Get the base size of the texture.
  25662. * It can be different from the size if the texture has been resized for POT for instance
  25663. * @returns the base size
  25664. */
  25665. getBaseSize(): ISize;
  25666. /**
  25667. * Update the sampling mode of the texture.
  25668. * Default is Trilinear mode.
  25669. *
  25670. * | Value | Type | Description |
  25671. * | ----- | ------------------ | ----------- |
  25672. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25673. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25674. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25675. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25676. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25677. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25678. * | 7 | NEAREST_LINEAR | |
  25679. * | 8 | NEAREST_NEAREST | |
  25680. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25681. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25682. * | 11 | LINEAR_LINEAR | |
  25683. * | 12 | LINEAR_NEAREST | |
  25684. *
  25685. * > _mag_: magnification filter (close to the viewer)
  25686. * > _min_: minification filter (far from the viewer)
  25687. * > _mip_: filter used between mip map levels
  25688. *@param samplingMode Define the new sampling mode of the texture
  25689. */
  25690. updateSamplingMode(samplingMode: number): void;
  25691. /**
  25692. * Scales the texture if is `canRescale()`
  25693. * @param ratio the resize factor we want to use to rescale
  25694. */
  25695. scale(ratio: number): void;
  25696. /**
  25697. * Get if the texture can rescale.
  25698. */
  25699. readonly canRescale: boolean;
  25700. /** @hidden */
  25701. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25702. /** @hidden */
  25703. _rebuild(): void;
  25704. /**
  25705. * Triggers the load sequence in delayed load mode.
  25706. */
  25707. delayLoad(): void;
  25708. /**
  25709. * Clones the texture.
  25710. * @returns the cloned texture
  25711. */
  25712. clone(): Nullable<BaseTexture>;
  25713. /**
  25714. * Get the texture underlying type (INT, FLOAT...)
  25715. */
  25716. readonly textureType: number;
  25717. /**
  25718. * Get the texture underlying format (RGB, RGBA...)
  25719. */
  25720. readonly textureFormat: number;
  25721. /**
  25722. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25723. * This will returns an RGBA array buffer containing either in values (0-255) or
  25724. * float values (0-1) depending of the underlying buffer type.
  25725. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25726. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25727. * @param buffer defines a user defined buffer to fill with data (can be null)
  25728. * @returns The Array buffer containing the pixels data.
  25729. */
  25730. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25731. /**
  25732. * Release and destroy the underlying lower level texture aka internalTexture.
  25733. */
  25734. releaseInternalTexture(): void;
  25735. /**
  25736. * Get the polynomial representation of the texture data.
  25737. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25738. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25739. */
  25740. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25741. /** @hidden */
  25742. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25743. /** @hidden */
  25744. readonly _lodTextureMid: Nullable<BaseTexture>;
  25745. /** @hidden */
  25746. readonly _lodTextureLow: Nullable<BaseTexture>;
  25747. /**
  25748. * Dispose the texture and release its associated resources.
  25749. */
  25750. dispose(): void;
  25751. /**
  25752. * Serialize the texture into a JSON representation that can be parsed later on.
  25753. * @returns the JSON representation of the texture
  25754. */
  25755. serialize(): any;
  25756. /**
  25757. * Helper function to be called back once a list of texture contains only ready textures.
  25758. * @param textures Define the list of textures to wait for
  25759. * @param callback Define the callback triggered once the entire list will be ready
  25760. */
  25761. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25762. }
  25763. }
  25764. declare module "babylonjs/Materials/uniformBuffer" {
  25765. import { Nullable, FloatArray } from "babylonjs/types";
  25766. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25767. import { Engine } from "babylonjs/Engines/engine";
  25768. import { Effect } from "babylonjs/Materials/effect";
  25769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25770. /**
  25771. * Uniform buffer objects.
  25772. *
  25773. * Handles blocks of uniform on the GPU.
  25774. *
  25775. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25776. *
  25777. * For more information, please refer to :
  25778. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25779. */
  25780. export class UniformBuffer {
  25781. private _engine;
  25782. private _buffer;
  25783. private _data;
  25784. private _bufferData;
  25785. private _dynamic?;
  25786. private _uniformLocations;
  25787. private _uniformSizes;
  25788. private _uniformLocationPointer;
  25789. private _needSync;
  25790. private _noUBO;
  25791. private _currentEffect;
  25792. private static _MAX_UNIFORM_SIZE;
  25793. private static _tempBuffer;
  25794. /**
  25795. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25796. * This is dynamic to allow compat with webgl 1 and 2.
  25797. * You will need to pass the name of the uniform as well as the value.
  25798. */
  25799. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25800. /**
  25801. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25802. * This is dynamic to allow compat with webgl 1 and 2.
  25803. * You will need to pass the name of the uniform as well as the value.
  25804. */
  25805. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25806. /**
  25807. * Lambda to Update a single float in a uniform buffer.
  25808. * This is dynamic to allow compat with webgl 1 and 2.
  25809. * You will need to pass the name of the uniform as well as the value.
  25810. */
  25811. updateFloat: (name: string, x: number) => void;
  25812. /**
  25813. * Lambda to Update a vec2 of float in a uniform buffer.
  25814. * This is dynamic to allow compat with webgl 1 and 2.
  25815. * You will need to pass the name of the uniform as well as the value.
  25816. */
  25817. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25818. /**
  25819. * Lambda to Update a vec3 of float in a uniform buffer.
  25820. * This is dynamic to allow compat with webgl 1 and 2.
  25821. * You will need to pass the name of the uniform as well as the value.
  25822. */
  25823. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25824. /**
  25825. * Lambda to Update a vec4 of float in a uniform buffer.
  25826. * This is dynamic to allow compat with webgl 1 and 2.
  25827. * You will need to pass the name of the uniform as well as the value.
  25828. */
  25829. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25830. /**
  25831. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25832. * This is dynamic to allow compat with webgl 1 and 2.
  25833. * You will need to pass the name of the uniform as well as the value.
  25834. */
  25835. updateMatrix: (name: string, mat: Matrix) => void;
  25836. /**
  25837. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25838. * This is dynamic to allow compat with webgl 1 and 2.
  25839. * You will need to pass the name of the uniform as well as the value.
  25840. */
  25841. updateVector3: (name: string, vector: Vector3) => void;
  25842. /**
  25843. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25844. * This is dynamic to allow compat with webgl 1 and 2.
  25845. * You will need to pass the name of the uniform as well as the value.
  25846. */
  25847. updateVector4: (name: string, vector: Vector4) => void;
  25848. /**
  25849. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25850. * This is dynamic to allow compat with webgl 1 and 2.
  25851. * You will need to pass the name of the uniform as well as the value.
  25852. */
  25853. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25854. /**
  25855. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25856. * This is dynamic to allow compat with webgl 1 and 2.
  25857. * You will need to pass the name of the uniform as well as the value.
  25858. */
  25859. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25860. /**
  25861. * Instantiates a new Uniform buffer objects.
  25862. *
  25863. * Handles blocks of uniform on the GPU.
  25864. *
  25865. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25866. *
  25867. * For more information, please refer to :
  25868. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25869. * @param engine Define the engine the buffer is associated with
  25870. * @param data Define the data contained in the buffer
  25871. * @param dynamic Define if the buffer is updatable
  25872. */
  25873. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25874. /**
  25875. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25876. * or just falling back on setUniformXXX calls.
  25877. */
  25878. readonly useUbo: boolean;
  25879. /**
  25880. * Indicates if the WebGL underlying uniform buffer is in sync
  25881. * with the javascript cache data.
  25882. */
  25883. readonly isSync: boolean;
  25884. /**
  25885. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25886. * Also, a dynamic UniformBuffer will disable cache verification and always
  25887. * update the underlying WebGL uniform buffer to the GPU.
  25888. * @returns if Dynamic, otherwise false
  25889. */
  25890. isDynamic(): boolean;
  25891. /**
  25892. * The data cache on JS side.
  25893. * @returns the underlying data as a float array
  25894. */
  25895. getData(): Float32Array;
  25896. /**
  25897. * The underlying WebGL Uniform buffer.
  25898. * @returns the webgl buffer
  25899. */
  25900. getBuffer(): Nullable<WebGLBuffer>;
  25901. /**
  25902. * std140 layout specifies how to align data within an UBO structure.
  25903. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25904. * for specs.
  25905. */
  25906. private _fillAlignment;
  25907. /**
  25908. * Adds an uniform in the buffer.
  25909. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25910. * for the layout to be correct !
  25911. * @param name Name of the uniform, as used in the uniform block in the shader.
  25912. * @param size Data size, or data directly.
  25913. */
  25914. addUniform(name: string, size: number | number[]): void;
  25915. /**
  25916. * Adds a Matrix 4x4 to the uniform buffer.
  25917. * @param name Name of the uniform, as used in the uniform block in the shader.
  25918. * @param mat A 4x4 matrix.
  25919. */
  25920. addMatrix(name: string, mat: Matrix): void;
  25921. /**
  25922. * Adds a vec2 to the uniform buffer.
  25923. * @param name Name of the uniform, as used in the uniform block in the shader.
  25924. * @param x Define the x component value of the vec2
  25925. * @param y Define the y component value of the vec2
  25926. */
  25927. addFloat2(name: string, x: number, y: number): void;
  25928. /**
  25929. * Adds a vec3 to the uniform buffer.
  25930. * @param name Name of the uniform, as used in the uniform block in the shader.
  25931. * @param x Define the x component value of the vec3
  25932. * @param y Define the y component value of the vec3
  25933. * @param z Define the z component value of the vec3
  25934. */
  25935. addFloat3(name: string, x: number, y: number, z: number): void;
  25936. /**
  25937. * Adds a vec3 to the uniform buffer.
  25938. * @param name Name of the uniform, as used in the uniform block in the shader.
  25939. * @param color Define the vec3 from a Color
  25940. */
  25941. addColor3(name: string, color: Color3): void;
  25942. /**
  25943. * Adds a vec4 to the uniform buffer.
  25944. * @param name Name of the uniform, as used in the uniform block in the shader.
  25945. * @param color Define the rgb components from a Color
  25946. * @param alpha Define the a component of the vec4
  25947. */
  25948. addColor4(name: string, color: Color3, alpha: number): void;
  25949. /**
  25950. * Adds a vec3 to the uniform buffer.
  25951. * @param name Name of the uniform, as used in the uniform block in the shader.
  25952. * @param vector Define the vec3 components from a Vector
  25953. */
  25954. addVector3(name: string, vector: Vector3): void;
  25955. /**
  25956. * Adds a Matrix 3x3 to the uniform buffer.
  25957. * @param name Name of the uniform, as used in the uniform block in the shader.
  25958. */
  25959. addMatrix3x3(name: string): void;
  25960. /**
  25961. * Adds a Matrix 2x2 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. */
  25964. addMatrix2x2(name: string): void;
  25965. /**
  25966. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25967. */
  25968. create(): void;
  25969. /** @hidden */
  25970. _rebuild(): void;
  25971. /**
  25972. * Updates the WebGL Uniform Buffer on the GPU.
  25973. * If the `dynamic` flag is set to true, no cache comparison is done.
  25974. * Otherwise, the buffer will be updated only if the cache differs.
  25975. */
  25976. update(): void;
  25977. /**
  25978. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25979. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25980. * @param data Define the flattened data
  25981. * @param size Define the size of the data.
  25982. */
  25983. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25984. private _updateMatrix3x3ForUniform;
  25985. private _updateMatrix3x3ForEffect;
  25986. private _updateMatrix2x2ForEffect;
  25987. private _updateMatrix2x2ForUniform;
  25988. private _updateFloatForEffect;
  25989. private _updateFloatForUniform;
  25990. private _updateFloat2ForEffect;
  25991. private _updateFloat2ForUniform;
  25992. private _updateFloat3ForEffect;
  25993. private _updateFloat3ForUniform;
  25994. private _updateFloat4ForEffect;
  25995. private _updateFloat4ForUniform;
  25996. private _updateMatrixForEffect;
  25997. private _updateMatrixForUniform;
  25998. private _updateVector3ForEffect;
  25999. private _updateVector3ForUniform;
  26000. private _updateVector4ForEffect;
  26001. private _updateVector4ForUniform;
  26002. private _updateColor3ForEffect;
  26003. private _updateColor3ForUniform;
  26004. private _updateColor4ForEffect;
  26005. private _updateColor4ForUniform;
  26006. /**
  26007. * Sets a sampler uniform on the effect.
  26008. * @param name Define the name of the sampler.
  26009. * @param texture Define the texture to set in the sampler
  26010. */
  26011. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26012. /**
  26013. * Directly updates the value of the uniform in the cache AND on the GPU.
  26014. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26015. * @param data Define the flattened data
  26016. */
  26017. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26018. /**
  26019. * Binds this uniform buffer to an effect.
  26020. * @param effect Define the effect to bind the buffer to
  26021. * @param name Name of the uniform block in the shader.
  26022. */
  26023. bindToEffect(effect: Effect, name: string): void;
  26024. /**
  26025. * Disposes the uniform buffer.
  26026. */
  26027. dispose(): void;
  26028. }
  26029. }
  26030. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26031. import { Nullable } from "babylonjs/types";
  26032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26033. /**
  26034. * This represents the required contract to create a new type of texture loader.
  26035. */
  26036. export interface IInternalTextureLoader {
  26037. /**
  26038. * Defines wether the loader supports cascade loading the different faces.
  26039. */
  26040. supportCascades: boolean;
  26041. /**
  26042. * This returns if the loader support the current file information.
  26043. * @param extension defines the file extension of the file being loaded
  26044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26045. * @param fallback defines the fallback internal texture if any
  26046. * @param isBase64 defines whether the texture is encoded as a base64
  26047. * @param isBuffer defines whether the texture data are stored as a buffer
  26048. * @returns true if the loader can load the specified file
  26049. */
  26050. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26051. /**
  26052. * Transform the url before loading if required.
  26053. * @param rootUrl the url of the texture
  26054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26055. * @returns the transformed texture
  26056. */
  26057. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26058. /**
  26059. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26060. * @param rootUrl the url of the texture
  26061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26062. * @returns the fallback texture
  26063. */
  26064. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26065. /**
  26066. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26067. * @param data contains the texture data
  26068. * @param texture defines the BabylonJS internal texture
  26069. * @param createPolynomials will be true if polynomials have been requested
  26070. * @param onLoad defines the callback to trigger once the texture is ready
  26071. * @param onError defines the callback to trigger in case of error
  26072. */
  26073. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26074. /**
  26075. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26076. * @param data contains the texture data
  26077. * @param texture defines the BabylonJS internal texture
  26078. * @param callback defines the method to call once ready to upload
  26079. */
  26080. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26081. }
  26082. }
  26083. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26084. import { Scene } from "babylonjs/scene";
  26085. import { Engine } from "babylonjs/Engines/engine";
  26086. import { Texture } from "babylonjs/Materials/Textures/texture";
  26087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26088. /**
  26089. * Creation options of the multi render target texture.
  26090. */
  26091. export interface IMultiRenderTargetOptions {
  26092. /**
  26093. * Define if the texture needs to create mip maps after render.
  26094. */
  26095. generateMipMaps?: boolean;
  26096. /**
  26097. * Define the types of all the draw buffers we want to create
  26098. */
  26099. types?: number[];
  26100. /**
  26101. * Define the sampling modes of all the draw buffers we want to create
  26102. */
  26103. samplingModes?: number[];
  26104. /**
  26105. * Define if a depth buffer is required
  26106. */
  26107. generateDepthBuffer?: boolean;
  26108. /**
  26109. * Define if a stencil buffer is required
  26110. */
  26111. generateStencilBuffer?: boolean;
  26112. /**
  26113. * Define if a depth texture is required instead of a depth buffer
  26114. */
  26115. generateDepthTexture?: boolean;
  26116. /**
  26117. * Define the number of desired draw buffers
  26118. */
  26119. textureCount?: number;
  26120. /**
  26121. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26122. */
  26123. doNotChangeAspectRatio?: boolean;
  26124. /**
  26125. * Define the default type of the buffers we are creating
  26126. */
  26127. defaultType?: number;
  26128. }
  26129. /**
  26130. * A multi render target, like a render target provides the ability to render to a texture.
  26131. * Unlike the render target, it can render to several draw buffers in one draw.
  26132. * This is specially interesting in deferred rendering or for any effects requiring more than
  26133. * just one color from a single pass.
  26134. */
  26135. export class MultiRenderTarget extends RenderTargetTexture {
  26136. private _internalTextures;
  26137. private _textures;
  26138. private _multiRenderTargetOptions;
  26139. /**
  26140. * Get if draw buffers are currently supported by the used hardware and browser.
  26141. */
  26142. readonly isSupported: boolean;
  26143. /**
  26144. * Get the list of textures generated by the multi render target.
  26145. */
  26146. readonly textures: Texture[];
  26147. /**
  26148. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26149. */
  26150. readonly depthTexture: Texture;
  26151. /**
  26152. * Set the wrapping mode on U of all the textures we are rendering to.
  26153. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26154. */
  26155. wrapU: number;
  26156. /**
  26157. * Set the wrapping mode on V of all the textures we are rendering to.
  26158. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26159. */
  26160. wrapV: number;
  26161. /**
  26162. * Instantiate a new multi render target texture.
  26163. * A multi render target, like a render target provides the ability to render to a texture.
  26164. * Unlike the render target, it can render to several draw buffers in one draw.
  26165. * This is specially interesting in deferred rendering or for any effects requiring more than
  26166. * just one color from a single pass.
  26167. * @param name Define the name of the texture
  26168. * @param size Define the size of the buffers to render to
  26169. * @param count Define the number of target we are rendering into
  26170. * @param scene Define the scene the texture belongs to
  26171. * @param options Define the options used to create the multi render target
  26172. */
  26173. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. private _createInternalTextures;
  26177. private _createTextures;
  26178. /**
  26179. * Define the number of samples used if MSAA is enabled.
  26180. */
  26181. samples: number;
  26182. /**
  26183. * Resize all the textures in the multi render target.
  26184. * Be carrefull as it will recreate all the data in the new texture.
  26185. * @param size Define the new size
  26186. */
  26187. resize(size: any): void;
  26188. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26189. /**
  26190. * Dispose the render targets and their associated resources
  26191. */
  26192. dispose(): void;
  26193. /**
  26194. * Release all the underlying texture used as draw buffers.
  26195. */
  26196. releaseInternalTextures(): void;
  26197. }
  26198. }
  26199. declare module "babylonjs/Audio/analyser" {
  26200. import { Scene } from "babylonjs/scene";
  26201. /**
  26202. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26204. */
  26205. export class Analyser {
  26206. /**
  26207. * Gets or sets the smoothing
  26208. * @ignorenaming
  26209. */
  26210. SMOOTHING: number;
  26211. /**
  26212. * Gets or sets the FFT table size
  26213. * @ignorenaming
  26214. */
  26215. FFT_SIZE: number;
  26216. /**
  26217. * Gets or sets the bar graph amplitude
  26218. * @ignorenaming
  26219. */
  26220. BARGRAPHAMPLITUDE: number;
  26221. /**
  26222. * Gets or sets the position of the debug canvas
  26223. * @ignorenaming
  26224. */
  26225. DEBUGCANVASPOS: {
  26226. x: number;
  26227. y: number;
  26228. };
  26229. /**
  26230. * Gets or sets the debug canvas size
  26231. * @ignorenaming
  26232. */
  26233. DEBUGCANVASSIZE: {
  26234. width: number;
  26235. height: number;
  26236. };
  26237. private _byteFreqs;
  26238. private _byteTime;
  26239. private _floatFreqs;
  26240. private _webAudioAnalyser;
  26241. private _debugCanvas;
  26242. private _debugCanvasContext;
  26243. private _scene;
  26244. private _registerFunc;
  26245. private _audioEngine;
  26246. /**
  26247. * Creates a new analyser
  26248. * @param scene defines hosting scene
  26249. */
  26250. constructor(scene: Scene);
  26251. /**
  26252. * Get the number of data values you will have to play with for the visualization
  26253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26254. * @returns a number
  26255. */
  26256. getFrequencyBinCount(): number;
  26257. /**
  26258. * Gets the current frequency data as a byte array
  26259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26260. * @returns a Uint8Array
  26261. */
  26262. getByteFrequencyData(): Uint8Array;
  26263. /**
  26264. * Gets the current waveform as a byte array
  26265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26266. * @returns a Uint8Array
  26267. */
  26268. getByteTimeDomainData(): Uint8Array;
  26269. /**
  26270. * Gets the current frequency data as a float array
  26271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26272. * @returns a Float32Array
  26273. */
  26274. getFloatFrequencyData(): Float32Array;
  26275. /**
  26276. * Renders the debug canvas
  26277. */
  26278. drawDebugCanvas(): void;
  26279. /**
  26280. * Stops rendering the debug canvas and removes it
  26281. */
  26282. stopDebugCanvas(): void;
  26283. /**
  26284. * Connects two audio nodes
  26285. * @param inputAudioNode defines first node to connect
  26286. * @param outputAudioNode defines second node to connect
  26287. */
  26288. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26289. /**
  26290. * Releases all associated resources
  26291. */
  26292. dispose(): void;
  26293. }
  26294. }
  26295. declare module "babylonjs/Audio/audioEngine" {
  26296. import { IDisposable } from "babylonjs/scene";
  26297. import { Analyser } from "babylonjs/Audio/analyser";
  26298. import { Nullable } from "babylonjs/types";
  26299. import { Observable } from "babylonjs/Misc/observable";
  26300. /**
  26301. * This represents an audio engine and it is responsible
  26302. * to play, synchronize and analyse sounds throughout the application.
  26303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26304. */
  26305. export interface IAudioEngine extends IDisposable {
  26306. /**
  26307. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26308. */
  26309. readonly canUseWebAudio: boolean;
  26310. /**
  26311. * Gets the current AudioContext if available.
  26312. */
  26313. readonly audioContext: Nullable<AudioContext>;
  26314. /**
  26315. * The master gain node defines the global audio volume of your audio engine.
  26316. */
  26317. readonly masterGain: GainNode;
  26318. /**
  26319. * Gets whether or not mp3 are supported by your browser.
  26320. */
  26321. readonly isMP3supported: boolean;
  26322. /**
  26323. * Gets whether or not ogg are supported by your browser.
  26324. */
  26325. readonly isOGGsupported: boolean;
  26326. /**
  26327. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26328. * @ignoreNaming
  26329. */
  26330. WarnedWebAudioUnsupported: boolean;
  26331. /**
  26332. * Defines if the audio engine relies on a custom unlocked button.
  26333. * In this case, the embedded button will not be displayed.
  26334. */
  26335. useCustomUnlockedButton: boolean;
  26336. /**
  26337. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26338. */
  26339. readonly unlocked: boolean;
  26340. /**
  26341. * Event raised when audio has been unlocked on the browser.
  26342. */
  26343. onAudioUnlockedObservable: Observable<AudioEngine>;
  26344. /**
  26345. * Event raised when audio has been locked on the browser.
  26346. */
  26347. onAudioLockedObservable: Observable<AudioEngine>;
  26348. /**
  26349. * Flags the audio engine in Locked state.
  26350. * This happens due to new browser policies preventing audio to autoplay.
  26351. */
  26352. lock(): void;
  26353. /**
  26354. * Unlocks the audio engine once a user action has been done on the dom.
  26355. * This is helpful to resume play once browser policies have been satisfied.
  26356. */
  26357. unlock(): void;
  26358. }
  26359. /**
  26360. * This represents the default audio engine used in babylon.
  26361. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26363. */
  26364. export class AudioEngine implements IAudioEngine {
  26365. private _audioContext;
  26366. private _audioContextInitialized;
  26367. private _muteButton;
  26368. private _hostElement;
  26369. /**
  26370. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26371. */
  26372. canUseWebAudio: boolean;
  26373. /**
  26374. * The master gain node defines the global audio volume of your audio engine.
  26375. */
  26376. masterGain: GainNode;
  26377. /**
  26378. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26379. * @ignoreNaming
  26380. */
  26381. WarnedWebAudioUnsupported: boolean;
  26382. /**
  26383. * Gets whether or not mp3 are supported by your browser.
  26384. */
  26385. isMP3supported: boolean;
  26386. /**
  26387. * Gets whether or not ogg are supported by your browser.
  26388. */
  26389. isOGGsupported: boolean;
  26390. /**
  26391. * Gets whether audio has been unlocked on the device.
  26392. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26393. * a user interaction has happened.
  26394. */
  26395. unlocked: boolean;
  26396. /**
  26397. * Defines if the audio engine relies on a custom unlocked button.
  26398. * In this case, the embedded button will not be displayed.
  26399. */
  26400. useCustomUnlockedButton: boolean;
  26401. /**
  26402. * Event raised when audio has been unlocked on the browser.
  26403. */
  26404. onAudioUnlockedObservable: Observable<AudioEngine>;
  26405. /**
  26406. * Event raised when audio has been locked on the browser.
  26407. */
  26408. onAudioLockedObservable: Observable<AudioEngine>;
  26409. /**
  26410. * Gets the current AudioContext if available.
  26411. */
  26412. readonly audioContext: Nullable<AudioContext>;
  26413. private _connectedAnalyser;
  26414. /**
  26415. * Instantiates a new audio engine.
  26416. *
  26417. * There should be only one per page as some browsers restrict the number
  26418. * of audio contexts you can create.
  26419. * @param hostElement defines the host element where to display the mute icon if necessary
  26420. */
  26421. constructor(hostElement?: Nullable<HTMLElement>);
  26422. /**
  26423. * Flags the audio engine in Locked state.
  26424. * This happens due to new browser policies preventing audio to autoplay.
  26425. */
  26426. lock(): void;
  26427. /**
  26428. * Unlocks the audio engine once a user action has been done on the dom.
  26429. * This is helpful to resume play once browser policies have been satisfied.
  26430. */
  26431. unlock(): void;
  26432. private _resumeAudioContext;
  26433. private _initializeAudioContext;
  26434. private _tryToRun;
  26435. private _triggerRunningState;
  26436. private _triggerSuspendedState;
  26437. private _displayMuteButton;
  26438. private _moveButtonToTopLeft;
  26439. private _onResize;
  26440. private _hideMuteButton;
  26441. /**
  26442. * Destroy and release the resources associated with the audio ccontext.
  26443. */
  26444. dispose(): void;
  26445. /**
  26446. * Gets the global volume sets on the master gain.
  26447. * @returns the global volume if set or -1 otherwise
  26448. */
  26449. getGlobalVolume(): number;
  26450. /**
  26451. * Sets the global volume of your experience (sets on the master gain).
  26452. * @param newVolume Defines the new global volume of the application
  26453. */
  26454. setGlobalVolume(newVolume: number): void;
  26455. /**
  26456. * Connect the audio engine to an audio analyser allowing some amazing
  26457. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26459. * @param analyser The analyser to connect to the engine
  26460. */
  26461. connectToAnalyser(analyser: Analyser): void;
  26462. }
  26463. }
  26464. declare module "babylonjs/Loading/loadingScreen" {
  26465. /**
  26466. * Interface used to present a loading screen while loading a scene
  26467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26468. */
  26469. export interface ILoadingScreen {
  26470. /**
  26471. * Function called to display the loading screen
  26472. */
  26473. displayLoadingUI: () => void;
  26474. /**
  26475. * Function called to hide the loading screen
  26476. */
  26477. hideLoadingUI: () => void;
  26478. /**
  26479. * Gets or sets the color to use for the background
  26480. */
  26481. loadingUIBackgroundColor: string;
  26482. /**
  26483. * Gets or sets the text to display while loading
  26484. */
  26485. loadingUIText: string;
  26486. }
  26487. /**
  26488. * Class used for the default loading screen
  26489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26490. */
  26491. export class DefaultLoadingScreen implements ILoadingScreen {
  26492. private _renderingCanvas;
  26493. private _loadingText;
  26494. private _loadingDivBackgroundColor;
  26495. private _loadingDiv;
  26496. private _loadingTextDiv;
  26497. /**
  26498. * Creates a new default loading screen
  26499. * @param _renderingCanvas defines the canvas used to render the scene
  26500. * @param _loadingText defines the default text to display
  26501. * @param _loadingDivBackgroundColor defines the default background color
  26502. */
  26503. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26504. /**
  26505. * Function called to display the loading screen
  26506. */
  26507. displayLoadingUI(): void;
  26508. /**
  26509. * Function called to hide the loading screen
  26510. */
  26511. hideLoadingUI(): void;
  26512. /**
  26513. * Gets or sets the text to display while loading
  26514. */
  26515. loadingUIText: string;
  26516. /**
  26517. * Gets or sets the color to use for the background
  26518. */
  26519. loadingUIBackgroundColor: string;
  26520. private _resizeLoadingUI;
  26521. }
  26522. }
  26523. declare module "babylonjs/Materials/Textures/videoTexture" {
  26524. import { Observable } from "babylonjs/Misc/observable";
  26525. import { Nullable } from "babylonjs/types";
  26526. import { Scene } from "babylonjs/scene";
  26527. import { Texture } from "babylonjs/Materials/Textures/texture";
  26528. /**
  26529. * Settings for finer control over video usage
  26530. */
  26531. export interface VideoTextureSettings {
  26532. /**
  26533. * Applies `autoplay` to video, if specified
  26534. */
  26535. autoPlay?: boolean;
  26536. /**
  26537. * Applies `loop` to video, if specified
  26538. */
  26539. loop?: boolean;
  26540. /**
  26541. * Automatically updates internal texture from video at every frame in the render loop
  26542. */
  26543. autoUpdateTexture: boolean;
  26544. /**
  26545. * Image src displayed during the video loading or until the user interacts with the video.
  26546. */
  26547. poster?: string;
  26548. }
  26549. /**
  26550. * If you want to display a video in your scene, this is the special texture for that.
  26551. * This special texture works similar to other textures, with the exception of a few parameters.
  26552. * @see https://doc.babylonjs.com/how_to/video_texture
  26553. */
  26554. export class VideoTexture extends Texture {
  26555. /**
  26556. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26557. */
  26558. readonly autoUpdateTexture: boolean;
  26559. /**
  26560. * The video instance used by the texture internally
  26561. */
  26562. readonly video: HTMLVideoElement;
  26563. private _onUserActionRequestedObservable;
  26564. /**
  26565. * Event triggerd when a dom action is required by the user to play the video.
  26566. * This happens due to recent changes in browser policies preventing video to auto start.
  26567. */
  26568. readonly onUserActionRequestedObservable: Observable<Texture>;
  26569. private _generateMipMaps;
  26570. private _engine;
  26571. private _stillImageCaptured;
  26572. private _displayingPosterTexture;
  26573. private _settings;
  26574. private _createInternalTextureOnEvent;
  26575. /**
  26576. * Creates a video texture.
  26577. * If you want to display a video in your scene, this is the special texture for that.
  26578. * This special texture works similar to other textures, with the exception of a few parameters.
  26579. * @see https://doc.babylonjs.com/how_to/video_texture
  26580. * @param name optional name, will detect from video source, if not defined
  26581. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26582. * @param scene is obviously the current scene.
  26583. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26584. * @param invertY is false by default but can be used to invert video on Y axis
  26585. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26586. * @param settings allows finer control over video usage
  26587. */
  26588. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26589. private _getName;
  26590. private _getVideo;
  26591. private _createInternalTexture;
  26592. private reset;
  26593. /**
  26594. * @hidden Internal method to initiate `update`.
  26595. */
  26596. _rebuild(): void;
  26597. /**
  26598. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26599. */
  26600. update(): void;
  26601. /**
  26602. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26603. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26604. */
  26605. updateTexture(isVisible: boolean): void;
  26606. protected _updateInternalTexture: () => void;
  26607. /**
  26608. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26609. * @param url New url.
  26610. */
  26611. updateURL(url: string): void;
  26612. /**
  26613. * Dispose the texture and release its associated resources.
  26614. */
  26615. dispose(): void;
  26616. /**
  26617. * Creates a video texture straight from your WebCam video feed.
  26618. * @param scene Define the scene the texture should be created in
  26619. * @param onReady Define a callback to triggered once the texture will be ready
  26620. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26621. */
  26622. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26623. minWidth: number;
  26624. maxWidth: number;
  26625. minHeight: number;
  26626. maxHeight: number;
  26627. deviceId: string;
  26628. }): void;
  26629. }
  26630. }
  26631. declare module "babylonjs/Engines/engine" {
  26632. import { Observable } from "babylonjs/Misc/observable";
  26633. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26634. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26635. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26636. import { Camera } from "babylonjs/Cameras/camera";
  26637. import { Scene } from "babylonjs/scene";
  26638. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26639. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26640. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26641. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26642. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26643. import { Material } from "babylonjs/Materials/material";
  26644. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26647. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26648. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26649. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26650. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26651. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26652. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26653. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26654. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26655. /**
  26656. * Interface for attribute information associated with buffer instanciation
  26657. */
  26658. export class InstancingAttributeInfo {
  26659. /**
  26660. * Index/offset of the attribute in the vertex shader
  26661. */
  26662. index: number;
  26663. /**
  26664. * size of the attribute, 1, 2, 3 or 4
  26665. */
  26666. attributeSize: number;
  26667. /**
  26668. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26669. * default is FLOAT
  26670. */
  26671. attribyteType: number;
  26672. /**
  26673. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26674. */
  26675. normalized: boolean;
  26676. /**
  26677. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26678. */
  26679. offset: number;
  26680. /**
  26681. * Name of the GLSL attribute, for debugging purpose only
  26682. */
  26683. attributeName: string;
  26684. }
  26685. /**
  26686. * Define options used to create a depth texture
  26687. */
  26688. export class DepthTextureCreationOptions {
  26689. /** Specifies whether or not a stencil should be allocated in the texture */
  26690. generateStencil?: boolean;
  26691. /** Specifies whether or not bilinear filtering is enable on the texture */
  26692. bilinearFiltering?: boolean;
  26693. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26694. comparisonFunction?: number;
  26695. /** Specifies if the created texture is a cube texture */
  26696. isCube?: boolean;
  26697. }
  26698. /**
  26699. * Class used to describe the capabilities of the engine relatively to the current browser
  26700. */
  26701. export class EngineCapabilities {
  26702. /** Maximum textures units per fragment shader */
  26703. maxTexturesImageUnits: number;
  26704. /** Maximum texture units per vertex shader */
  26705. maxVertexTextureImageUnits: number;
  26706. /** Maximum textures units in the entire pipeline */
  26707. maxCombinedTexturesImageUnits: number;
  26708. /** Maximum texture size */
  26709. maxTextureSize: number;
  26710. /** Maximum cube texture size */
  26711. maxCubemapTextureSize: number;
  26712. /** Maximum render texture size */
  26713. maxRenderTextureSize: number;
  26714. /** Maximum number of vertex attributes */
  26715. maxVertexAttribs: number;
  26716. /** Maximum number of varyings */
  26717. maxVaryingVectors: number;
  26718. /** Maximum number of uniforms per vertex shader */
  26719. maxVertexUniformVectors: number;
  26720. /** Maximum number of uniforms per fragment shader */
  26721. maxFragmentUniformVectors: number;
  26722. /** Defines if standard derivates (dx/dy) are supported */
  26723. standardDerivatives: boolean;
  26724. /** Defines if s3tc texture compression is supported */
  26725. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26726. /** Defines if pvrtc texture compression is supported */
  26727. pvrtc: any;
  26728. /** Defines if etc1 texture compression is supported */
  26729. etc1: any;
  26730. /** Defines if etc2 texture compression is supported */
  26731. etc2: any;
  26732. /** Defines if astc texture compression is supported */
  26733. astc: any;
  26734. /** Defines if float textures are supported */
  26735. textureFloat: boolean;
  26736. /** Defines if vertex array objects are supported */
  26737. vertexArrayObject: boolean;
  26738. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26739. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26740. /** Gets the maximum level of anisotropy supported */
  26741. maxAnisotropy: number;
  26742. /** Defines if instancing is supported */
  26743. instancedArrays: boolean;
  26744. /** Defines if 32 bits indices are supported */
  26745. uintIndices: boolean;
  26746. /** Defines if high precision shaders are supported */
  26747. highPrecisionShaderSupported: boolean;
  26748. /** Defines if depth reading in the fragment shader is supported */
  26749. fragmentDepthSupported: boolean;
  26750. /** Defines if float texture linear filtering is supported*/
  26751. textureFloatLinearFiltering: boolean;
  26752. /** Defines if rendering to float textures is supported */
  26753. textureFloatRender: boolean;
  26754. /** Defines if half float textures are supported*/
  26755. textureHalfFloat: boolean;
  26756. /** Defines if half float texture linear filtering is supported*/
  26757. textureHalfFloatLinearFiltering: boolean;
  26758. /** Defines if rendering to half float textures is supported */
  26759. textureHalfFloatRender: boolean;
  26760. /** Defines if textureLOD shader command is supported */
  26761. textureLOD: boolean;
  26762. /** Defines if draw buffers extension is supported */
  26763. drawBuffersExtension: boolean;
  26764. /** Defines if depth textures are supported */
  26765. depthTextureExtension: boolean;
  26766. /** Defines if float color buffer are supported */
  26767. colorBufferFloat: boolean;
  26768. /** Gets disjoint timer query extension (null if not supported) */
  26769. timerQuery: EXT_disjoint_timer_query;
  26770. /** Defines if timestamp can be used with timer query */
  26771. canUseTimestampForTimerQuery: boolean;
  26772. /** Function used to let the system compiles shaders in background */
  26773. parallelShaderCompile: {
  26774. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26775. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26776. COMPLETION_STATUS_KHR: number;
  26777. };
  26778. }
  26779. /** Interface defining initialization parameters for Engine class */
  26780. export interface EngineOptions extends WebGLContextAttributes {
  26781. /**
  26782. * Defines if the engine should no exceed a specified device ratio
  26783. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26784. */
  26785. limitDeviceRatio?: number;
  26786. /**
  26787. * Defines if webvr should be enabled automatically
  26788. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26789. */
  26790. autoEnableWebVR?: boolean;
  26791. /**
  26792. * Defines if webgl2 should be turned off even if supported
  26793. * @see http://doc.babylonjs.com/features/webgl2
  26794. */
  26795. disableWebGL2Support?: boolean;
  26796. /**
  26797. * Defines if webaudio should be initialized as well
  26798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26799. */
  26800. audioEngine?: boolean;
  26801. /**
  26802. * Defines if animations should run using a deterministic lock step
  26803. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26804. */
  26805. deterministicLockstep?: boolean;
  26806. /** Defines the maximum steps to use with deterministic lock step mode */
  26807. lockstepMaxSteps?: number;
  26808. /**
  26809. * Defines that engine should ignore context lost events
  26810. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26811. */
  26812. doNotHandleContextLost?: boolean;
  26813. /**
  26814. * Defines that engine should ignore modifying touch action attribute and style
  26815. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26816. */
  26817. doNotHandleTouchAction?: boolean;
  26818. }
  26819. /**
  26820. * Defines the interface used by display changed events
  26821. */
  26822. export interface IDisplayChangedEventArgs {
  26823. /** Gets the vrDisplay object (if any) */
  26824. vrDisplay: Nullable<any>;
  26825. /** Gets a boolean indicating if webVR is supported */
  26826. vrSupported: boolean;
  26827. }
  26828. /**
  26829. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26830. */
  26831. export class Engine {
  26832. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26833. static ExceptionList: ({
  26834. key: string;
  26835. capture: string;
  26836. captureConstraint: number;
  26837. targets: string[];
  26838. } | {
  26839. key: string;
  26840. capture: null;
  26841. captureConstraint: null;
  26842. targets: string[];
  26843. })[];
  26844. /** Gets the list of created engines */
  26845. static readonly Instances: Engine[];
  26846. /**
  26847. * Gets the latest created engine
  26848. */
  26849. static readonly LastCreatedEngine: Nullable<Engine>;
  26850. /**
  26851. * Gets the latest created scene
  26852. */
  26853. static readonly LastCreatedScene: Nullable<Scene>;
  26854. /**
  26855. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26856. * @param flag defines which part of the materials must be marked as dirty
  26857. * @param predicate defines a predicate used to filter which materials should be affected
  26858. */
  26859. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26860. /**
  26861. * Hidden
  26862. */
  26863. static _TextureLoaders: IInternalTextureLoader[];
  26864. /** Defines that alpha blending is disabled */
  26865. static readonly ALPHA_DISABLE: number;
  26866. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26867. static readonly ALPHA_ADD: number;
  26868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26869. static readonly ALPHA_COMBINE: number;
  26870. /** Defines that alpha blending to DEST - SRC * DEST */
  26871. static readonly ALPHA_SUBTRACT: number;
  26872. /** Defines that alpha blending to SRC * DEST */
  26873. static readonly ALPHA_MULTIPLY: number;
  26874. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26875. static readonly ALPHA_MAXIMIZED: number;
  26876. /** Defines that alpha blending to SRC + DEST */
  26877. static readonly ALPHA_ONEONE: number;
  26878. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26879. static readonly ALPHA_PREMULTIPLIED: number;
  26880. /**
  26881. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26882. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26883. */
  26884. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26885. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26886. static readonly ALPHA_INTERPOLATE: number;
  26887. /**
  26888. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26889. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26890. */
  26891. static readonly ALPHA_SCREENMODE: number;
  26892. /** Defines that the ressource is not delayed*/
  26893. static readonly DELAYLOADSTATE_NONE: number;
  26894. /** Defines that the ressource was successfully delay loaded */
  26895. static readonly DELAYLOADSTATE_LOADED: number;
  26896. /** Defines that the ressource is currently delay loading */
  26897. static readonly DELAYLOADSTATE_LOADING: number;
  26898. /** Defines that the ressource is delayed and has not started loading */
  26899. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26901. static readonly NEVER: number;
  26902. /** 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 */
  26903. static readonly ALWAYS: number;
  26904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26905. static readonly LESS: number;
  26906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26907. static readonly EQUAL: number;
  26908. /** 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 */
  26909. static readonly LEQUAL: number;
  26910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26911. static readonly GREATER: number;
  26912. /** 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 */
  26913. static readonly GEQUAL: number;
  26914. /** 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 */
  26915. static readonly NOTEQUAL: number;
  26916. /** Passed to stencilOperation to specify that stencil value must be kept */
  26917. static readonly KEEP: number;
  26918. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26919. static readonly REPLACE: number;
  26920. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26921. static readonly INCR: number;
  26922. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26923. static readonly DECR: number;
  26924. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26925. static readonly INVERT: number;
  26926. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26927. static readonly INCR_WRAP: number;
  26928. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26929. static readonly DECR_WRAP: number;
  26930. /** Texture is not repeating outside of 0..1 UVs */
  26931. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26932. /** Texture is repeating outside of 0..1 UVs */
  26933. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26934. /** Texture is repeating and mirrored */
  26935. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26936. /** ALPHA */
  26937. static readonly TEXTUREFORMAT_ALPHA: number;
  26938. /** LUMINANCE */
  26939. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26940. /** LUMINANCE_ALPHA */
  26941. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26942. /** RGB */
  26943. static readonly TEXTUREFORMAT_RGB: number;
  26944. /** RGBA */
  26945. static readonly TEXTUREFORMAT_RGBA: number;
  26946. /** RED */
  26947. static readonly TEXTUREFORMAT_RED: number;
  26948. /** RED (2nd reference) */
  26949. static readonly TEXTUREFORMAT_R: number;
  26950. /** RG */
  26951. static readonly TEXTUREFORMAT_RG: number;
  26952. /** RED_INTEGER */
  26953. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26954. /** RED_INTEGER (2nd reference) */
  26955. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26956. /** RG_INTEGER */
  26957. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26958. /** RGB_INTEGER */
  26959. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26960. /** RGBA_INTEGER */
  26961. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26962. /** UNSIGNED_BYTE */
  26963. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26964. /** UNSIGNED_BYTE (2nd reference) */
  26965. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26966. /** FLOAT */
  26967. static readonly TEXTURETYPE_FLOAT: number;
  26968. /** HALF_FLOAT */
  26969. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26970. /** BYTE */
  26971. static readonly TEXTURETYPE_BYTE: number;
  26972. /** SHORT */
  26973. static readonly TEXTURETYPE_SHORT: number;
  26974. /** UNSIGNED_SHORT */
  26975. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26976. /** INT */
  26977. static readonly TEXTURETYPE_INT: number;
  26978. /** UNSIGNED_INT */
  26979. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26980. /** UNSIGNED_SHORT_4_4_4_4 */
  26981. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26982. /** UNSIGNED_SHORT_5_5_5_1 */
  26983. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26984. /** UNSIGNED_SHORT_5_6_5 */
  26985. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26986. /** UNSIGNED_INT_2_10_10_10_REV */
  26987. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26988. /** UNSIGNED_INT_24_8 */
  26989. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26990. /** UNSIGNED_INT_10F_11F_11F_REV */
  26991. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26992. /** UNSIGNED_INT_5_9_9_9_REV */
  26993. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26994. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26995. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26996. /** nearest is mag = nearest and min = nearest and mip = linear */
  26997. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26998. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26999. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27000. /** Trilinear is mag = linear and min = linear and mip = linear */
  27001. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27002. /** nearest is mag = nearest and min = nearest and mip = linear */
  27003. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27004. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27005. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27006. /** Trilinear is mag = linear and min = linear and mip = linear */
  27007. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27008. /** mag = nearest and min = nearest and mip = nearest */
  27009. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27010. /** mag = nearest and min = linear and mip = nearest */
  27011. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27012. /** mag = nearest and min = linear and mip = linear */
  27013. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27014. /** mag = nearest and min = linear and mip = none */
  27015. static readonly TEXTURE_NEAREST_LINEAR: number;
  27016. /** mag = nearest and min = nearest and mip = none */
  27017. static readonly TEXTURE_NEAREST_NEAREST: number;
  27018. /** mag = linear and min = nearest and mip = nearest */
  27019. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27020. /** mag = linear and min = nearest and mip = linear */
  27021. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27022. /** mag = linear and min = linear and mip = none */
  27023. static readonly TEXTURE_LINEAR_LINEAR: number;
  27024. /** mag = linear and min = nearest and mip = none */
  27025. static readonly TEXTURE_LINEAR_NEAREST: number;
  27026. /** Explicit coordinates mode */
  27027. static readonly TEXTURE_EXPLICIT_MODE: number;
  27028. /** Spherical coordinates mode */
  27029. static readonly TEXTURE_SPHERICAL_MODE: number;
  27030. /** Planar coordinates mode */
  27031. static readonly TEXTURE_PLANAR_MODE: number;
  27032. /** Cubic coordinates mode */
  27033. static readonly TEXTURE_CUBIC_MODE: number;
  27034. /** Projection coordinates mode */
  27035. static readonly TEXTURE_PROJECTION_MODE: number;
  27036. /** Skybox coordinates mode */
  27037. static readonly TEXTURE_SKYBOX_MODE: number;
  27038. /** Inverse Cubic coordinates mode */
  27039. static readonly TEXTURE_INVCUBIC_MODE: number;
  27040. /** Equirectangular coordinates mode */
  27041. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27042. /** Equirectangular Fixed coordinates mode */
  27043. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27044. /** Equirectangular Fixed Mirrored coordinates mode */
  27045. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27046. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27047. static readonly SCALEMODE_FLOOR: number;
  27048. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27049. static readonly SCALEMODE_NEAREST: number;
  27050. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27051. static readonly SCALEMODE_CEILING: number;
  27052. /**
  27053. * Returns the current version of the framework
  27054. */
  27055. static readonly Version: string;
  27056. /**
  27057. * Returns a string describing the current engine
  27058. */
  27059. readonly description: string;
  27060. /**
  27061. * Gets or sets the epsilon value used by collision engine
  27062. */
  27063. static CollisionsEpsilon: number;
  27064. /**
  27065. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27066. */
  27067. static ShadersRepository: string;
  27068. /**
  27069. * Method called to create the default loading screen.
  27070. * This can be overriden in your own app.
  27071. * @param canvas The rendering canvas element
  27072. * @returns The loading screen
  27073. */
  27074. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27075. /**
  27076. * Method called to create the default rescale post process on each engine.
  27077. */
  27078. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27079. /**
  27080. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27081. */
  27082. forcePOTTextures: boolean;
  27083. /**
  27084. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27085. */
  27086. isFullscreen: boolean;
  27087. /**
  27088. * Gets a boolean indicating if the pointer is currently locked
  27089. */
  27090. isPointerLock: boolean;
  27091. /**
  27092. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27093. */
  27094. cullBackFaces: boolean;
  27095. /**
  27096. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27097. */
  27098. renderEvenInBackground: boolean;
  27099. /**
  27100. * Gets or sets a boolean indicating that cache can be kept between frames
  27101. */
  27102. preventCacheWipeBetweenFrames: boolean;
  27103. /**
  27104. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27105. **/
  27106. enableOfflineSupport: boolean;
  27107. /**
  27108. * 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)
  27109. **/
  27110. disableManifestCheck: boolean;
  27111. /**
  27112. * Gets the list of created scenes
  27113. */
  27114. scenes: Scene[];
  27115. /**
  27116. * Event raised when a new scene is created
  27117. */
  27118. onNewSceneAddedObservable: Observable<Scene>;
  27119. /**
  27120. * Gets the list of created postprocesses
  27121. */
  27122. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27123. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27124. validateShaderPrograms: boolean;
  27125. /**
  27126. * Observable event triggered each time the rendering canvas is resized
  27127. */
  27128. onResizeObservable: Observable<Engine>;
  27129. /**
  27130. * Observable event triggered each time the canvas loses focus
  27131. */
  27132. onCanvasBlurObservable: Observable<Engine>;
  27133. /**
  27134. * Observable event triggered each time the canvas gains focus
  27135. */
  27136. onCanvasFocusObservable: Observable<Engine>;
  27137. /**
  27138. * Observable event triggered each time the canvas receives pointerout event
  27139. */
  27140. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27141. /**
  27142. * Observable event triggered before each texture is initialized
  27143. */
  27144. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27145. private _vrDisplay;
  27146. private _vrSupported;
  27147. private _oldSize;
  27148. private _oldHardwareScaleFactor;
  27149. private _vrExclusivePointerMode;
  27150. private _webVRInitPromise;
  27151. /**
  27152. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27153. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27154. */
  27155. readonly isInVRExclusivePointerMode: boolean;
  27156. /**
  27157. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27158. */
  27159. disableUniformBuffers: boolean;
  27160. /** @hidden */
  27161. _uniformBuffers: UniformBuffer[];
  27162. /**
  27163. * Gets a boolean indicating that the engine supports uniform buffers
  27164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27165. */
  27166. readonly supportsUniformBuffers: boolean;
  27167. /**
  27168. * Observable raised when the engine begins a new frame
  27169. */
  27170. onBeginFrameObservable: Observable<Engine>;
  27171. /**
  27172. * If set, will be used to request the next animation frame for the render loop
  27173. */
  27174. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27175. /**
  27176. * Observable raised when the engine ends the current frame
  27177. */
  27178. onEndFrameObservable: Observable<Engine>;
  27179. /**
  27180. * Observable raised when the engine is about to compile a shader
  27181. */
  27182. onBeforeShaderCompilationObservable: Observable<Engine>;
  27183. /**
  27184. * Observable raised when the engine has jsut compiled a shader
  27185. */
  27186. onAfterShaderCompilationObservable: Observable<Engine>;
  27187. /** @hidden */
  27188. _gl: WebGLRenderingContext;
  27189. private _renderingCanvas;
  27190. private _windowIsBackground;
  27191. private _webGLVersion;
  27192. /**
  27193. * Gets a boolean indicating that only power of 2 textures are supported
  27194. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27195. */
  27196. readonly needPOTTextures: boolean;
  27197. /** @hidden */
  27198. _badOS: boolean;
  27199. /** @hidden */
  27200. _badDesktopOS: boolean;
  27201. /**
  27202. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27203. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27204. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27205. */
  27206. disableTextureBindingOptimization: boolean;
  27207. /**
  27208. * Gets the audio engine
  27209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27210. * @ignorenaming
  27211. */
  27212. static audioEngine: IAudioEngine;
  27213. /**
  27214. * Default AudioEngine factory responsible of creating the Audio Engine.
  27215. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27216. */
  27217. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27218. /**
  27219. * Default offline support factory responsible of creating a tool used to store data locally.
  27220. * By default, this will create a Database object if the workload has been embedded.
  27221. */
  27222. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27223. private _onFocus;
  27224. private _onBlur;
  27225. private _onCanvasPointerOut;
  27226. private _onCanvasBlur;
  27227. private _onCanvasFocus;
  27228. private _onFullscreenChange;
  27229. private _onPointerLockChange;
  27230. private _onVRDisplayPointerRestricted;
  27231. private _onVRDisplayPointerUnrestricted;
  27232. private _onVrDisplayConnect;
  27233. private _onVrDisplayDisconnect;
  27234. private _onVrDisplayPresentChange;
  27235. /**
  27236. * Observable signaled when VR display mode changes
  27237. */
  27238. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27239. /**
  27240. * Observable signaled when VR request present is complete
  27241. */
  27242. onVRRequestPresentComplete: Observable<boolean>;
  27243. /**
  27244. * Observable signaled when VR request present starts
  27245. */
  27246. onVRRequestPresentStart: Observable<Engine>;
  27247. private _hardwareScalingLevel;
  27248. /** @hidden */
  27249. protected _caps: EngineCapabilities;
  27250. private _pointerLockRequested;
  27251. private _isStencilEnable;
  27252. private _colorWrite;
  27253. private _loadingScreen;
  27254. /** @hidden */
  27255. _drawCalls: PerfCounter;
  27256. /** @hidden */
  27257. _textureCollisions: PerfCounter;
  27258. private _glVersion;
  27259. private _glRenderer;
  27260. private _glVendor;
  27261. private _videoTextureSupported;
  27262. private _renderingQueueLaunched;
  27263. private _activeRenderLoops;
  27264. private _deterministicLockstep;
  27265. private _lockstepMaxSteps;
  27266. /**
  27267. * Observable signaled when a context lost event is raised
  27268. */
  27269. onContextLostObservable: Observable<Engine>;
  27270. /**
  27271. * Observable signaled when a context restored event is raised
  27272. */
  27273. onContextRestoredObservable: Observable<Engine>;
  27274. private _onContextLost;
  27275. private _onContextRestored;
  27276. private _contextWasLost;
  27277. private _doNotHandleContextLost;
  27278. /**
  27279. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27281. */
  27282. doNotHandleContextLost: boolean;
  27283. private _performanceMonitor;
  27284. private _fps;
  27285. private _deltaTime;
  27286. /**
  27287. * Turn this value on if you want to pause FPS computation when in background
  27288. */
  27289. disablePerformanceMonitorInBackground: boolean;
  27290. /**
  27291. * Gets the performance monitor attached to this engine
  27292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27293. */
  27294. readonly performanceMonitor: PerformanceMonitor;
  27295. /** @hidden */
  27296. protected _depthCullingState: _DepthCullingState;
  27297. /** @hidden */
  27298. protected _stencilState: _StencilState;
  27299. /** @hidden */
  27300. protected _alphaState: _AlphaState;
  27301. /** @hidden */
  27302. protected _alphaMode: number;
  27303. protected _internalTexturesCache: InternalTexture[];
  27304. /** @hidden */
  27305. protected _activeChannel: number;
  27306. private _currentTextureChannel;
  27307. /** @hidden */
  27308. protected _boundTexturesCache: {
  27309. [key: string]: Nullable<InternalTexture>;
  27310. };
  27311. /** @hidden */
  27312. protected _currentEffect: Nullable<Effect>;
  27313. /** @hidden */
  27314. protected _currentProgram: Nullable<WebGLProgram>;
  27315. private _compiledEffects;
  27316. private _vertexAttribArraysEnabled;
  27317. /** @hidden */
  27318. protected _cachedViewport: Nullable<Viewport>;
  27319. private _cachedVertexArrayObject;
  27320. /** @hidden */
  27321. protected _cachedVertexBuffers: any;
  27322. /** @hidden */
  27323. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27324. /** @hidden */
  27325. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27326. /** @hidden */
  27327. protected _currentRenderTarget: Nullable<InternalTexture>;
  27328. private _uintIndicesCurrentlySet;
  27329. private _currentBoundBuffer;
  27330. /** @hidden */
  27331. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27332. private _currentBufferPointers;
  27333. private _currentInstanceLocations;
  27334. private _currentInstanceBuffers;
  27335. private _textureUnits;
  27336. private _firstBoundInternalTextureTracker;
  27337. private _lastBoundInternalTextureTracker;
  27338. private _workingCanvas;
  27339. private _workingContext;
  27340. private _rescalePostProcess;
  27341. private _dummyFramebuffer;
  27342. private _externalData;
  27343. private _bindedRenderFunction;
  27344. private _vaoRecordInProgress;
  27345. private _mustWipeVertexAttributes;
  27346. private _emptyTexture;
  27347. private _emptyCubeTexture;
  27348. private _emptyTexture3D;
  27349. /** @hidden */
  27350. _frameHandler: number;
  27351. private _nextFreeTextureSlots;
  27352. private _maxSimultaneousTextures;
  27353. private _activeRequests;
  27354. private _texturesSupported;
  27355. private _textureFormatInUse;
  27356. /**
  27357. * Gets the list of texture formats supported
  27358. */
  27359. readonly texturesSupported: Array<string>;
  27360. /**
  27361. * Gets the list of texture formats in use
  27362. */
  27363. readonly textureFormatInUse: Nullable<string>;
  27364. /**
  27365. * Gets the current viewport
  27366. */
  27367. readonly currentViewport: Nullable<Viewport>;
  27368. /**
  27369. * Gets the default empty texture
  27370. */
  27371. readonly emptyTexture: InternalTexture;
  27372. /**
  27373. * Gets the default empty 3D texture
  27374. */
  27375. readonly emptyTexture3D: InternalTexture;
  27376. /**
  27377. * Gets the default empty cube texture
  27378. */
  27379. readonly emptyCubeTexture: InternalTexture;
  27380. /**
  27381. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27382. */
  27383. readonly premultipliedAlpha: boolean;
  27384. /**
  27385. * Creates a new engine
  27386. * @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
  27387. * @param antialias defines enable antialiasing (default: false)
  27388. * @param options defines further options to be sent to the getContext() function
  27389. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27390. */
  27391. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27392. private _disableTouchAction;
  27393. private _rebuildInternalTextures;
  27394. private _rebuildEffects;
  27395. /**
  27396. * Gets a boolean indicating if all created effects are ready
  27397. * @returns true if all effects are ready
  27398. */
  27399. areAllEffectsReady(): boolean;
  27400. private _rebuildBuffers;
  27401. private _initGLContext;
  27402. /**
  27403. * Gets version of the current webGL context
  27404. */
  27405. readonly webGLVersion: number;
  27406. /**
  27407. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27408. */
  27409. readonly isStencilEnable: boolean;
  27410. private _prepareWorkingCanvas;
  27411. /**
  27412. * Reset the texture cache to empty state
  27413. */
  27414. resetTextureCache(): void;
  27415. /**
  27416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27418. * @returns true if engine is in deterministic lock step mode
  27419. */
  27420. isDeterministicLockStep(): boolean;
  27421. /**
  27422. * Gets the max steps when engine is running in deterministic lock step
  27423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27424. * @returns the max steps
  27425. */
  27426. getLockstepMaxSteps(): number;
  27427. /**
  27428. * Gets an object containing information about the current webGL context
  27429. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27430. */
  27431. getGlInfo(): {
  27432. vendor: string;
  27433. renderer: string;
  27434. version: string;
  27435. };
  27436. /**
  27437. * Gets current aspect ratio
  27438. * @param camera defines the camera to use to get the aspect ratio
  27439. * @param useScreen defines if screen size must be used (or the current render target if any)
  27440. * @returns a number defining the aspect ratio
  27441. */
  27442. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27443. /**
  27444. * Gets current screen aspect ratio
  27445. * @returns a number defining the aspect ratio
  27446. */
  27447. getScreenAspectRatio(): number;
  27448. /**
  27449. * Gets the current render width
  27450. * @param useScreen defines if screen size must be used (or the current render target if any)
  27451. * @returns a number defining the current render width
  27452. */
  27453. getRenderWidth(useScreen?: boolean): number;
  27454. /**
  27455. * Gets the current render height
  27456. * @param useScreen defines if screen size must be used (or the current render target if any)
  27457. * @returns a number defining the current render height
  27458. */
  27459. getRenderHeight(useScreen?: boolean): number;
  27460. /**
  27461. * Gets the HTML canvas attached with the current webGL context
  27462. * @returns a HTML canvas
  27463. */
  27464. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27465. /**
  27466. * Gets the client rect of the HTML canvas attached with the current webGL context
  27467. * @returns a client rectanglee
  27468. */
  27469. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27470. /**
  27471. * Defines the hardware scaling level.
  27472. * By default the hardware scaling level is computed from the window device ratio.
  27473. * 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.
  27474. * @param level defines the level to use
  27475. */
  27476. setHardwareScalingLevel(level: number): void;
  27477. /**
  27478. * Gets the current hardware scaling level.
  27479. * By default the hardware scaling level is computed from the window device ratio.
  27480. * 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.
  27481. * @returns a number indicating the current hardware scaling level
  27482. */
  27483. getHardwareScalingLevel(): number;
  27484. /**
  27485. * Gets the list of loaded textures
  27486. * @returns an array containing all loaded textures
  27487. */
  27488. getLoadedTexturesCache(): InternalTexture[];
  27489. /**
  27490. * Gets the object containing all engine capabilities
  27491. * @returns the EngineCapabilities object
  27492. */
  27493. getCaps(): EngineCapabilities;
  27494. /**
  27495. * Gets the current depth function
  27496. * @returns a number defining the depth function
  27497. */
  27498. getDepthFunction(): Nullable<number>;
  27499. /**
  27500. * Sets the current depth function
  27501. * @param depthFunc defines the function to use
  27502. */
  27503. setDepthFunction(depthFunc: number): void;
  27504. /**
  27505. * Sets the current depth function to GREATER
  27506. */
  27507. setDepthFunctionToGreater(): void;
  27508. /**
  27509. * Sets the current depth function to GEQUAL
  27510. */
  27511. setDepthFunctionToGreaterOrEqual(): void;
  27512. /**
  27513. * Sets the current depth function to LESS
  27514. */
  27515. setDepthFunctionToLess(): void;
  27516. /**
  27517. * Sets the current depth function to LEQUAL
  27518. */
  27519. setDepthFunctionToLessOrEqual(): void;
  27520. /**
  27521. * Gets a boolean indicating if stencil buffer is enabled
  27522. * @returns the current stencil buffer state
  27523. */
  27524. getStencilBuffer(): boolean;
  27525. /**
  27526. * Enable or disable the stencil buffer
  27527. * @param enable defines if the stencil buffer must be enabled or disabled
  27528. */
  27529. setStencilBuffer(enable: boolean): void;
  27530. /**
  27531. * Gets the current stencil mask
  27532. * @returns a number defining the new stencil mask to use
  27533. */
  27534. getStencilMask(): number;
  27535. /**
  27536. * Sets the current stencil mask
  27537. * @param mask defines the new stencil mask to use
  27538. */
  27539. setStencilMask(mask: number): void;
  27540. /**
  27541. * Gets the current stencil function
  27542. * @returns a number defining the stencil function to use
  27543. */
  27544. getStencilFunction(): number;
  27545. /**
  27546. * Gets the current stencil reference value
  27547. * @returns a number defining the stencil reference value to use
  27548. */
  27549. getStencilFunctionReference(): number;
  27550. /**
  27551. * Gets the current stencil mask
  27552. * @returns a number defining the stencil mask to use
  27553. */
  27554. getStencilFunctionMask(): number;
  27555. /**
  27556. * Sets the current stencil function
  27557. * @param stencilFunc defines the new stencil function to use
  27558. */
  27559. setStencilFunction(stencilFunc: number): void;
  27560. /**
  27561. * Sets the current stencil reference
  27562. * @param reference defines the new stencil reference to use
  27563. */
  27564. setStencilFunctionReference(reference: number): void;
  27565. /**
  27566. * Sets the current stencil mask
  27567. * @param mask defines the new stencil mask to use
  27568. */
  27569. setStencilFunctionMask(mask: number): void;
  27570. /**
  27571. * Gets the current stencil operation when stencil fails
  27572. * @returns a number defining stencil operation to use when stencil fails
  27573. */
  27574. getStencilOperationFail(): number;
  27575. /**
  27576. * Gets the current stencil operation when depth fails
  27577. * @returns a number defining stencil operation to use when depth fails
  27578. */
  27579. getStencilOperationDepthFail(): number;
  27580. /**
  27581. * Gets the current stencil operation when stencil passes
  27582. * @returns a number defining stencil operation to use when stencil passes
  27583. */
  27584. getStencilOperationPass(): number;
  27585. /**
  27586. * Sets the stencil operation to use when stencil fails
  27587. * @param operation defines the stencil operation to use when stencil fails
  27588. */
  27589. setStencilOperationFail(operation: number): void;
  27590. /**
  27591. * Sets the stencil operation to use when depth fails
  27592. * @param operation defines the stencil operation to use when depth fails
  27593. */
  27594. setStencilOperationDepthFail(operation: number): void;
  27595. /**
  27596. * Sets the stencil operation to use when stencil passes
  27597. * @param operation defines the stencil operation to use when stencil passes
  27598. */
  27599. setStencilOperationPass(operation: number): void;
  27600. /**
  27601. * Sets a boolean indicating if the dithering state is enabled or disabled
  27602. * @param value defines the dithering state
  27603. */
  27604. setDitheringState(value: boolean): void;
  27605. /**
  27606. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27607. * @param value defines the rasterizer state
  27608. */
  27609. setRasterizerState(value: boolean): void;
  27610. /**
  27611. * stop executing a render loop function and remove it from the execution array
  27612. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27613. */
  27614. stopRenderLoop(renderFunction?: () => void): void;
  27615. /** @hidden */
  27616. _renderLoop(): void;
  27617. /**
  27618. * Register and execute a render loop. The engine can have more than one render function
  27619. * @param renderFunction defines the function to continuously execute
  27620. */
  27621. runRenderLoop(renderFunction: () => void): void;
  27622. /**
  27623. * Toggle full screen mode
  27624. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27625. */
  27626. switchFullscreen(requestPointerLock: boolean): void;
  27627. /**
  27628. * Enters full screen mode
  27629. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27630. */
  27631. enterFullscreen(requestPointerLock: boolean): void;
  27632. /**
  27633. * Exits full screen mode
  27634. */
  27635. exitFullscreen(): void;
  27636. /**
  27637. * Clear the current render buffer or the current render target (if any is set up)
  27638. * @param color defines the color to use
  27639. * @param backBuffer defines if the back buffer must be cleared
  27640. * @param depth defines if the depth buffer must be cleared
  27641. * @param stencil defines if the stencil buffer must be cleared
  27642. */
  27643. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27644. /**
  27645. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27646. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27647. * @param y defines the y-coordinate of the corner of the clear rectangle
  27648. * @param width defines the width of the clear rectangle
  27649. * @param height defines the height of the clear rectangle
  27650. * @param clearColor defines the clear color
  27651. */
  27652. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27653. /**
  27654. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27655. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27656. * @param y defines the y-coordinate of the corner of the clear rectangle
  27657. * @param width defines the width of the clear rectangle
  27658. * @param height defines the height of the clear rectangle
  27659. */
  27660. enableScissor(x: number, y: number, width: number, height: number): void;
  27661. /**
  27662. * Disable previously set scissor test rectangle
  27663. */
  27664. disableScissor(): void;
  27665. private _viewportCached;
  27666. /** @hidden */
  27667. _viewport(x: number, y: number, width: number, height: number): void;
  27668. /**
  27669. * Set the WebGL's viewport
  27670. * @param viewport defines the viewport element to be used
  27671. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27672. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27673. */
  27674. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27675. /**
  27676. * Directly set the WebGL Viewport
  27677. * @param x defines the x coordinate of the viewport (in screen space)
  27678. * @param y defines the y coordinate of the viewport (in screen space)
  27679. * @param width defines the width of the viewport (in screen space)
  27680. * @param height defines the height of the viewport (in screen space)
  27681. * @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
  27682. */
  27683. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27684. /**
  27685. * Begin a new frame
  27686. */
  27687. beginFrame(): void;
  27688. /**
  27689. * Enf the current frame
  27690. */
  27691. endFrame(): void;
  27692. /**
  27693. * Resize the view according to the canvas' size
  27694. */
  27695. resize(): void;
  27696. /**
  27697. * Force a specific size of the canvas
  27698. * @param width defines the new canvas' width
  27699. * @param height defines the new canvas' height
  27700. */
  27701. setSize(width: number, height: number): void;
  27702. /**
  27703. * Gets a boolean indicating if a webVR device was detected
  27704. * @returns true if a webVR device was detected
  27705. */
  27706. isVRDevicePresent(): boolean;
  27707. /**
  27708. * Gets the current webVR device
  27709. * @returns the current webVR device (or null)
  27710. */
  27711. getVRDevice(): any;
  27712. /**
  27713. * Initializes a webVR display and starts listening to display change events
  27714. * The onVRDisplayChangedObservable will be notified upon these changes
  27715. * @returns The onVRDisplayChangedObservable
  27716. */
  27717. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27718. /**
  27719. * Initializes a webVR display and starts listening to display change events
  27720. * The onVRDisplayChangedObservable will be notified upon these changes
  27721. * @returns A promise containing a VRDisplay and if vr is supported
  27722. */
  27723. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27724. /**
  27725. * Call this function to switch to webVR mode
  27726. * Will do nothing if webVR is not supported or if there is no webVR device
  27727. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27728. */
  27729. enableVR(): void;
  27730. /**
  27731. * Call this function to leave webVR mode
  27732. * Will do nothing if webVR is not supported or if there is no webVR device
  27733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27734. */
  27735. disableVR(): void;
  27736. private _onVRFullScreenTriggered;
  27737. private _getVRDisplaysAsync;
  27738. /**
  27739. * Binds the frame buffer to the specified texture.
  27740. * @param texture The texture to render to or null for the default canvas
  27741. * @param faceIndex The face of the texture to render to in case of cube texture
  27742. * @param requiredWidth The width of the target to render to
  27743. * @param requiredHeight The height of the target to render to
  27744. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27745. * @param depthStencilTexture The depth stencil texture to use to render
  27746. * @param lodLevel defines le lod level to bind to the frame buffer
  27747. */
  27748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27749. private bindUnboundFramebuffer;
  27750. /**
  27751. * Unbind the current render target texture from the webGL context
  27752. * @param texture defines the render target texture to unbind
  27753. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27754. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27755. */
  27756. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27757. /**
  27758. * Unbind a list of render target textures from the webGL context
  27759. * This is used only when drawBuffer extension or webGL2 are active
  27760. * @param textures defines the render target textures to unbind
  27761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27763. */
  27764. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27765. /**
  27766. * Force the mipmap generation for the given render target texture
  27767. * @param texture defines the render target texture to use
  27768. */
  27769. generateMipMapsForCubemap(texture: InternalTexture): void;
  27770. /**
  27771. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27772. */
  27773. flushFramebuffer(): void;
  27774. /**
  27775. * Unbind the current render target and bind the default framebuffer
  27776. */
  27777. restoreDefaultFramebuffer(): void;
  27778. /**
  27779. * Create an uniform buffer
  27780. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27781. * @param elements defines the content of the uniform buffer
  27782. * @returns the webGL uniform buffer
  27783. */
  27784. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27785. /**
  27786. * Create a dynamic uniform buffer
  27787. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27788. * @param elements defines the content of the uniform buffer
  27789. * @returns the webGL uniform buffer
  27790. */
  27791. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27792. /**
  27793. * Update an existing uniform buffer
  27794. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27795. * @param uniformBuffer defines the target uniform buffer
  27796. * @param elements defines the content to update
  27797. * @param offset defines the offset in the uniform buffer where update should start
  27798. * @param count defines the size of the data to update
  27799. */
  27800. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27801. private _resetVertexBufferBinding;
  27802. /**
  27803. * Creates a vertex buffer
  27804. * @param data the data for the vertex buffer
  27805. * @returns the new WebGL static buffer
  27806. */
  27807. createVertexBuffer(data: DataArray): WebGLBuffer;
  27808. /**
  27809. * Creates a dynamic vertex buffer
  27810. * @param data the data for the dynamic vertex buffer
  27811. * @returns the new WebGL dynamic buffer
  27812. */
  27813. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27814. /**
  27815. * Update a dynamic index buffer
  27816. * @param indexBuffer defines the target index buffer
  27817. * @param indices defines the data to update
  27818. * @param offset defines the offset in the target index buffer where update should start
  27819. */
  27820. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27821. /**
  27822. * Updates a dynamic vertex buffer.
  27823. * @param vertexBuffer the vertex buffer to update
  27824. * @param data the data used to update the vertex buffer
  27825. * @param byteOffset the byte offset of the data
  27826. * @param byteLength the byte length of the data
  27827. */
  27828. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27829. private _resetIndexBufferBinding;
  27830. /**
  27831. * Creates a new index buffer
  27832. * @param indices defines the content of the index buffer
  27833. * @param updatable defines if the index buffer must be updatable
  27834. * @returns a new webGL buffer
  27835. */
  27836. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27837. /**
  27838. * Bind a webGL buffer to the webGL context
  27839. * @param buffer defines the buffer to bind
  27840. */
  27841. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27842. /**
  27843. * Bind an uniform buffer to the current webGL context
  27844. * @param buffer defines the buffer to bind
  27845. */
  27846. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27847. /**
  27848. * Bind a buffer to the current webGL context at a given location
  27849. * @param buffer defines the buffer to bind
  27850. * @param location defines the index where to bind the buffer
  27851. */
  27852. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27853. /**
  27854. * Bind a specific block at a given index in a specific shader program
  27855. * @param shaderProgram defines the shader program
  27856. * @param blockName defines the block name
  27857. * @param index defines the index where to bind the block
  27858. */
  27859. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27860. private bindIndexBuffer;
  27861. private bindBuffer;
  27862. /**
  27863. * update the bound buffer with the given data
  27864. * @param data defines the data to update
  27865. */
  27866. updateArrayBuffer(data: Float32Array): void;
  27867. private _vertexAttribPointer;
  27868. private _bindIndexBufferWithCache;
  27869. private _bindVertexBuffersAttributes;
  27870. /**
  27871. * Records a vertex array object
  27872. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27873. * @param vertexBuffers defines the list of vertex buffers to store
  27874. * @param indexBuffer defines the index buffer to store
  27875. * @param effect defines the effect to store
  27876. * @returns the new vertex array object
  27877. */
  27878. recordVertexArrayObject(vertexBuffers: {
  27879. [key: string]: VertexBuffer;
  27880. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27881. /**
  27882. * Bind a specific vertex array object
  27883. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27884. * @param vertexArrayObject defines the vertex array object to bind
  27885. * @param indexBuffer defines the index buffer to bind
  27886. */
  27887. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27888. /**
  27889. * Bind webGl buffers directly to the webGL context
  27890. * @param vertexBuffer defines the vertex buffer to bind
  27891. * @param indexBuffer defines the index buffer to bind
  27892. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27893. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27894. * @param effect defines the effect associated with the vertex buffer
  27895. */
  27896. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27897. private _unbindVertexArrayObject;
  27898. /**
  27899. * Bind a list of vertex buffers to the webGL context
  27900. * @param vertexBuffers defines the list of vertex buffers to bind
  27901. * @param indexBuffer defines the index buffer to bind
  27902. * @param effect defines the effect associated with the vertex buffers
  27903. */
  27904. bindBuffers(vertexBuffers: {
  27905. [key: string]: Nullable<VertexBuffer>;
  27906. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27907. /**
  27908. * Unbind all instance attributes
  27909. */
  27910. unbindInstanceAttributes(): void;
  27911. /**
  27912. * Release and free the memory of a vertex array object
  27913. * @param vao defines the vertex array object to delete
  27914. */
  27915. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27916. /** @hidden */
  27917. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27918. /**
  27919. * Creates a webGL buffer to use with instanciation
  27920. * @param capacity defines the size of the buffer
  27921. * @returns the webGL buffer
  27922. */
  27923. createInstancesBuffer(capacity: number): WebGLBuffer;
  27924. /**
  27925. * Delete a webGL buffer used with instanciation
  27926. * @param buffer defines the webGL buffer to delete
  27927. */
  27928. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27929. /**
  27930. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27931. * @param instancesBuffer defines the webGL buffer to update and bind
  27932. * @param data defines the data to store in the buffer
  27933. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27934. */
  27935. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27936. /**
  27937. * Apply all cached states (depth, culling, stencil and alpha)
  27938. */
  27939. applyStates(): void;
  27940. /**
  27941. * Send a draw order
  27942. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27943. * @param indexStart defines the starting index
  27944. * @param indexCount defines the number of index to draw
  27945. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27946. */
  27947. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27948. /**
  27949. * Draw a list of points
  27950. * @param verticesStart defines the index of first vertex to draw
  27951. * @param verticesCount defines the count of vertices to draw
  27952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27953. */
  27954. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27955. /**
  27956. * Draw a list of unindexed primitives
  27957. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27958. * @param verticesStart defines the index of first vertex to draw
  27959. * @param verticesCount defines the count of vertices to draw
  27960. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27961. */
  27962. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27963. /**
  27964. * Draw a list of indexed primitives
  27965. * @param fillMode defines the primitive to use
  27966. * @param indexStart defines the starting index
  27967. * @param indexCount defines the number of index to draw
  27968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27969. */
  27970. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27971. /**
  27972. * Draw a list of unindexed primitives
  27973. * @param fillMode defines the primitive to use
  27974. * @param verticesStart defines the index of first vertex to draw
  27975. * @param verticesCount defines the count of vertices to draw
  27976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27977. */
  27978. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27979. private _drawMode;
  27980. /** @hidden */
  27981. _releaseEffect(effect: Effect): void;
  27982. /** @hidden */
  27983. _deleteProgram(program: WebGLProgram): void;
  27984. /**
  27985. * Create a new effect (used to store vertex/fragment shaders)
  27986. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27987. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27988. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27989. * @param samplers defines an array of string used to represent textures
  27990. * @param defines defines the string containing the defines to use to compile the shaders
  27991. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27992. * @param onCompiled defines a function to call when the effect creation is successful
  27993. * @param onError defines a function to call when the effect creation has failed
  27994. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27995. * @returns the new Effect
  27996. */
  27997. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27998. private _compileShader;
  27999. private _compileRawShader;
  28000. /**
  28001. * Directly creates a webGL program
  28002. * @param vertexCode defines the vertex shader code to use
  28003. * @param fragmentCode defines the fragment shader code to use
  28004. * @param context defines the webGL context to use (if not set, the current one will be used)
  28005. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28006. * @returns the new webGL program
  28007. */
  28008. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28009. /**
  28010. * Creates a webGL program
  28011. * @param vertexCode defines the vertex shader code to use
  28012. * @param fragmentCode defines the fragment shader code to use
  28013. * @param defines defines the string containing the defines to use to compile the shaders
  28014. * @param context defines the webGL context to use (if not set, the current one will be used)
  28015. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28016. * @returns the new webGL program
  28017. */
  28018. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28019. private _createShaderProgram;
  28020. private _finalizeProgram;
  28021. /** @hidden */
  28022. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28023. /** @hidden */
  28024. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28025. /**
  28026. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28027. * @param shaderProgram defines the webGL program to use
  28028. * @param uniformsNames defines the list of uniform names
  28029. * @returns an array of webGL uniform locations
  28030. */
  28031. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28032. /**
  28033. * Gets the lsit of active attributes for a given webGL program
  28034. * @param shaderProgram defines the webGL program to use
  28035. * @param attributesNames defines the list of attribute names to get
  28036. * @returns an array of indices indicating the offset of each attribute
  28037. */
  28038. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28039. /**
  28040. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28041. * @param effect defines the effect to activate
  28042. */
  28043. enableEffect(effect: Nullable<Effect>): void;
  28044. /**
  28045. * Set the value of an uniform to an array of int32
  28046. * @param uniform defines the webGL uniform location where to store the value
  28047. * @param array defines the array of int32 to store
  28048. */
  28049. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28050. /**
  28051. * Set the value of an uniform to an array of int32 (stored as vec2)
  28052. * @param uniform defines the webGL uniform location where to store the value
  28053. * @param array defines the array of int32 to store
  28054. */
  28055. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28056. /**
  28057. * Set the value of an uniform to an array of int32 (stored as vec3)
  28058. * @param uniform defines the webGL uniform location where to store the value
  28059. * @param array defines the array of int32 to store
  28060. */
  28061. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28062. /**
  28063. * Set the value of an uniform to an array of int32 (stored as vec4)
  28064. * @param uniform defines the webGL uniform location where to store the value
  28065. * @param array defines the array of int32 to store
  28066. */
  28067. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28068. /**
  28069. * Set the value of an uniform to an array of float32
  28070. * @param uniform defines the webGL uniform location where to store the value
  28071. * @param array defines the array of float32 to store
  28072. */
  28073. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28074. /**
  28075. * Set the value of an uniform to an array of float32 (stored as vec2)
  28076. * @param uniform defines the webGL uniform location where to store the value
  28077. * @param array defines the array of float32 to store
  28078. */
  28079. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28080. /**
  28081. * Set the value of an uniform to an array of float32 (stored as vec3)
  28082. * @param uniform defines the webGL uniform location where to store the value
  28083. * @param array defines the array of float32 to store
  28084. */
  28085. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28086. /**
  28087. * Set the value of an uniform to an array of float32 (stored as vec4)
  28088. * @param uniform defines the webGL uniform location where to store the value
  28089. * @param array defines the array of float32 to store
  28090. */
  28091. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28092. /**
  28093. * Set the value of an uniform to an array of number
  28094. * @param uniform defines the webGL uniform location where to store the value
  28095. * @param array defines the array of number to store
  28096. */
  28097. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28098. /**
  28099. * Set the value of an uniform to an array of number (stored as vec2)
  28100. * @param uniform defines the webGL uniform location where to store the value
  28101. * @param array defines the array of number to store
  28102. */
  28103. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28104. /**
  28105. * Set the value of an uniform to an array of number (stored as vec3)
  28106. * @param uniform defines the webGL uniform location where to store the value
  28107. * @param array defines the array of number to store
  28108. */
  28109. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28110. /**
  28111. * Set the value of an uniform to an array of number (stored as vec4)
  28112. * @param uniform defines the webGL uniform location where to store the value
  28113. * @param array defines the array of number to store
  28114. */
  28115. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28116. /**
  28117. * Set the value of an uniform to an array of float32 (stored as matrices)
  28118. * @param uniform defines the webGL uniform location where to store the value
  28119. * @param matrices defines the array of float32 to store
  28120. */
  28121. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28122. /**
  28123. * Set the value of an uniform to a matrix
  28124. * @param uniform defines the webGL uniform location where to store the value
  28125. * @param matrix defines the matrix to store
  28126. */
  28127. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28128. /**
  28129. * Set the value of an uniform to a matrix (3x3)
  28130. * @param uniform defines the webGL uniform location where to store the value
  28131. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28132. */
  28133. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28134. /**
  28135. * Set the value of an uniform to a matrix (2x2)
  28136. * @param uniform defines the webGL uniform location where to store the value
  28137. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28138. */
  28139. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28140. /**
  28141. * Set the value of an uniform to a number (int)
  28142. * @param uniform defines the webGL uniform location where to store the value
  28143. * @param value defines the int number to store
  28144. */
  28145. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28146. /**
  28147. * Set the value of an uniform to a number (float)
  28148. * @param uniform defines the webGL uniform location where to store the value
  28149. * @param value defines the float number to store
  28150. */
  28151. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28152. /**
  28153. * Set the value of an uniform to a vec2
  28154. * @param uniform defines the webGL uniform location where to store the value
  28155. * @param x defines the 1st component of the value
  28156. * @param y defines the 2nd component of the value
  28157. */
  28158. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28159. /**
  28160. * Set the value of an uniform to a vec3
  28161. * @param uniform defines the webGL uniform location where to store the value
  28162. * @param x defines the 1st component of the value
  28163. * @param y defines the 2nd component of the value
  28164. * @param z defines the 3rd component of the value
  28165. */
  28166. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28167. /**
  28168. * Set the value of an uniform to a boolean
  28169. * @param uniform defines the webGL uniform location where to store the value
  28170. * @param bool defines the boolean to store
  28171. */
  28172. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28173. /**
  28174. * Set the value of an uniform to a vec4
  28175. * @param uniform defines the webGL uniform location where to store the value
  28176. * @param x defines the 1st component of the value
  28177. * @param y defines the 2nd component of the value
  28178. * @param z defines the 3rd component of the value
  28179. * @param w defines the 4th component of the value
  28180. */
  28181. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28182. /**
  28183. * Set the value of an uniform to a Color3
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param color3 defines the color to store
  28186. */
  28187. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28188. /**
  28189. * Set the value of an uniform to a Color3 and an alpha value
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param color3 defines the color to store
  28192. * @param alpha defines the alpha component to store
  28193. */
  28194. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28195. /**
  28196. * Sets a Color4 on a uniform variable
  28197. * @param uniform defines the uniform location
  28198. * @param color4 defines the value to be set
  28199. */
  28200. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28201. /**
  28202. * Set various states to the webGL context
  28203. * @param culling defines backface culling state
  28204. * @param zOffset defines the value to apply to zOffset (0 by default)
  28205. * @param force defines if states must be applied even if cache is up to date
  28206. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28207. */
  28208. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28209. /**
  28210. * Set the z offset to apply to current rendering
  28211. * @param value defines the offset to apply
  28212. */
  28213. setZOffset(value: number): void;
  28214. /**
  28215. * Gets the current value of the zOffset
  28216. * @returns the current zOffset state
  28217. */
  28218. getZOffset(): number;
  28219. /**
  28220. * Enable or disable depth buffering
  28221. * @param enable defines the state to set
  28222. */
  28223. setDepthBuffer(enable: boolean): void;
  28224. /**
  28225. * Gets a boolean indicating if depth writing is enabled
  28226. * @returns the current depth writing state
  28227. */
  28228. getDepthWrite(): boolean;
  28229. /**
  28230. * Enable or disable depth writing
  28231. * @param enable defines the state to set
  28232. */
  28233. setDepthWrite(enable: boolean): void;
  28234. /**
  28235. * Enable or disable color writing
  28236. * @param enable defines the state to set
  28237. */
  28238. setColorWrite(enable: boolean): void;
  28239. /**
  28240. * Gets a boolean indicating if color writing is enabled
  28241. * @returns the current color writing state
  28242. */
  28243. getColorWrite(): boolean;
  28244. /**
  28245. * Sets alpha constants used by some alpha blending modes
  28246. * @param r defines the red component
  28247. * @param g defines the green component
  28248. * @param b defines the blue component
  28249. * @param a defines the alpha component
  28250. */
  28251. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28252. /**
  28253. * Sets the current alpha mode
  28254. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28255. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28257. */
  28258. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28259. /**
  28260. * Gets the current alpha mode
  28261. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28262. * @returns the current alpha mode
  28263. */
  28264. getAlphaMode(): number;
  28265. /**
  28266. * Clears the list of texture accessible through engine.
  28267. * This can help preventing texture load conflict due to name collision.
  28268. */
  28269. clearInternalTexturesCache(): void;
  28270. /**
  28271. * Force the entire cache to be cleared
  28272. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28273. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28274. */
  28275. wipeCaches(bruteForce?: boolean): void;
  28276. /**
  28277. * Set the compressed texture format to use, based on the formats you have, and the formats
  28278. * supported by the hardware / browser.
  28279. *
  28280. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28281. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28282. * to API arguments needed to compressed textures. This puts the burden on the container
  28283. * generator to house the arcane code for determining these for current & future formats.
  28284. *
  28285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28287. *
  28288. * Note: The result of this call is not taken into account when a texture is base64.
  28289. *
  28290. * @param formatsAvailable defines the list of those format families you have created
  28291. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28292. *
  28293. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28294. * @returns The extension selected.
  28295. */
  28296. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28297. private _getSamplingParameters;
  28298. private _partialLoadImg;
  28299. private _cascadeLoadImgs;
  28300. /** @hidden */
  28301. _createTexture(): WebGLTexture;
  28302. /**
  28303. * Usually called from Texture.ts.
  28304. * Passed information to create a WebGLTexture
  28305. * @param urlArg defines a value which contains one of the following:
  28306. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28307. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28308. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28309. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28310. * @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)
  28311. * @param scene needed for loading to the correct scene
  28312. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28313. * @param onLoad optional callback to be called upon successful completion
  28314. * @param onError optional callback to be called upon failure
  28315. * @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
  28316. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28317. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28318. * @param forcedExtension defines the extension to use to pick the right loader
  28319. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28320. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28321. */
  28322. 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;
  28323. private _rescaleTexture;
  28324. /**
  28325. * Update a raw texture
  28326. * @param texture defines the texture to update
  28327. * @param data defines the data to store in the texture
  28328. * @param format defines the format of the data
  28329. * @param invertY defines if data must be stored with Y axis inverted
  28330. * @param compression defines the compression used (null by default)
  28331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28332. */
  28333. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28334. /**
  28335. * Creates a raw texture
  28336. * @param data defines the data to store in the texture
  28337. * @param width defines the width of the texture
  28338. * @param height defines the height of the texture
  28339. * @param format defines the format of the data
  28340. * @param generateMipMaps defines if the engine should generate the mip levels
  28341. * @param invertY defines if data must be stored with Y axis inverted
  28342. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28343. * @param compression defines the compression used (null by default)
  28344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28345. * @returns the raw texture inside an InternalTexture
  28346. */
  28347. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28348. private _unpackFlipYCached;
  28349. /**
  28350. * In case you are sharing the context with other applications, it might
  28351. * be interested to not cache the unpack flip y state to ensure a consistent
  28352. * value would be set.
  28353. */
  28354. enableUnpackFlipYCached: boolean;
  28355. /** @hidden */
  28356. _unpackFlipY(value: boolean): void;
  28357. /** @hidden */
  28358. _getUnpackAlignement(): number;
  28359. /**
  28360. * Creates a dynamic texture
  28361. * @param width defines the width of the texture
  28362. * @param height defines the height of the texture
  28363. * @param generateMipMaps defines if the engine should generate the mip levels
  28364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28365. * @returns the dynamic texture inside an InternalTexture
  28366. */
  28367. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28368. /**
  28369. * Update the sampling mode of a given texture
  28370. * @param samplingMode defines the required sampling mode
  28371. * @param texture defines the texture to update
  28372. */
  28373. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28374. /**
  28375. * Update the content of a dynamic texture
  28376. * @param texture defines the texture to update
  28377. * @param canvas defines the canvas containing the source
  28378. * @param invertY defines if data must be stored with Y axis inverted
  28379. * @param premulAlpha defines if alpha is stored as premultiplied
  28380. * @param format defines the format of the data
  28381. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28382. */
  28383. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28384. /**
  28385. * Update a video texture
  28386. * @param texture defines the texture to update
  28387. * @param video defines the video element to use
  28388. * @param invertY defines if data must be stored with Y axis inverted
  28389. */
  28390. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28391. /**
  28392. * Updates a depth texture Comparison Mode and Function.
  28393. * If the comparison Function is equal to 0, the mode will be set to none.
  28394. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28395. * @param texture The texture to set the comparison function for
  28396. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28397. */
  28398. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28399. private _setupDepthStencilTexture;
  28400. /**
  28401. * Creates a depth stencil texture.
  28402. * This is only available in WebGL 2 or with the depth texture extension available.
  28403. * @param size The size of face edge in the texture.
  28404. * @param options The options defining the texture.
  28405. * @returns The texture
  28406. */
  28407. createDepthStencilTexture(size: number | {
  28408. width: number;
  28409. height: number;
  28410. }, options: DepthTextureCreationOptions): InternalTexture;
  28411. /**
  28412. * Creates a depth stencil texture.
  28413. * This is only available in WebGL 2 or with the depth texture extension available.
  28414. * @param size The size of face edge in the texture.
  28415. * @param options The options defining the texture.
  28416. * @returns The texture
  28417. */
  28418. private _createDepthStencilTexture;
  28419. /**
  28420. * Creates a depth stencil cube texture.
  28421. * This is only available in WebGL 2.
  28422. * @param size The size of face edge in the cube texture.
  28423. * @param options The options defining the cube texture.
  28424. * @returns The cube texture
  28425. */
  28426. private _createDepthStencilCubeTexture;
  28427. /**
  28428. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28429. * @param renderTarget The render target to set the frame buffer for
  28430. */
  28431. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28432. /**
  28433. * Creates a new render target texture
  28434. * @param size defines the size of the texture
  28435. * @param options defines the options used to create the texture
  28436. * @returns a new render target texture stored in an InternalTexture
  28437. */
  28438. createRenderTargetTexture(size: number | {
  28439. width: number;
  28440. height: number;
  28441. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28442. /**
  28443. * Create a multi render target texture
  28444. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28445. * @param size defines the size of the texture
  28446. * @param options defines the creation options
  28447. * @returns the cube texture as an InternalTexture
  28448. */
  28449. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28450. private _setupFramebufferDepthAttachments;
  28451. /**
  28452. * Updates the sample count of a render target texture
  28453. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28454. * @param texture defines the texture to update
  28455. * @param samples defines the sample count to set
  28456. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28457. */
  28458. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28459. /**
  28460. * Update the sample count for a given multiple render target texture
  28461. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28462. * @param textures defines the textures to update
  28463. * @param samples defines the sample count to set
  28464. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28465. */
  28466. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28467. /** @hidden */
  28468. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28469. /** @hidden */
  28470. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28471. /** @hidden */
  28472. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28473. /** @hidden */
  28474. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28475. /**
  28476. * Creates a new render target cube texture
  28477. * @param size defines the size of the texture
  28478. * @param options defines the options used to create the texture
  28479. * @returns a new render target cube texture stored in an InternalTexture
  28480. */
  28481. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28482. /**
  28483. * Creates a cube texture
  28484. * @param rootUrl defines the url where the files to load is located
  28485. * @param scene defines the current scene
  28486. * @param files defines the list of files to load (1 per face)
  28487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28488. * @param onLoad defines an optional callback raised when the texture is loaded
  28489. * @param onError defines an optional callback raised if there is an issue to load the texture
  28490. * @param format defines the format of the data
  28491. * @param forcedExtension defines the extension to use to pick the right loader
  28492. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28495. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28496. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28497. * @returns the cube texture as an InternalTexture
  28498. */
  28499. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28500. /**
  28501. * @hidden
  28502. */
  28503. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28504. /**
  28505. * Update a raw cube texture
  28506. * @param texture defines the texture to udpdate
  28507. * @param data defines the data to store
  28508. * @param format defines the data format
  28509. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28510. * @param invertY defines if data must be stored with Y axis inverted
  28511. * @param compression defines the compression used (null by default)
  28512. * @param level defines which level of the texture to update
  28513. */
  28514. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28515. /**
  28516. * Creates a new raw cube texture
  28517. * @param data defines the array of data to use to create each face
  28518. * @param size defines the size of the textures
  28519. * @param format defines the format of the data
  28520. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28521. * @param generateMipMaps defines if the engine should generate the mip levels
  28522. * @param invertY defines if data must be stored with Y axis inverted
  28523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28524. * @param compression defines the compression used (null by default)
  28525. * @returns the cube texture as an InternalTexture
  28526. */
  28527. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28528. /**
  28529. * Creates a new raw cube texture from a specified url
  28530. * @param url defines the url where the data is located
  28531. * @param scene defines the current scene
  28532. * @param size defines the size of the textures
  28533. * @param format defines the format of the data
  28534. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28535. * @param noMipmap defines if the engine should avoid generating the mip levels
  28536. * @param callback defines a callback used to extract texture data from loaded data
  28537. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28538. * @param onLoad defines a callback called when texture is loaded
  28539. * @param onError defines a callback called if there is an error
  28540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28541. * @param invertY defines if data must be stored with Y axis inverted
  28542. * @returns the cube texture as an InternalTexture
  28543. */
  28544. 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;
  28545. /**
  28546. * Update a raw 3D texture
  28547. * @param texture defines the texture to update
  28548. * @param data defines the data to store
  28549. * @param format defines the data format
  28550. * @param invertY defines if data must be stored with Y axis inverted
  28551. * @param compression defines the used compression (can be null)
  28552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28553. */
  28554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28555. /**
  28556. * Creates a new raw 3D texture
  28557. * @param data defines the data used to create the texture
  28558. * @param width defines the width of the texture
  28559. * @param height defines the height of the texture
  28560. * @param depth defines the depth of the texture
  28561. * @param format defines the format of the texture
  28562. * @param generateMipMaps defines if the engine must generate mip levels
  28563. * @param invertY defines if data must be stored with Y axis inverted
  28564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28565. * @param compression defines the compressed used (can be null)
  28566. * @param textureType defines the compressed used (can be null)
  28567. * @returns a new raw 3D texture (stored in an InternalTexture)
  28568. */
  28569. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28570. private _prepareWebGLTextureContinuation;
  28571. private _prepareWebGLTexture;
  28572. private _convertRGBtoRGBATextureData;
  28573. /** @hidden */
  28574. _releaseFramebufferObjects(texture: InternalTexture): void;
  28575. /** @hidden */
  28576. _releaseTexture(texture: InternalTexture): void;
  28577. private setProgram;
  28578. private _boundUniforms;
  28579. /**
  28580. * Binds an effect to the webGL context
  28581. * @param effect defines the effect to bind
  28582. */
  28583. bindSamplers(effect: Effect): void;
  28584. private _moveBoundTextureOnTop;
  28585. private _getCorrectTextureChannel;
  28586. private _linkTrackers;
  28587. private _removeDesignatedSlot;
  28588. private _activateCurrentTexture;
  28589. /** @hidden */
  28590. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28591. /** @hidden */
  28592. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28593. /**
  28594. * Sets a texture to the webGL context from a postprocess
  28595. * @param channel defines the channel to use
  28596. * @param postProcess defines the source postprocess
  28597. */
  28598. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28599. /**
  28600. * Binds the output of the passed in post process to the texture channel specified
  28601. * @param channel The channel the texture should be bound to
  28602. * @param postProcess The post process which's output should be bound
  28603. */
  28604. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28605. /**
  28606. * Unbind all textures from the webGL context
  28607. */
  28608. unbindAllTextures(): void;
  28609. /**
  28610. * Sets a texture to the according uniform.
  28611. * @param channel The texture channel
  28612. * @param uniform The uniform to set
  28613. * @param texture The texture to apply
  28614. */
  28615. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28616. /**
  28617. * Sets a depth stencil texture from a render target to the according uniform.
  28618. * @param channel The texture channel
  28619. * @param uniform The uniform to set
  28620. * @param texture The render target texture containing the depth stencil texture to apply
  28621. */
  28622. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28623. private _bindSamplerUniformToChannel;
  28624. private _getTextureWrapMode;
  28625. private _setTexture;
  28626. /**
  28627. * Sets an array of texture to the webGL context
  28628. * @param channel defines the channel where the texture array must be set
  28629. * @param uniform defines the associated uniform location
  28630. * @param textures defines the array of textures to bind
  28631. */
  28632. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28633. /** @hidden */
  28634. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28635. private _setTextureParameterFloat;
  28636. private _setTextureParameterInteger;
  28637. /**
  28638. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28639. * @param x defines the x coordinate of the rectangle where pixels must be read
  28640. * @param y defines the y coordinate of the rectangle where pixels must be read
  28641. * @param width defines the width of the rectangle where pixels must be read
  28642. * @param height defines the height of the rectangle where pixels must be read
  28643. * @returns a Uint8Array containing RGBA colors
  28644. */
  28645. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28646. /**
  28647. * Add an externaly attached data from its key.
  28648. * This method call will fail and return false, if such key already exists.
  28649. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28650. * @param key the unique key that identifies the data
  28651. * @param data the data object to associate to the key for this Engine instance
  28652. * @return true if no such key were already present and the data was added successfully, false otherwise
  28653. */
  28654. addExternalData<T>(key: string, data: T): boolean;
  28655. /**
  28656. * Get an externaly attached data from its key
  28657. * @param key the unique key that identifies the data
  28658. * @return the associated data, if present (can be null), or undefined if not present
  28659. */
  28660. getExternalData<T>(key: string): T;
  28661. /**
  28662. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28663. * @param key the unique key that identifies the data
  28664. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28665. * @return the associated data, can be null if the factory returned null.
  28666. */
  28667. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28668. /**
  28669. * Remove an externaly attached data from the Engine instance
  28670. * @param key the unique key that identifies the data
  28671. * @return true if the data was successfully removed, false if it doesn't exist
  28672. */
  28673. removeExternalData(key: string): boolean;
  28674. /**
  28675. * Unbind all vertex attributes from the webGL context
  28676. */
  28677. unbindAllAttributes(): void;
  28678. /**
  28679. * 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
  28680. */
  28681. releaseEffects(): void;
  28682. /**
  28683. * Dispose and release all associated resources
  28684. */
  28685. dispose(): void;
  28686. /**
  28687. * Display the loading screen
  28688. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28689. */
  28690. displayLoadingUI(): void;
  28691. /**
  28692. * Hide the loading screen
  28693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28694. */
  28695. hideLoadingUI(): void;
  28696. /**
  28697. * Gets the current loading screen object
  28698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28699. */
  28700. /**
  28701. * Sets the current loading screen object
  28702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28703. */
  28704. loadingScreen: ILoadingScreen;
  28705. /**
  28706. * Sets the current loading screen text
  28707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28708. */
  28709. loadingUIText: string;
  28710. /**
  28711. * Sets the current loading screen background color
  28712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28713. */
  28714. loadingUIBackgroundColor: string;
  28715. /**
  28716. * Attach a new callback raised when context lost event is fired
  28717. * @param callback defines the callback to call
  28718. */
  28719. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28720. /**
  28721. * Attach a new callback raised when context restored event is fired
  28722. * @param callback defines the callback to call
  28723. */
  28724. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28725. /**
  28726. * Gets the source code of the vertex shader associated with a specific webGL program
  28727. * @param program defines the program to use
  28728. * @returns a string containing the source code of the vertex shader associated with the program
  28729. */
  28730. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28731. /**
  28732. * Gets the source code of the fragment shader associated with a specific webGL program
  28733. * @param program defines the program to use
  28734. * @returns a string containing the source code of the fragment shader associated with the program
  28735. */
  28736. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28737. /**
  28738. * Get the current error code of the webGL context
  28739. * @returns the error code
  28740. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28741. */
  28742. getError(): number;
  28743. /**
  28744. * Gets the current framerate
  28745. * @returns a number representing the framerate
  28746. */
  28747. getFps(): number;
  28748. /**
  28749. * Gets the time spent between current and previous frame
  28750. * @returns a number representing the delta time in ms
  28751. */
  28752. getDeltaTime(): number;
  28753. private _measureFps;
  28754. /** @hidden */
  28755. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28756. private _canRenderToFloatFramebuffer;
  28757. private _canRenderToHalfFloatFramebuffer;
  28758. private _canRenderToFramebuffer;
  28759. /** @hidden */
  28760. _getWebGLTextureType(type: number): number;
  28761. private _getInternalFormat;
  28762. /** @hidden */
  28763. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28764. /** @hidden */
  28765. _getRGBAMultiSampleBufferFormat(type: number): number;
  28766. /** @hidden */
  28767. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28768. /** @hidden */
  28769. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28770. private _partialLoadFile;
  28771. private _cascadeLoadFiles;
  28772. /**
  28773. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28774. * @returns true if the engine can be created
  28775. * @ignorenaming
  28776. */
  28777. static isSupported(): boolean;
  28778. }
  28779. }
  28780. declare module "babylonjs/Materials/effect" {
  28781. import { Observable } from "babylonjs/Misc/observable";
  28782. import { Nullable } from "babylonjs/types";
  28783. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28784. import { Engine } from "babylonjs/Engines/engine";
  28785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28790. /**
  28791. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28792. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28793. */
  28794. export class EffectFallbacks {
  28795. private _defines;
  28796. private _currentRank;
  28797. private _maxRank;
  28798. private _mesh;
  28799. /**
  28800. * Removes the fallback from the bound mesh.
  28801. */
  28802. unBindMesh(): void;
  28803. /**
  28804. * Adds a fallback on the specified property.
  28805. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28806. * @param define The name of the define in the shader
  28807. */
  28808. addFallback(rank: number, define: string): void;
  28809. /**
  28810. * Sets the mesh to use CPU skinning when needing to fallback.
  28811. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28812. * @param mesh The mesh to use the fallbacks.
  28813. */
  28814. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28815. /**
  28816. * Checks to see if more fallbacks are still availible.
  28817. */
  28818. readonly isMoreFallbacks: boolean;
  28819. /**
  28820. * Removes the defines that shoould be removed when falling back.
  28821. * @param currentDefines defines the current define statements for the shader.
  28822. * @param effect defines the current effect we try to compile
  28823. * @returns The resulting defines with defines of the current rank removed.
  28824. */
  28825. reduce(currentDefines: string, effect: Effect): string;
  28826. }
  28827. /**
  28828. * Options to be used when creating an effect.
  28829. */
  28830. export class EffectCreationOptions {
  28831. /**
  28832. * Atrributes that will be used in the shader.
  28833. */
  28834. attributes: string[];
  28835. /**
  28836. * Uniform varible names that will be set in the shader.
  28837. */
  28838. uniformsNames: string[];
  28839. /**
  28840. * Uniform buffer varible names that will be set in the shader.
  28841. */
  28842. uniformBuffersNames: string[];
  28843. /**
  28844. * Sampler texture variable names that will be set in the shader.
  28845. */
  28846. samplers: string[];
  28847. /**
  28848. * Define statements that will be set in the shader.
  28849. */
  28850. defines: any;
  28851. /**
  28852. * Possible fallbacks for this effect to improve performance when needed.
  28853. */
  28854. fallbacks: Nullable<EffectFallbacks>;
  28855. /**
  28856. * Callback that will be called when the shader is compiled.
  28857. */
  28858. onCompiled: Nullable<(effect: Effect) => void>;
  28859. /**
  28860. * Callback that will be called if an error occurs during shader compilation.
  28861. */
  28862. onError: Nullable<(effect: Effect, errors: string) => void>;
  28863. /**
  28864. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28865. */
  28866. indexParameters: any;
  28867. /**
  28868. * Max number of lights that can be used in the shader.
  28869. */
  28870. maxSimultaneousLights: number;
  28871. /**
  28872. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28873. */
  28874. transformFeedbackVaryings: Nullable<string[]>;
  28875. }
  28876. /**
  28877. * Effect containing vertex and fragment shader that can be executed on an object.
  28878. */
  28879. export class Effect {
  28880. /**
  28881. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28882. */
  28883. static ShadersRepository: string;
  28884. /**
  28885. * Name of the effect.
  28886. */
  28887. name: any;
  28888. /**
  28889. * String container all the define statements that should be set on the shader.
  28890. */
  28891. defines: string;
  28892. /**
  28893. * Callback that will be called when the shader is compiled.
  28894. */
  28895. onCompiled: Nullable<(effect: Effect) => void>;
  28896. /**
  28897. * Callback that will be called if an error occurs during shader compilation.
  28898. */
  28899. onError: Nullable<(effect: Effect, errors: string) => void>;
  28900. /**
  28901. * Callback that will be called when effect is bound.
  28902. */
  28903. onBind: Nullable<(effect: Effect) => void>;
  28904. /**
  28905. * Unique ID of the effect.
  28906. */
  28907. uniqueId: number;
  28908. /**
  28909. * Observable that will be called when the shader is compiled.
  28910. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28911. */
  28912. onCompileObservable: Observable<Effect>;
  28913. /**
  28914. * Observable that will be called if an error occurs during shader compilation.
  28915. */
  28916. onErrorObservable: Observable<Effect>;
  28917. /** @hidden */
  28918. _onBindObservable: Nullable<Observable<Effect>>;
  28919. /**
  28920. * Observable that will be called when effect is bound.
  28921. */
  28922. readonly onBindObservable: Observable<Effect>;
  28923. /** @hidden */
  28924. _bonesComputationForcedToCPU: boolean;
  28925. private static _uniqueIdSeed;
  28926. private _engine;
  28927. private _uniformBuffersNames;
  28928. private _uniformsNames;
  28929. private _samplers;
  28930. private _isReady;
  28931. private _compilationError;
  28932. private _attributesNames;
  28933. private _attributes;
  28934. private _uniforms;
  28935. /**
  28936. * Key for the effect.
  28937. * @hidden
  28938. */
  28939. _key: string;
  28940. private _indexParameters;
  28941. private _fallbacks;
  28942. private _vertexSourceCode;
  28943. private _fragmentSourceCode;
  28944. private _vertexSourceCodeOverride;
  28945. private _fragmentSourceCodeOverride;
  28946. private _transformFeedbackVaryings;
  28947. /**
  28948. * Compiled shader to webGL program.
  28949. * @hidden
  28950. */
  28951. _program: WebGLProgram;
  28952. private _valueCache;
  28953. private static _baseCache;
  28954. /**
  28955. * Instantiates an effect.
  28956. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28957. * @param baseName Name of the effect.
  28958. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28959. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28960. * @param samplers List of sampler variables that will be passed to the shader.
  28961. * @param engine Engine to be used to render the effect
  28962. * @param defines Define statements to be added to the shader.
  28963. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28964. * @param onCompiled Callback that will be called when the shader is compiled.
  28965. * @param onError Callback that will be called if an error occurs during shader compilation.
  28966. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28967. */
  28968. 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);
  28969. /**
  28970. * Unique key for this effect
  28971. */
  28972. readonly key: string;
  28973. /**
  28974. * If the effect has been compiled and prepared.
  28975. * @returns if the effect is compiled and prepared.
  28976. */
  28977. isReady(): boolean;
  28978. /**
  28979. * The engine the effect was initialized with.
  28980. * @returns the engine.
  28981. */
  28982. getEngine(): Engine;
  28983. /**
  28984. * The compiled webGL program for the effect
  28985. * @returns the webGL program.
  28986. */
  28987. getProgram(): WebGLProgram;
  28988. /**
  28989. * The set of names of attribute variables for the shader.
  28990. * @returns An array of attribute names.
  28991. */
  28992. getAttributesNames(): string[];
  28993. /**
  28994. * Returns the attribute at the given index.
  28995. * @param index The index of the attribute.
  28996. * @returns The location of the attribute.
  28997. */
  28998. getAttributeLocation(index: number): number;
  28999. /**
  29000. * Returns the attribute based on the name of the variable.
  29001. * @param name of the attribute to look up.
  29002. * @returns the attribute location.
  29003. */
  29004. getAttributeLocationByName(name: string): number;
  29005. /**
  29006. * The number of attributes.
  29007. * @returns the numnber of attributes.
  29008. */
  29009. getAttributesCount(): number;
  29010. /**
  29011. * Gets the index of a uniform variable.
  29012. * @param uniformName of the uniform to look up.
  29013. * @returns the index.
  29014. */
  29015. getUniformIndex(uniformName: string): number;
  29016. /**
  29017. * Returns the attribute based on the name of the variable.
  29018. * @param uniformName of the uniform to look up.
  29019. * @returns the location of the uniform.
  29020. */
  29021. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29022. /**
  29023. * Returns an array of sampler variable names
  29024. * @returns The array of sampler variable neames.
  29025. */
  29026. getSamplers(): string[];
  29027. /**
  29028. * The error from the last compilation.
  29029. * @returns the error string.
  29030. */
  29031. getCompilationError(): string;
  29032. /**
  29033. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29034. * @param func The callback to be used.
  29035. */
  29036. executeWhenCompiled(func: (effect: Effect) => void): void;
  29037. private _checkIsReady;
  29038. /** @hidden */
  29039. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29040. /** @hidden */
  29041. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29042. /** @hidden */
  29043. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29044. private _processShaderConversion;
  29045. private _processIncludes;
  29046. private _processPrecision;
  29047. /**
  29048. * Recompiles the webGL program
  29049. * @param vertexSourceCode The source code for the vertex shader.
  29050. * @param fragmentSourceCode The source code for the fragment shader.
  29051. * @param onCompiled Callback called when completed.
  29052. * @param onError Callback called on error.
  29053. * @hidden
  29054. */
  29055. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29056. /**
  29057. * Gets the uniform locations of the the specified variable names
  29058. * @param names THe names of the variables to lookup.
  29059. * @returns Array of locations in the same order as variable names.
  29060. */
  29061. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29062. /**
  29063. * Prepares the effect
  29064. * @hidden
  29065. */
  29066. _prepareEffect(): void;
  29067. /**
  29068. * Checks if the effect is supported. (Must be called after compilation)
  29069. */
  29070. readonly isSupported: boolean;
  29071. /**
  29072. * Binds a texture to the engine to be used as output of the shader.
  29073. * @param channel Name of the output variable.
  29074. * @param texture Texture to bind.
  29075. * @hidden
  29076. */
  29077. _bindTexture(channel: string, texture: InternalTexture): void;
  29078. /**
  29079. * Sets a texture on the engine to be used in the shader.
  29080. * @param channel Name of the sampler variable.
  29081. * @param texture Texture to set.
  29082. */
  29083. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29084. /**
  29085. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29086. * @param channel Name of the sampler variable.
  29087. * @param texture Texture to set.
  29088. */
  29089. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29090. /**
  29091. * Sets an array of textures on the engine to be used in the shader.
  29092. * @param channel Name of the variable.
  29093. * @param textures Textures to set.
  29094. */
  29095. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29096. /**
  29097. * 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)
  29098. * @param channel Name of the sampler variable.
  29099. * @param postProcess Post process to get the input texture from.
  29100. */
  29101. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29102. /**
  29103. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29104. * 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)
  29105. * @param channel Name of the sampler variable.
  29106. * @param postProcess Post process to get the output texture from.
  29107. */
  29108. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29109. /** @hidden */
  29110. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29111. /** @hidden */
  29112. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29113. /** @hidden */
  29114. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29115. /** @hidden */
  29116. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29117. /**
  29118. * Binds a buffer to a uniform.
  29119. * @param buffer Buffer to bind.
  29120. * @param name Name of the uniform variable to bind to.
  29121. */
  29122. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29123. /**
  29124. * Binds block to a uniform.
  29125. * @param blockName Name of the block to bind.
  29126. * @param index Index to bind.
  29127. */
  29128. bindUniformBlock(blockName: string, index: number): void;
  29129. /**
  29130. * Sets an interger value on a uniform variable.
  29131. * @param uniformName Name of the variable.
  29132. * @param value Value to be set.
  29133. * @returns this effect.
  29134. */
  29135. setInt(uniformName: string, value: number): Effect;
  29136. /**
  29137. * Sets an int array on a uniform variable.
  29138. * @param uniformName Name of the variable.
  29139. * @param array array to be set.
  29140. * @returns this effect.
  29141. */
  29142. setIntArray(uniformName: string, array: Int32Array): Effect;
  29143. /**
  29144. * 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)
  29145. * @param uniformName Name of the variable.
  29146. * @param array array to be set.
  29147. * @returns this effect.
  29148. */
  29149. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29150. /**
  29151. * 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)
  29152. * @param uniformName Name of the variable.
  29153. * @param array array to be set.
  29154. * @returns this effect.
  29155. */
  29156. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29157. /**
  29158. * 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)
  29159. * @param uniformName Name of the variable.
  29160. * @param array array to be set.
  29161. * @returns this effect.
  29162. */
  29163. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29164. /**
  29165. * Sets an float array on a uniform variable.
  29166. * @param uniformName Name of the variable.
  29167. * @param array array to be set.
  29168. * @returns this effect.
  29169. */
  29170. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29171. /**
  29172. * 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)
  29173. * @param uniformName Name of the variable.
  29174. * @param array array to be set.
  29175. * @returns this effect.
  29176. */
  29177. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29178. /**
  29179. * 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)
  29180. * @param uniformName Name of the variable.
  29181. * @param array array to be set.
  29182. * @returns this effect.
  29183. */
  29184. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29185. /**
  29186. * 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)
  29187. * @param uniformName Name of the variable.
  29188. * @param array array to be set.
  29189. * @returns this effect.
  29190. */
  29191. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29192. /**
  29193. * Sets an array on a uniform variable.
  29194. * @param uniformName Name of the variable.
  29195. * @param array array to be set.
  29196. * @returns this effect.
  29197. */
  29198. setArray(uniformName: string, array: number[]): Effect;
  29199. /**
  29200. * 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)
  29201. * @param uniformName Name of the variable.
  29202. * @param array array to be set.
  29203. * @returns this effect.
  29204. */
  29205. setArray2(uniformName: string, array: number[]): Effect;
  29206. /**
  29207. * 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)
  29208. * @param uniformName Name of the variable.
  29209. * @param array array to be set.
  29210. * @returns this effect.
  29211. */
  29212. setArray3(uniformName: string, array: number[]): Effect;
  29213. /**
  29214. * 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)
  29215. * @param uniformName Name of the variable.
  29216. * @param array array to be set.
  29217. * @returns this effect.
  29218. */
  29219. setArray4(uniformName: string, array: number[]): Effect;
  29220. /**
  29221. * Sets matrices on a uniform variable.
  29222. * @param uniformName Name of the variable.
  29223. * @param matrices matrices to be set.
  29224. * @returns this effect.
  29225. */
  29226. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29227. /**
  29228. * Sets matrix on a uniform variable.
  29229. * @param uniformName Name of the variable.
  29230. * @param matrix matrix to be set.
  29231. * @returns this effect.
  29232. */
  29233. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29234. /**
  29235. * 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)
  29236. * @param uniformName Name of the variable.
  29237. * @param matrix matrix to be set.
  29238. * @returns this effect.
  29239. */
  29240. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29241. /**
  29242. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29243. * @param uniformName Name of the variable.
  29244. * @param matrix matrix to be set.
  29245. * @returns this effect.
  29246. */
  29247. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29248. /**
  29249. * Sets a float on a uniform variable.
  29250. * @param uniformName Name of the variable.
  29251. * @param value value to be set.
  29252. * @returns this effect.
  29253. */
  29254. setFloat(uniformName: string, value: number): Effect;
  29255. /**
  29256. * Sets a boolean on a uniform variable.
  29257. * @param uniformName Name of the variable.
  29258. * @param bool value to be set.
  29259. * @returns this effect.
  29260. */
  29261. setBool(uniformName: string, bool: boolean): Effect;
  29262. /**
  29263. * Sets a Vector2 on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param vector2 vector2 to be set.
  29266. * @returns this effect.
  29267. */
  29268. setVector2(uniformName: string, vector2: Vector2): Effect;
  29269. /**
  29270. * Sets a float2 on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param x First float in float2.
  29273. * @param y Second float in float2.
  29274. * @returns this effect.
  29275. */
  29276. setFloat2(uniformName: string, x: number, y: number): Effect;
  29277. /**
  29278. * Sets a Vector3 on a uniform variable.
  29279. * @param uniformName Name of the variable.
  29280. * @param vector3 Value to be set.
  29281. * @returns this effect.
  29282. */
  29283. setVector3(uniformName: string, vector3: Vector3): Effect;
  29284. /**
  29285. * Sets a float3 on a uniform variable.
  29286. * @param uniformName Name of the variable.
  29287. * @param x First float in float3.
  29288. * @param y Second float in float3.
  29289. * @param z Third float in float3.
  29290. * @returns this effect.
  29291. */
  29292. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29293. /**
  29294. * Sets a Vector4 on a uniform variable.
  29295. * @param uniformName Name of the variable.
  29296. * @param vector4 Value to be set.
  29297. * @returns this effect.
  29298. */
  29299. setVector4(uniformName: string, vector4: Vector4): Effect;
  29300. /**
  29301. * Sets a float4 on a uniform variable.
  29302. * @param uniformName Name of the variable.
  29303. * @param x First float in float4.
  29304. * @param y Second float in float4.
  29305. * @param z Third float in float4.
  29306. * @param w Fourth float in float4.
  29307. * @returns this effect.
  29308. */
  29309. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29310. /**
  29311. * Sets a Color3 on a uniform variable.
  29312. * @param uniformName Name of the variable.
  29313. * @param color3 Value to be set.
  29314. * @returns this effect.
  29315. */
  29316. setColor3(uniformName: string, color3: Color3): Effect;
  29317. /**
  29318. * Sets a Color4 on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param color3 Value to be set.
  29321. * @param alpha Alpha value to be set.
  29322. * @returns this effect.
  29323. */
  29324. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29325. /**
  29326. * Sets a Color4 on a uniform variable
  29327. * @param uniformName defines the name of the variable
  29328. * @param color4 defines the value to be set
  29329. * @returns this effect.
  29330. */
  29331. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29332. /**
  29333. * This function will add a new shader to the shader store
  29334. * @param name the name of the shader
  29335. * @param pixelShader optional pixel shader content
  29336. * @param vertexShader optional vertex shader content
  29337. */
  29338. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29339. /**
  29340. * Store of each shader (The can be looked up using effect.key)
  29341. */
  29342. static ShadersStore: {
  29343. [key: string]: string;
  29344. };
  29345. /**
  29346. * Store of each included file for a shader (The can be looked up using effect.key)
  29347. */
  29348. static IncludesShadersStore: {
  29349. [key: string]: string;
  29350. };
  29351. /**
  29352. * Resets the cache of effects.
  29353. */
  29354. static ResetCache(): void;
  29355. }
  29356. }
  29357. declare module "babylonjs/Materials/colorCurves" {
  29358. import { Effect } from "babylonjs/Materials/effect";
  29359. /**
  29360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29362. * 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;
  29363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29364. */
  29365. export class ColorCurves {
  29366. private _dirty;
  29367. private _tempColor;
  29368. private _globalCurve;
  29369. private _highlightsCurve;
  29370. private _midtonesCurve;
  29371. private _shadowsCurve;
  29372. private _positiveCurve;
  29373. private _negativeCurve;
  29374. private _globalHue;
  29375. private _globalDensity;
  29376. private _globalSaturation;
  29377. private _globalExposure;
  29378. /**
  29379. * Gets the global Hue value.
  29380. * 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).
  29381. */
  29382. /**
  29383. * Sets the global Hue value.
  29384. * 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).
  29385. */
  29386. globalHue: number;
  29387. /**
  29388. * Gets the global Density value.
  29389. * 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.
  29390. * Values less than zero provide a filter of opposite hue.
  29391. */
  29392. /**
  29393. * Sets the global Density value.
  29394. * 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.
  29395. * Values less than zero provide a filter of opposite hue.
  29396. */
  29397. globalDensity: number;
  29398. /**
  29399. * Gets the global Saturation value.
  29400. * 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.
  29401. */
  29402. /**
  29403. * Sets the global Saturation value.
  29404. * 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.
  29405. */
  29406. globalSaturation: number;
  29407. /**
  29408. * Gets the global Exposure value.
  29409. * 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.
  29410. */
  29411. /**
  29412. * Sets the global Exposure value.
  29413. * 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.
  29414. */
  29415. globalExposure: number;
  29416. private _highlightsHue;
  29417. private _highlightsDensity;
  29418. private _highlightsSaturation;
  29419. private _highlightsExposure;
  29420. /**
  29421. * Gets the highlights Hue value.
  29422. * 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).
  29423. */
  29424. /**
  29425. * Sets the highlights Hue value.
  29426. * 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).
  29427. */
  29428. highlightsHue: number;
  29429. /**
  29430. * Gets the highlights Density value.
  29431. * 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.
  29432. * Values less than zero provide a filter of opposite hue.
  29433. */
  29434. /**
  29435. * Sets the highlights Density value.
  29436. * 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.
  29437. * Values less than zero provide a filter of opposite hue.
  29438. */
  29439. highlightsDensity: number;
  29440. /**
  29441. * Gets the highlights Saturation value.
  29442. * 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.
  29443. */
  29444. /**
  29445. * Sets the highlights Saturation value.
  29446. * 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.
  29447. */
  29448. highlightsSaturation: number;
  29449. /**
  29450. * Gets the highlights Exposure value.
  29451. * 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.
  29452. */
  29453. /**
  29454. * Sets the highlights Exposure value.
  29455. * 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.
  29456. */
  29457. highlightsExposure: number;
  29458. private _midtonesHue;
  29459. private _midtonesDensity;
  29460. private _midtonesSaturation;
  29461. private _midtonesExposure;
  29462. /**
  29463. * Gets the midtones Hue value.
  29464. * 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).
  29465. */
  29466. /**
  29467. * Sets the midtones Hue value.
  29468. * 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).
  29469. */
  29470. midtonesHue: number;
  29471. /**
  29472. * Gets the midtones Density value.
  29473. * 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.
  29474. * Values less than zero provide a filter of opposite hue.
  29475. */
  29476. /**
  29477. * Sets the midtones Density value.
  29478. * 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.
  29479. * Values less than zero provide a filter of opposite hue.
  29480. */
  29481. midtonesDensity: number;
  29482. /**
  29483. * Gets the midtones Saturation value.
  29484. * 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.
  29485. */
  29486. /**
  29487. * Sets the midtones Saturation value.
  29488. * 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.
  29489. */
  29490. midtonesSaturation: number;
  29491. /**
  29492. * Gets the midtones Exposure value.
  29493. * 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.
  29494. */
  29495. /**
  29496. * Sets the midtones Exposure value.
  29497. * 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.
  29498. */
  29499. midtonesExposure: number;
  29500. private _shadowsHue;
  29501. private _shadowsDensity;
  29502. private _shadowsSaturation;
  29503. private _shadowsExposure;
  29504. /**
  29505. * Gets the shadows Hue value.
  29506. * 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).
  29507. */
  29508. /**
  29509. * Sets the shadows Hue value.
  29510. * 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).
  29511. */
  29512. shadowsHue: number;
  29513. /**
  29514. * Gets the shadows Density value.
  29515. * 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.
  29516. * Values less than zero provide a filter of opposite hue.
  29517. */
  29518. /**
  29519. * Sets the shadows Density value.
  29520. * 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.
  29521. * Values less than zero provide a filter of opposite hue.
  29522. */
  29523. shadowsDensity: number;
  29524. /**
  29525. * Gets the shadows Saturation value.
  29526. * 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.
  29527. */
  29528. /**
  29529. * Sets the shadows Saturation value.
  29530. * 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.
  29531. */
  29532. shadowsSaturation: number;
  29533. /**
  29534. * Gets the shadows Exposure value.
  29535. * 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.
  29536. */
  29537. /**
  29538. * Sets the shadows Exposure value.
  29539. * 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.
  29540. */
  29541. shadowsExposure: number;
  29542. /**
  29543. * Returns the class name
  29544. * @returns The class name
  29545. */
  29546. getClassName(): string;
  29547. /**
  29548. * Binds the color curves to the shader.
  29549. * @param colorCurves The color curve to bind
  29550. * @param effect The effect to bind to
  29551. * @param positiveUniform The positive uniform shader parameter
  29552. * @param neutralUniform The neutral uniform shader parameter
  29553. * @param negativeUniform The negative uniform shader parameter
  29554. */
  29555. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29556. /**
  29557. * Prepare the list of uniforms associated with the ColorCurves effects.
  29558. * @param uniformsList The list of uniforms used in the effect
  29559. */
  29560. static PrepareUniforms(uniformsList: string[]): void;
  29561. /**
  29562. * Returns color grading data based on a hue, density, saturation and exposure value.
  29563. * @param filterHue The hue of the color filter.
  29564. * @param filterDensity The density of the color filter.
  29565. * @param saturation The saturation.
  29566. * @param exposure The exposure.
  29567. * @param result The result data container.
  29568. */
  29569. private getColorGradingDataToRef;
  29570. /**
  29571. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29572. * @param value The input slider value in range [-100,100].
  29573. * @returns Adjusted value.
  29574. */
  29575. private static applyColorGradingSliderNonlinear;
  29576. /**
  29577. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29578. * @param hue The hue (H) input.
  29579. * @param saturation The saturation (S) input.
  29580. * @param brightness The brightness (B) input.
  29581. * @result An RGBA color represented as Vector4.
  29582. */
  29583. private static fromHSBToRef;
  29584. /**
  29585. * Returns a value clamped between min and max
  29586. * @param value The value to clamp
  29587. * @param min The minimum of value
  29588. * @param max The maximum of value
  29589. * @returns The clamped value.
  29590. */
  29591. private static clamp;
  29592. /**
  29593. * Clones the current color curve instance.
  29594. * @return The cloned curves
  29595. */
  29596. clone(): ColorCurves;
  29597. /**
  29598. * Serializes the current color curve instance to a json representation.
  29599. * @return a JSON representation
  29600. */
  29601. serialize(): any;
  29602. /**
  29603. * Parses the color curve from a json representation.
  29604. * @param source the JSON source to parse
  29605. * @return The parsed curves
  29606. */
  29607. static Parse(source: any): ColorCurves;
  29608. }
  29609. }
  29610. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29611. import { Observable } from "babylonjs/Misc/observable";
  29612. import { Nullable } from "babylonjs/types";
  29613. import { Color4 } from "babylonjs/Maths/math";
  29614. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29615. import { Effect } from "babylonjs/Materials/effect";
  29616. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29617. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29618. /**
  29619. * Interface to follow in your material defines to integrate easily the
  29620. * Image proccessing functions.
  29621. * @hidden
  29622. */
  29623. export interface IImageProcessingConfigurationDefines {
  29624. IMAGEPROCESSING: boolean;
  29625. VIGNETTE: boolean;
  29626. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29627. VIGNETTEBLENDMODEOPAQUE: boolean;
  29628. TONEMAPPING: boolean;
  29629. TONEMAPPING_ACES: boolean;
  29630. CONTRAST: boolean;
  29631. EXPOSURE: boolean;
  29632. COLORCURVES: boolean;
  29633. COLORGRADING: boolean;
  29634. COLORGRADING3D: boolean;
  29635. SAMPLER3DGREENDEPTH: boolean;
  29636. SAMPLER3DBGRMAP: boolean;
  29637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29638. }
  29639. /**
  29640. * @hidden
  29641. */
  29642. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29643. IMAGEPROCESSING: boolean;
  29644. VIGNETTE: boolean;
  29645. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29646. VIGNETTEBLENDMODEOPAQUE: boolean;
  29647. TONEMAPPING: boolean;
  29648. TONEMAPPING_ACES: boolean;
  29649. CONTRAST: boolean;
  29650. COLORCURVES: boolean;
  29651. COLORGRADING: boolean;
  29652. COLORGRADING3D: boolean;
  29653. SAMPLER3DGREENDEPTH: boolean;
  29654. SAMPLER3DBGRMAP: boolean;
  29655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29656. EXPOSURE: boolean;
  29657. constructor();
  29658. }
  29659. /**
  29660. * This groups together the common properties used for image processing either in direct forward pass
  29661. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29662. * or not.
  29663. */
  29664. export class ImageProcessingConfiguration {
  29665. /**
  29666. * Default tone mapping applied in BabylonJS.
  29667. */
  29668. static readonly TONEMAPPING_STANDARD: number;
  29669. /**
  29670. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29671. * to other engines rendering to increase portability.
  29672. */
  29673. static readonly TONEMAPPING_ACES: number;
  29674. /**
  29675. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29676. */
  29677. colorCurves: Nullable<ColorCurves>;
  29678. private _colorCurvesEnabled;
  29679. /**
  29680. * Gets wether the color curves effect is enabled.
  29681. */
  29682. /**
  29683. * Sets wether the color curves effect is enabled.
  29684. */
  29685. colorCurvesEnabled: boolean;
  29686. private _colorGradingTexture;
  29687. /**
  29688. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29689. */
  29690. /**
  29691. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29692. */
  29693. colorGradingTexture: Nullable<BaseTexture>;
  29694. private _colorGradingEnabled;
  29695. /**
  29696. * Gets wether the color grading effect is enabled.
  29697. */
  29698. /**
  29699. * Sets wether the color grading effect is enabled.
  29700. */
  29701. colorGradingEnabled: boolean;
  29702. private _colorGradingWithGreenDepth;
  29703. /**
  29704. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29705. */
  29706. /**
  29707. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29708. */
  29709. colorGradingWithGreenDepth: boolean;
  29710. private _colorGradingBGR;
  29711. /**
  29712. * Gets wether the color grading texture contains BGR values.
  29713. */
  29714. /**
  29715. * Sets wether the color grading texture contains BGR values.
  29716. */
  29717. colorGradingBGR: boolean;
  29718. /** @hidden */
  29719. _exposure: number;
  29720. /**
  29721. * Gets the Exposure used in the effect.
  29722. */
  29723. /**
  29724. * Sets the Exposure used in the effect.
  29725. */
  29726. exposure: number;
  29727. private _toneMappingEnabled;
  29728. /**
  29729. * Gets wether the tone mapping effect is enabled.
  29730. */
  29731. /**
  29732. * Sets wether the tone mapping effect is enabled.
  29733. */
  29734. toneMappingEnabled: boolean;
  29735. private _toneMappingType;
  29736. /**
  29737. * Gets the type of tone mapping effect.
  29738. */
  29739. /**
  29740. * Sets the type of tone mapping effect used in BabylonJS.
  29741. */
  29742. toneMappingType: number;
  29743. protected _contrast: number;
  29744. /**
  29745. * Gets the contrast used in the effect.
  29746. */
  29747. /**
  29748. * Sets the contrast used in the effect.
  29749. */
  29750. contrast: number;
  29751. /**
  29752. * Vignette stretch size.
  29753. */
  29754. vignetteStretch: number;
  29755. /**
  29756. * Vignette centre X Offset.
  29757. */
  29758. vignetteCentreX: number;
  29759. /**
  29760. * Vignette centre Y Offset.
  29761. */
  29762. vignetteCentreY: number;
  29763. /**
  29764. * Vignette weight or intensity of the vignette effect.
  29765. */
  29766. vignetteWeight: number;
  29767. /**
  29768. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29769. * if vignetteEnabled is set to true.
  29770. */
  29771. vignetteColor: Color4;
  29772. /**
  29773. * Camera field of view used by the Vignette effect.
  29774. */
  29775. vignetteCameraFov: number;
  29776. private _vignetteBlendMode;
  29777. /**
  29778. * Gets the vignette blend mode allowing different kind of effect.
  29779. */
  29780. /**
  29781. * Sets the vignette blend mode allowing different kind of effect.
  29782. */
  29783. vignetteBlendMode: number;
  29784. private _vignetteEnabled;
  29785. /**
  29786. * Gets wether the vignette effect is enabled.
  29787. */
  29788. /**
  29789. * Sets wether the vignette effect is enabled.
  29790. */
  29791. vignetteEnabled: boolean;
  29792. private _applyByPostProcess;
  29793. /**
  29794. * Gets wether the image processing is applied through a post process or not.
  29795. */
  29796. /**
  29797. * Sets wether the image processing is applied through a post process or not.
  29798. */
  29799. applyByPostProcess: boolean;
  29800. private _isEnabled;
  29801. /**
  29802. * Gets wether the image processing is enabled or not.
  29803. */
  29804. /**
  29805. * Sets wether the image processing is enabled or not.
  29806. */
  29807. isEnabled: boolean;
  29808. /**
  29809. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29810. */
  29811. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29812. /**
  29813. * Method called each time the image processing information changes requires to recompile the effect.
  29814. */
  29815. protected _updateParameters(): void;
  29816. /**
  29817. * Gets the current class name.
  29818. * @return "ImageProcessingConfiguration"
  29819. */
  29820. getClassName(): string;
  29821. /**
  29822. * Prepare the list of uniforms associated with the Image Processing effects.
  29823. * @param uniforms The list of uniforms used in the effect
  29824. * @param defines the list of defines currently in use
  29825. */
  29826. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29827. /**
  29828. * Prepare the list of samplers associated with the Image Processing effects.
  29829. * @param samplersList The list of uniforms used in the effect
  29830. * @param defines the list of defines currently in use
  29831. */
  29832. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29833. /**
  29834. * Prepare the list of defines associated to the shader.
  29835. * @param defines the list of defines to complete
  29836. * @param forPostProcess Define if we are currently in post process mode or not
  29837. */
  29838. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29839. /**
  29840. * Returns true if all the image processing information are ready.
  29841. * @returns True if ready, otherwise, false
  29842. */
  29843. isReady(): boolean;
  29844. /**
  29845. * Binds the image processing to the shader.
  29846. * @param effect The effect to bind to
  29847. * @param aspectRatio Define the current aspect ratio of the effect
  29848. */
  29849. bind(effect: Effect, aspectRatio?: number): void;
  29850. /**
  29851. * Clones the current image processing instance.
  29852. * @return The cloned image processing
  29853. */
  29854. clone(): ImageProcessingConfiguration;
  29855. /**
  29856. * Serializes the current image processing instance to a json representation.
  29857. * @return a JSON representation
  29858. */
  29859. serialize(): any;
  29860. /**
  29861. * Parses the image processing from a json representation.
  29862. * @param source the JSON source to parse
  29863. * @return The parsed image processing
  29864. */
  29865. static Parse(source: any): ImageProcessingConfiguration;
  29866. private static _VIGNETTEMODE_MULTIPLY;
  29867. private static _VIGNETTEMODE_OPAQUE;
  29868. /**
  29869. * Used to apply the vignette as a mix with the pixel color.
  29870. */
  29871. static readonly VIGNETTEMODE_MULTIPLY: number;
  29872. /**
  29873. * Used to apply the vignette as a replacement of the pixel color.
  29874. */
  29875. static readonly VIGNETTEMODE_OPAQUE: number;
  29876. }
  29877. }
  29878. declare module "babylonjs/Materials/fresnelParameters" {
  29879. import { Color3 } from "babylonjs/Maths/math";
  29880. /**
  29881. * This represents all the required information to add a fresnel effect on a material:
  29882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29883. */
  29884. export class FresnelParameters {
  29885. private _isEnabled;
  29886. /**
  29887. * Define if the fresnel effect is enable or not.
  29888. */
  29889. isEnabled: boolean;
  29890. /**
  29891. * Define the color used on edges (grazing angle)
  29892. */
  29893. leftColor: Color3;
  29894. /**
  29895. * Define the color used on center
  29896. */
  29897. rightColor: Color3;
  29898. /**
  29899. * Define bias applied to computed fresnel term
  29900. */
  29901. bias: number;
  29902. /**
  29903. * Defined the power exponent applied to fresnel term
  29904. */
  29905. power: number;
  29906. /**
  29907. * Clones the current fresnel and its valuues
  29908. * @returns a clone fresnel configuration
  29909. */
  29910. clone(): FresnelParameters;
  29911. /**
  29912. * Serializes the current fresnel parameters to a JSON representation.
  29913. * @return the JSON serialization
  29914. */
  29915. serialize(): any;
  29916. /**
  29917. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29918. * @param parsedFresnelParameters Define the JSON representation
  29919. * @returns the parsed parameters
  29920. */
  29921. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29922. }
  29923. }
  29924. declare module "babylonjs/Misc/decorators" {
  29925. import { Nullable } from "babylonjs/types";
  29926. import { Scene } from "babylonjs/scene";
  29927. import { IAnimatable } from "babylonjs/Misc/tools";
  29928. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29929. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29937. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29938. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. /**
  29941. * Decorator used to define property that can be serialized as reference to a camera
  29942. * @param sourceName defines the name of the property to decorate
  29943. */
  29944. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29945. /**
  29946. * Class used to help serialization objects
  29947. */
  29948. export class SerializationHelper {
  29949. /** hidden */
  29950. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29951. /** hidden */
  29952. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29953. /** hidden */
  29954. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29955. /** hidden */
  29956. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29957. /**
  29958. * Appends the serialized animations from the source animations
  29959. * @param source Source containing the animations
  29960. * @param destination Target to store the animations
  29961. */
  29962. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29963. /**
  29964. * Static function used to serialized a specific entity
  29965. * @param entity defines the entity to serialize
  29966. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29967. * @returns a JSON compatible object representing the serialization of the entity
  29968. */
  29969. static Serialize<T>(entity: T, serializationObject?: any): any;
  29970. /**
  29971. * Creates a new entity from a serialization data object
  29972. * @param creationFunction defines a function used to instanciated the new entity
  29973. * @param source defines the source serialization data
  29974. * @param scene defines the hosting scene
  29975. * @param rootUrl defines the root url for resources
  29976. * @returns a new entity
  29977. */
  29978. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29979. /**
  29980. * Clones an object
  29981. * @param creationFunction defines the function used to instanciate the new object
  29982. * @param source defines the source object
  29983. * @returns the cloned object
  29984. */
  29985. static Clone<T>(creationFunction: () => T, source: T): T;
  29986. /**
  29987. * Instanciates a new object based on a source one (some data will be shared between both object)
  29988. * @param creationFunction defines the function used to instanciate the new object
  29989. * @param source defines the source object
  29990. * @returns the new object
  29991. */
  29992. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29993. }
  29994. }
  29995. declare module "babylonjs/Cameras/camera" {
  29996. import { SmartArray } from "babylonjs/Misc/smartArray";
  29997. import { Observable } from "babylonjs/Misc/observable";
  29998. import { Nullable } from "babylonjs/types";
  29999. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30000. import { Scene } from "babylonjs/scene";
  30001. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30002. import { Node } from "babylonjs/node";
  30003. import { Mesh } from "babylonjs/Meshes/mesh";
  30004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30005. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30009. import { Ray } from "babylonjs/Culling/ray";
  30010. /**
  30011. * This is the base class of all the camera used in the application.
  30012. * @see http://doc.babylonjs.com/features/cameras
  30013. */
  30014. export class Camera extends Node {
  30015. /** @hidden */
  30016. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30017. /**
  30018. * This is the default projection mode used by the cameras.
  30019. * It helps recreating a feeling of perspective and better appreciate depth.
  30020. * This is the best way to simulate real life cameras.
  30021. */
  30022. static readonly PERSPECTIVE_CAMERA: number;
  30023. /**
  30024. * This helps creating camera with an orthographic mode.
  30025. * 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.
  30026. */
  30027. static readonly ORTHOGRAPHIC_CAMERA: number;
  30028. /**
  30029. * This is the default FOV mode for perspective cameras.
  30030. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30031. */
  30032. static readonly FOVMODE_VERTICAL_FIXED: number;
  30033. /**
  30034. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30035. */
  30036. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30037. /**
  30038. * This specifies ther is no need for a camera rig.
  30039. * Basically only one eye is rendered corresponding to the camera.
  30040. */
  30041. static readonly RIG_MODE_NONE: number;
  30042. /**
  30043. * Simulates a camera Rig with one blue eye and one red eye.
  30044. * This can be use with 3d blue and red glasses.
  30045. */
  30046. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30047. /**
  30048. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30049. */
  30050. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30051. /**
  30052. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30053. */
  30054. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30055. /**
  30056. * Defines that both eyes of the camera will be rendered over under each other.
  30057. */
  30058. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30059. /**
  30060. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30061. */
  30062. static readonly RIG_MODE_VR: number;
  30063. /**
  30064. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30065. */
  30066. static readonly RIG_MODE_WEBVR: number;
  30067. /**
  30068. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30069. */
  30070. static readonly RIG_MODE_CUSTOM: number;
  30071. /**
  30072. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30073. */
  30074. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30075. /**
  30076. * @hidden
  30077. * Might be removed once multiview will be a thing
  30078. */
  30079. static UseAlternateWebVRRendering: boolean;
  30080. /**
  30081. * Define the input manager associated with the camera.
  30082. */
  30083. inputs: CameraInputsManager<Camera>;
  30084. /**
  30085. * Define the current local position of the camera in the scene
  30086. */
  30087. position: Vector3;
  30088. /**
  30089. * The vector the camera should consider as up.
  30090. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30091. */
  30092. upVector: Vector3;
  30093. /**
  30094. * Define the current limit on the left side for an orthographic camera
  30095. * In scene unit
  30096. */
  30097. orthoLeft: Nullable<number>;
  30098. /**
  30099. * Define the current limit on the right side for an orthographic camera
  30100. * In scene unit
  30101. */
  30102. orthoRight: Nullable<number>;
  30103. /**
  30104. * Define the current limit on the bottom side for an orthographic camera
  30105. * In scene unit
  30106. */
  30107. orthoBottom: Nullable<number>;
  30108. /**
  30109. * Define the current limit on the top side for an orthographic camera
  30110. * In scene unit
  30111. */
  30112. orthoTop: Nullable<number>;
  30113. /**
  30114. * Field Of View is set in Radians. (default is 0.8)
  30115. */
  30116. fov: number;
  30117. /**
  30118. * Define the minimum distance the camera can see from.
  30119. * This is important to note that the depth buffer are not infinite and the closer it starts
  30120. * the more your scene might encounter depth fighting issue.
  30121. */
  30122. minZ: number;
  30123. /**
  30124. * Define the maximum distance the camera can see to.
  30125. * This is important to note that the depth buffer are not infinite and the further it end
  30126. * the more your scene might encounter depth fighting issue.
  30127. */
  30128. maxZ: number;
  30129. /**
  30130. * Define the default inertia of the camera.
  30131. * This helps giving a smooth feeling to the camera movement.
  30132. */
  30133. inertia: number;
  30134. /**
  30135. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30136. */
  30137. mode: number;
  30138. /**
  30139. * Define wether the camera is intermediate.
  30140. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30141. */
  30142. isIntermediate: boolean;
  30143. /**
  30144. * Define the viewport of the camera.
  30145. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30146. */
  30147. viewport: Viewport;
  30148. /**
  30149. * Restricts the camera to viewing objects with the same layerMask.
  30150. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30151. */
  30152. layerMask: number;
  30153. /**
  30154. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30155. */
  30156. fovMode: number;
  30157. /**
  30158. * Rig mode of the camera.
  30159. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30160. * This is normally controlled byt the camera themselves as internal use.
  30161. */
  30162. cameraRigMode: number;
  30163. /**
  30164. * Defines the distance between both "eyes" in case of a RIG
  30165. */
  30166. interaxialDistance: number;
  30167. /**
  30168. * Defines if stereoscopic rendering is done side by side or over under.
  30169. */
  30170. isStereoscopicSideBySide: boolean;
  30171. /**
  30172. * 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
  30173. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30174. * else in the scene.
  30175. */
  30176. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30177. /**
  30178. * When set, the camera will render to this render target instead of the default canvas
  30179. */
  30180. outputRenderTarget: Nullable<RenderTargetTexture>;
  30181. /**
  30182. * Observable triggered when the camera view matrix has changed.
  30183. */
  30184. onViewMatrixChangedObservable: Observable<Camera>;
  30185. /**
  30186. * Observable triggered when the camera Projection matrix has changed.
  30187. */
  30188. onProjectionMatrixChangedObservable: Observable<Camera>;
  30189. /**
  30190. * Observable triggered when the inputs have been processed.
  30191. */
  30192. onAfterCheckInputsObservable: Observable<Camera>;
  30193. /**
  30194. * Observable triggered when reset has been called and applied to the camera.
  30195. */
  30196. onRestoreStateObservable: Observable<Camera>;
  30197. /** @hidden */
  30198. _cameraRigParams: any;
  30199. /** @hidden */
  30200. _rigCameras: Camera[];
  30201. /** @hidden */
  30202. _rigPostProcess: Nullable<PostProcess>;
  30203. protected _webvrViewMatrix: Matrix;
  30204. /** @hidden */
  30205. _skipRendering: boolean;
  30206. /** @hidden */
  30207. _alternateCamera: Camera;
  30208. /** @hidden */
  30209. _projectionMatrix: Matrix;
  30210. /** @hidden */
  30211. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30212. /** @hidden */
  30213. _activeMeshes: SmartArray<AbstractMesh>;
  30214. protected _globalPosition: Vector3;
  30215. /** hidden */
  30216. _computedViewMatrix: Matrix;
  30217. private _doNotComputeProjectionMatrix;
  30218. private _transformMatrix;
  30219. private _frustumPlanes;
  30220. private _refreshFrustumPlanes;
  30221. private _storedFov;
  30222. private _stateStored;
  30223. /**
  30224. * Instantiates a new camera object.
  30225. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30226. * @see http://doc.babylonjs.com/features/cameras
  30227. * @param name Defines the name of the camera in the scene
  30228. * @param position Defines the position of the camera
  30229. * @param scene Defines the scene the camera belongs too
  30230. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30231. */
  30232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30233. /**
  30234. * Store current camera state (fov, position, etc..)
  30235. * @returns the camera
  30236. */
  30237. storeState(): Camera;
  30238. /**
  30239. * Restores the camera state values if it has been stored. You must call storeState() first
  30240. */
  30241. protected _restoreStateValues(): boolean;
  30242. /**
  30243. * Restored camera state. You must call storeState() first.
  30244. * @returns true if restored and false otherwise
  30245. */
  30246. restoreState(): boolean;
  30247. /**
  30248. * Gets the class name of the camera.
  30249. * @returns the class name
  30250. */
  30251. getClassName(): string;
  30252. /** @hidden */
  30253. readonly _isCamera: boolean;
  30254. /**
  30255. * Gets a string representation of the camera useful for debug purpose.
  30256. * @param fullDetails Defines that a more verboe level of logging is required
  30257. * @returns the string representation
  30258. */
  30259. toString(fullDetails?: boolean): string;
  30260. /**
  30261. * Gets the current world space position of the camera.
  30262. */
  30263. readonly globalPosition: Vector3;
  30264. /**
  30265. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30266. * @returns the active meshe list
  30267. */
  30268. getActiveMeshes(): SmartArray<AbstractMesh>;
  30269. /**
  30270. * Check wether a mesh is part of the current active mesh list of the camera
  30271. * @param mesh Defines the mesh to check
  30272. * @returns true if active, false otherwise
  30273. */
  30274. isActiveMesh(mesh: Mesh): boolean;
  30275. /**
  30276. * Is this camera ready to be used/rendered
  30277. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30278. * @return true if the camera is ready
  30279. */
  30280. isReady(completeCheck?: boolean): boolean;
  30281. /** @hidden */
  30282. _initCache(): void;
  30283. /** @hidden */
  30284. _updateCache(ignoreParentClass?: boolean): void;
  30285. /** @hidden */
  30286. _isSynchronized(): boolean;
  30287. /** @hidden */
  30288. _isSynchronizedViewMatrix(): boolean;
  30289. /** @hidden */
  30290. _isSynchronizedProjectionMatrix(): boolean;
  30291. /**
  30292. * Attach the input controls to a specific dom element to get the input from.
  30293. * @param element Defines the element the controls should be listened from
  30294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30295. */
  30296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30297. /**
  30298. * Detach the current controls from the specified dom element.
  30299. * @param element Defines the element to stop listening the inputs from
  30300. */
  30301. detachControl(element: HTMLElement): void;
  30302. /**
  30303. * Update the camera state according to the different inputs gathered during the frame.
  30304. */
  30305. update(): void;
  30306. /** @hidden */
  30307. _checkInputs(): void;
  30308. /** @hidden */
  30309. readonly rigCameras: Camera[];
  30310. /**
  30311. * Gets the post process used by the rig cameras
  30312. */
  30313. readonly rigPostProcess: Nullable<PostProcess>;
  30314. /**
  30315. * Internal, gets the first post proces.
  30316. * @returns the first post process to be run on this camera.
  30317. */
  30318. _getFirstPostProcess(): Nullable<PostProcess>;
  30319. private _cascadePostProcessesToRigCams;
  30320. /**
  30321. * Attach a post process to the camera.
  30322. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30323. * @param postProcess The post process to attach to the camera
  30324. * @param insertAt The position of the post process in case several of them are in use in the scene
  30325. * @returns the position the post process has been inserted at
  30326. */
  30327. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30328. /**
  30329. * Detach a post process to the camera.
  30330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30331. * @param postProcess The post process to detach from the camera
  30332. */
  30333. detachPostProcess(postProcess: PostProcess): void;
  30334. /**
  30335. * Gets the current world matrix of the camera
  30336. */
  30337. getWorldMatrix(): Matrix;
  30338. /** @hidden */
  30339. _getViewMatrix(): Matrix;
  30340. /**
  30341. * Gets the current view matrix of the camera.
  30342. * @param force forces the camera to recompute the matrix without looking at the cached state
  30343. * @returns the view matrix
  30344. */
  30345. getViewMatrix(force?: boolean): Matrix;
  30346. /**
  30347. * Freeze the projection matrix.
  30348. * It will prevent the cache check of the camera projection compute and can speed up perf
  30349. * if no parameter of the camera are meant to change
  30350. * @param projection Defines manually a projection if necessary
  30351. */
  30352. freezeProjectionMatrix(projection?: Matrix): void;
  30353. /**
  30354. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30355. */
  30356. unfreezeProjectionMatrix(): void;
  30357. /**
  30358. * Gets the current projection matrix of the camera.
  30359. * @param force forces the camera to recompute the matrix without looking at the cached state
  30360. * @returns the projection matrix
  30361. */
  30362. getProjectionMatrix(force?: boolean): Matrix;
  30363. /**
  30364. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30365. * @returns a Matrix
  30366. */
  30367. getTransformationMatrix(): Matrix;
  30368. private _updateFrustumPlanes;
  30369. /**
  30370. * Checks if a cullable object (mesh...) is in the camera frustum
  30371. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30372. * @param target The object to check
  30373. * @returns true if the object is in frustum otherwise false
  30374. */
  30375. isInFrustum(target: ICullable): boolean;
  30376. /**
  30377. * Checks if a cullable object (mesh...) is in the camera frustum
  30378. * Unlike isInFrustum this cheks the full bounding box
  30379. * @param target The object to check
  30380. * @returns true if the object is in frustum otherwise false
  30381. */
  30382. isCompletelyInFrustum(target: ICullable): boolean;
  30383. /**
  30384. * Gets a ray in the forward direction from the camera.
  30385. * @param length Defines the length of the ray to create
  30386. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30387. * @param origin Defines the start point of the ray which defaults to the camera position
  30388. * @returns the forward ray
  30389. */
  30390. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30391. /**
  30392. * Releases resources associated with this node.
  30393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30395. */
  30396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30397. /**
  30398. * Gets the left camera of a rig setup in case of Rigged Camera
  30399. */
  30400. readonly leftCamera: Nullable<FreeCamera>;
  30401. /**
  30402. * Gets the right camera of a rig setup in case of Rigged Camera
  30403. */
  30404. readonly rightCamera: Nullable<FreeCamera>;
  30405. /**
  30406. * Gets the left camera target of a rig setup in case of Rigged Camera
  30407. * @returns the target position
  30408. */
  30409. getLeftTarget(): Nullable<Vector3>;
  30410. /**
  30411. * Gets the right camera target of a rig setup in case of Rigged Camera
  30412. * @returns the target position
  30413. */
  30414. getRightTarget(): Nullable<Vector3>;
  30415. /**
  30416. * @hidden
  30417. */
  30418. setCameraRigMode(mode: number, rigParams: any): void;
  30419. /** @hidden */
  30420. static _setStereoscopicRigMode(camera: Camera): void;
  30421. /** @hidden */
  30422. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30423. /** @hidden */
  30424. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30425. /** @hidden */
  30426. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30427. /** @hidden */
  30428. _getVRProjectionMatrix(): Matrix;
  30429. protected _updateCameraRotationMatrix(): void;
  30430. protected _updateWebVRCameraRotationMatrix(): void;
  30431. /**
  30432. * This function MUST be overwritten by the different WebVR cameras available.
  30433. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30434. * @hidden
  30435. */
  30436. _getWebVRProjectionMatrix(): Matrix;
  30437. /**
  30438. * This function MUST be overwritten by the different WebVR cameras available.
  30439. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30440. * @hidden
  30441. */
  30442. _getWebVRViewMatrix(): Matrix;
  30443. /** @hidden */
  30444. setCameraRigParameter(name: string, value: any): void;
  30445. /**
  30446. * needs to be overridden by children so sub has required properties to be copied
  30447. * @hidden
  30448. */
  30449. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30450. /**
  30451. * May need to be overridden by children
  30452. * @hidden
  30453. */
  30454. _updateRigCameras(): void;
  30455. /** @hidden */
  30456. _setupInputs(): void;
  30457. /**
  30458. * Serialiaze the camera setup to a json represention
  30459. * @returns the JSON representation
  30460. */
  30461. serialize(): any;
  30462. /**
  30463. * Clones the current camera.
  30464. * @param name The cloned camera name
  30465. * @returns the cloned camera
  30466. */
  30467. clone(name: string): Camera;
  30468. /**
  30469. * Gets the direction of the camera relative to a given local axis.
  30470. * @param localAxis Defines the reference axis to provide a relative direction.
  30471. * @return the direction
  30472. */
  30473. getDirection(localAxis: Vector3): Vector3;
  30474. /**
  30475. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30476. * @param localAxis Defines the reference axis to provide a relative direction.
  30477. * @param result Defines the vector to store the result in
  30478. */
  30479. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30480. /**
  30481. * Gets a camera constructor for a given camera type
  30482. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30483. * @param name The name of the camera the result will be able to instantiate
  30484. * @param scene The scene the result will construct the camera in
  30485. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30486. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30487. * @returns a factory method to construc the camera
  30488. */
  30489. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30490. /**
  30491. * Compute the world matrix of the camera.
  30492. * @returns the camera workd matrix
  30493. */
  30494. computeWorldMatrix(): Matrix;
  30495. /**
  30496. * Parse a JSON and creates the camera from the parsed information
  30497. * @param parsedCamera The JSON to parse
  30498. * @param scene The scene to instantiate the camera in
  30499. * @returns the newly constructed camera
  30500. */
  30501. static Parse(parsedCamera: any, scene: Scene): Camera;
  30502. }
  30503. }
  30504. declare module "babylonjs/Misc/tools" {
  30505. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30506. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30507. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30508. import { Observable } from "babylonjs/Misc/observable";
  30509. import { DomManagement } from "babylonjs/Misc/domManagement";
  30510. import { Camera } from "babylonjs/Cameras/camera";
  30511. import { Engine } from "babylonjs/Engines/engine";
  30512. import { Animation } from "babylonjs/Animations/animation";
  30513. /**
  30514. * Interface for any object that can request an animation frame
  30515. */
  30516. export interface ICustomAnimationFrameRequester {
  30517. /**
  30518. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30519. */
  30520. renderFunction?: Function;
  30521. /**
  30522. * Called to request the next frame to render to
  30523. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30524. */
  30525. requestAnimationFrame: Function;
  30526. /**
  30527. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30528. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30529. */
  30530. requestID?: number;
  30531. }
  30532. /**
  30533. * Interface containing an array of animations
  30534. */
  30535. export interface IAnimatable {
  30536. /**
  30537. * Array of animations
  30538. */
  30539. animations: Array<Animation>;
  30540. }
  30541. /** Interface used by value gradients (color, factor, ...) */
  30542. export interface IValueGradient {
  30543. /**
  30544. * Gets or sets the gradient value (between 0 and 1)
  30545. */
  30546. gradient: number;
  30547. }
  30548. /** Class used to store color4 gradient */
  30549. export class ColorGradient implements IValueGradient {
  30550. /**
  30551. * Gets or sets the gradient value (between 0 and 1)
  30552. */
  30553. gradient: number;
  30554. /**
  30555. * Gets or sets first associated color
  30556. */
  30557. color1: Color4;
  30558. /**
  30559. * Gets or sets second associated color
  30560. */
  30561. color2?: Color4;
  30562. /**
  30563. * Will get a color picked randomly between color1 and color2.
  30564. * If color2 is undefined then color1 will be used
  30565. * @param result defines the target Color4 to store the result in
  30566. */
  30567. getColorToRef(result: Color4): void;
  30568. }
  30569. /** Class used to store color 3 gradient */
  30570. export class Color3Gradient implements IValueGradient {
  30571. /**
  30572. * Gets or sets the gradient value (between 0 and 1)
  30573. */
  30574. gradient: number;
  30575. /**
  30576. * Gets or sets the associated color
  30577. */
  30578. color: Color3;
  30579. }
  30580. /** Class used to store factor gradient */
  30581. export class FactorGradient implements IValueGradient {
  30582. /**
  30583. * Gets or sets the gradient value (between 0 and 1)
  30584. */
  30585. gradient: number;
  30586. /**
  30587. * Gets or sets first associated factor
  30588. */
  30589. factor1: number;
  30590. /**
  30591. * Gets or sets second associated factor
  30592. */
  30593. factor2?: number;
  30594. /**
  30595. * Will get a number picked randomly between factor1 and factor2.
  30596. * If factor2 is undefined then factor1 will be used
  30597. * @returns the picked number
  30598. */
  30599. getFactor(): number;
  30600. }
  30601. /**
  30602. * @ignore
  30603. * Application error to support additional information when loading a file
  30604. */
  30605. export class LoadFileError extends Error {
  30606. /** defines the optional XHR request */
  30607. request?: XMLHttpRequest | undefined;
  30608. private static _setPrototypeOf;
  30609. /**
  30610. * Creates a new LoadFileError
  30611. * @param message defines the message of the error
  30612. * @param request defines the optional XHR request
  30613. */
  30614. constructor(message: string,
  30615. /** defines the optional XHR request */
  30616. request?: XMLHttpRequest | undefined);
  30617. }
  30618. /**
  30619. * Class used to define a retry strategy when error happens while loading assets
  30620. */
  30621. export class RetryStrategy {
  30622. /**
  30623. * Function used to defines an exponential back off strategy
  30624. * @param maxRetries defines the maximum number of retries (3 by default)
  30625. * @param baseInterval defines the interval between retries
  30626. * @returns the strategy function to use
  30627. */
  30628. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30629. }
  30630. /**
  30631. * File request interface
  30632. */
  30633. export interface IFileRequest {
  30634. /**
  30635. * Raised when the request is complete (success or error).
  30636. */
  30637. onCompleteObservable: Observable<IFileRequest>;
  30638. /**
  30639. * Aborts the request for a file.
  30640. */
  30641. abort: () => void;
  30642. }
  30643. /**
  30644. * Class containing a set of static utilities functions
  30645. */
  30646. export class Tools {
  30647. /**
  30648. * Gets or sets the base URL to use to load assets
  30649. */
  30650. static BaseUrl: string;
  30651. /**
  30652. * Enable/Disable Custom HTTP Request Headers globally.
  30653. * default = false
  30654. * @see CustomRequestHeaders
  30655. */
  30656. static UseCustomRequestHeaders: boolean;
  30657. /**
  30658. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30659. * i.e. when loading files, where the server/service expects an Authorization header.
  30660. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30661. */
  30662. static CustomRequestHeaders: {
  30663. [key: string]: string;
  30664. };
  30665. /**
  30666. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30667. */
  30668. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30669. /**
  30670. * Default behaviour for cors in the application.
  30671. * It can be a string if the expected behavior is identical in the entire app.
  30672. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30673. */
  30674. static CorsBehavior: string | ((url: string | string[]) => string);
  30675. /**
  30676. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30677. * @ignorenaming
  30678. */
  30679. static UseFallbackTexture: boolean;
  30680. /**
  30681. * Use this object to register external classes like custom textures or material
  30682. * to allow the laoders to instantiate them
  30683. */
  30684. static RegisteredExternalClasses: {
  30685. [key: string]: Object;
  30686. };
  30687. /**
  30688. * Texture content used if a texture cannot loaded
  30689. * @ignorenaming
  30690. */
  30691. static fallbackTexture: string;
  30692. /**
  30693. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30694. * @param u defines the coordinate on X axis
  30695. * @param v defines the coordinate on Y axis
  30696. * @param width defines the width of the source data
  30697. * @param height defines the height of the source data
  30698. * @param pixels defines the source byte array
  30699. * @param color defines the output color
  30700. */
  30701. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30702. /**
  30703. * Interpolates between a and b via alpha
  30704. * @param a The lower value (returned when alpha = 0)
  30705. * @param b The upper value (returned when alpha = 1)
  30706. * @param alpha The interpolation-factor
  30707. * @return The mixed value
  30708. */
  30709. static Mix(a: number, b: number, alpha: number): number;
  30710. /**
  30711. * Tries to instantiate a new object from a given class name
  30712. * @param className defines the class name to instantiate
  30713. * @returns the new object or null if the system was not able to do the instantiation
  30714. */
  30715. static Instantiate(className: string): any;
  30716. /**
  30717. * Provides a slice function that will work even on IE
  30718. * @param data defines the array to slice
  30719. * @param start defines the start of the data (optional)
  30720. * @param end defines the end of the data (optional)
  30721. * @returns the new sliced array
  30722. */
  30723. static Slice<T>(data: T, start?: number, end?: number): T;
  30724. /**
  30725. * Polyfill for setImmediate
  30726. * @param action defines the action to execute after the current execution block
  30727. */
  30728. static SetImmediate(action: () => void): void;
  30729. /**
  30730. * Function indicating if a number is an exponent of 2
  30731. * @param value defines the value to test
  30732. * @returns true if the value is an exponent of 2
  30733. */
  30734. static IsExponentOfTwo(value: number): boolean;
  30735. private static _tmpFloatArray;
  30736. /**
  30737. * Returns the nearest 32-bit single precision float representation of a Number
  30738. * @param value A Number. If the parameter is of a different type, it will get converted
  30739. * to a number or to NaN if it cannot be converted
  30740. * @returns number
  30741. */
  30742. static FloatRound(value: number): number;
  30743. /**
  30744. * Find the next highest power of two.
  30745. * @param x Number to start search from.
  30746. * @return Next highest power of two.
  30747. */
  30748. static CeilingPOT(x: number): number;
  30749. /**
  30750. * Find the next lowest power of two.
  30751. * @param x Number to start search from.
  30752. * @return Next lowest power of two.
  30753. */
  30754. static FloorPOT(x: number): number;
  30755. /**
  30756. * Find the nearest power of two.
  30757. * @param x Number to start search from.
  30758. * @return Next nearest power of two.
  30759. */
  30760. static NearestPOT(x: number): number;
  30761. /**
  30762. * Get the closest exponent of two
  30763. * @param value defines the value to approximate
  30764. * @param max defines the maximum value to return
  30765. * @param mode defines how to define the closest value
  30766. * @returns closest exponent of two of the given value
  30767. */
  30768. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30769. /**
  30770. * Extracts the filename from a path
  30771. * @param path defines the path to use
  30772. * @returns the filename
  30773. */
  30774. static GetFilename(path: string): string;
  30775. /**
  30776. * Extracts the "folder" part of a path (everything before the filename).
  30777. * @param uri The URI to extract the info from
  30778. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30779. * @returns The "folder" part of the path
  30780. */
  30781. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30782. /**
  30783. * Extracts text content from a DOM element hierarchy
  30784. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30785. */
  30786. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30787. /**
  30788. * Convert an angle in radians to degrees
  30789. * @param angle defines the angle to convert
  30790. * @returns the angle in degrees
  30791. */
  30792. static ToDegrees(angle: number): number;
  30793. /**
  30794. * Convert an angle in degrees to radians
  30795. * @param angle defines the angle to convert
  30796. * @returns the angle in radians
  30797. */
  30798. static ToRadians(angle: number): number;
  30799. /**
  30800. * Encode a buffer to a base64 string
  30801. * @param buffer defines the buffer to encode
  30802. * @returns the encoded string
  30803. */
  30804. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30805. /**
  30806. * Extracts minimum and maximum values from a list of indexed positions
  30807. * @param positions defines the positions to use
  30808. * @param indices defines the indices to the positions
  30809. * @param indexStart defines the start index
  30810. * @param indexCount defines the end index
  30811. * @param bias defines bias value to add to the result
  30812. * @return minimum and maximum values
  30813. */
  30814. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30815. minimum: Vector3;
  30816. maximum: Vector3;
  30817. };
  30818. /**
  30819. * Extracts minimum and maximum values from a list of positions
  30820. * @param positions defines the positions to use
  30821. * @param start defines the start index in the positions array
  30822. * @param count defines the number of positions to handle
  30823. * @param bias defines bias value to add to the result
  30824. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30825. * @return minimum and maximum values
  30826. */
  30827. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30828. minimum: Vector3;
  30829. maximum: Vector3;
  30830. };
  30831. /**
  30832. * Returns an array if obj is not an array
  30833. * @param obj defines the object to evaluate as an array
  30834. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30835. * @returns either obj directly if obj is an array or a new array containing obj
  30836. */
  30837. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30838. /**
  30839. * Gets the pointer prefix to use
  30840. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30841. */
  30842. static GetPointerPrefix(): string;
  30843. /**
  30844. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30845. * @param func - the function to be called
  30846. * @param requester - the object that will request the next frame. Falls back to window.
  30847. * @returns frame number
  30848. */
  30849. static QueueNewFrame(func: () => void, requester?: any): number;
  30850. /**
  30851. * Ask the browser to promote the current element to fullscreen rendering mode
  30852. * @param element defines the DOM element to promote
  30853. */
  30854. static RequestFullscreen(element: HTMLElement): void;
  30855. /**
  30856. * Asks the browser to exit fullscreen mode
  30857. */
  30858. static ExitFullscreen(): void;
  30859. /**
  30860. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30861. * @param url define the url we are trying
  30862. * @param element define the dom element where to configure the cors policy
  30863. */
  30864. static SetCorsBehavior(url: string | string[], element: {
  30865. crossOrigin: string | null;
  30866. }): void;
  30867. /**
  30868. * Removes unwanted characters from an url
  30869. * @param url defines the url to clean
  30870. * @returns the cleaned url
  30871. */
  30872. static CleanUrl(url: string): string;
  30873. /**
  30874. * Gets or sets a function used to pre-process url before using them to load assets
  30875. */
  30876. static PreprocessUrl: (url: string) => string;
  30877. /**
  30878. * Loads an image as an HTMLImageElement.
  30879. * @param input url string, ArrayBuffer, or Blob to load
  30880. * @param onLoad callback called when the image successfully loads
  30881. * @param onError callback called when the image fails to load
  30882. * @param offlineProvider offline provider for caching
  30883. * @returns the HTMLImageElement of the loaded image
  30884. */
  30885. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30886. /**
  30887. * Loads a file
  30888. * @param url url string, ArrayBuffer, or Blob to load
  30889. * @param onSuccess callback called when the file successfully loads
  30890. * @param onProgress callback called while file is loading (if the server supports this mode)
  30891. * @param offlineProvider defines the offline provider for caching
  30892. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30893. * @param onError callback called when the file fails to load
  30894. * @returns a file request object
  30895. */
  30896. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30897. /**
  30898. * Load a script (identified by an url). When the url returns, the
  30899. * content of this file is added into a new script element, attached to the DOM (body element)
  30900. * @param scriptUrl defines the url of the script to laod
  30901. * @param onSuccess defines the callback called when the script is loaded
  30902. * @param onError defines the callback to call if an error occurs
  30903. */
  30904. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30905. /**
  30906. * Loads a file from a blob
  30907. * @param fileToLoad defines the blob to use
  30908. * @param callback defines the callback to call when data is loaded
  30909. * @param progressCallback defines the callback to call during loading process
  30910. * @returns a file request object
  30911. */
  30912. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30913. /**
  30914. * Loads a file
  30915. * @param fileToLoad defines the file to load
  30916. * @param callback defines the callback to call when data is loaded
  30917. * @param progressCallBack defines the callback to call during loading process
  30918. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30919. * @returns a file request object
  30920. */
  30921. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30922. /**
  30923. * Creates a data url from a given string content
  30924. * @param content defines the content to convert
  30925. * @returns the new data url link
  30926. */
  30927. static FileAsURL(content: string): string;
  30928. /**
  30929. * Format the given number to a specific decimal format
  30930. * @param value defines the number to format
  30931. * @param decimals defines the number of decimals to use
  30932. * @returns the formatted string
  30933. */
  30934. static Format(value: number, decimals?: number): string;
  30935. /**
  30936. * Checks if a given vector is inside a specific range
  30937. * @param v defines the vector to test
  30938. * @param min defines the minimum range
  30939. * @param max defines the maximum range
  30940. */
  30941. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30942. /**
  30943. * Tries to copy an object by duplicating every property
  30944. * @param source defines the source object
  30945. * @param destination defines the target object
  30946. * @param doNotCopyList defines a list of properties to avoid
  30947. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30948. */
  30949. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30950. /**
  30951. * Gets a boolean indicating if the given object has no own property
  30952. * @param obj defines the object to test
  30953. * @returns true if object has no own property
  30954. */
  30955. static IsEmpty(obj: any): boolean;
  30956. /**
  30957. * Function used to register events at window level
  30958. * @param events defines the events to register
  30959. */
  30960. static RegisterTopRootEvents(events: {
  30961. name: string;
  30962. handler: Nullable<(e: FocusEvent) => any>;
  30963. }[]): void;
  30964. /**
  30965. * Function used to unregister events from window level
  30966. * @param events defines the events to unregister
  30967. */
  30968. static UnregisterTopRootEvents(events: {
  30969. name: string;
  30970. handler: Nullable<(e: FocusEvent) => any>;
  30971. }[]): void;
  30972. /**
  30973. * Dumps the current bound framebuffer
  30974. * @param width defines the rendering width
  30975. * @param height defines the rendering height
  30976. * @param engine defines the hosting engine
  30977. * @param successCallback defines the callback triggered once the data are available
  30978. * @param mimeType defines the mime type of the result
  30979. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30980. */
  30981. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30982. /**
  30983. * Converts the canvas data to blob.
  30984. * This acts as a polyfill for browsers not supporting the to blob function.
  30985. * @param canvas Defines the canvas to extract the data from
  30986. * @param successCallback Defines the callback triggered once the data are available
  30987. * @param mimeType Defines the mime type of the result
  30988. */
  30989. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30990. /**
  30991. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30992. * @param successCallback defines the callback triggered once the data are available
  30993. * @param mimeType defines the mime type of the result
  30994. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30995. */
  30996. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30997. /**
  30998. * Downloads a blob in the browser
  30999. * @param blob defines the blob to download
  31000. * @param fileName defines the name of the downloaded file
  31001. */
  31002. static Download(blob: Blob, fileName: string): void;
  31003. /**
  31004. * Captures a screenshot of the current rendering
  31005. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31006. * @param engine defines the rendering engine
  31007. * @param camera defines the source camera
  31008. * @param size This parameter can be set to a single number or to an object with the
  31009. * following (optional) properties: precision, width, height. If a single number is passed,
  31010. * it will be used for both width and height. If an object is passed, the screenshot size
  31011. * will be derived from the parameters. The precision property is a multiplier allowing
  31012. * rendering at a higher or lower resolution
  31013. * @param successCallback defines the callback receives a single parameter which contains the
  31014. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31015. * src parameter of an <img> to display it
  31016. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31017. * Check your browser for supported MIME types
  31018. */
  31019. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31020. /**
  31021. * Generates an image screenshot from the specified camera.
  31022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31023. * @param engine The engine to use for rendering
  31024. * @param camera The camera to use for rendering
  31025. * @param size This parameter can be set to a single number or to an object with the
  31026. * following (optional) properties: precision, width, height. If a single number is passed,
  31027. * it will be used for both width and height. If an object is passed, the screenshot size
  31028. * will be derived from the parameters. The precision property is a multiplier allowing
  31029. * rendering at a higher or lower resolution
  31030. * @param successCallback The callback receives a single parameter which contains the
  31031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31032. * src parameter of an <img> to display it
  31033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31034. * Check your browser for supported MIME types
  31035. * @param samples Texture samples (default: 1)
  31036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31037. * @param fileName A name for for the downloaded file.
  31038. */
  31039. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31040. /**
  31041. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31042. * Be aware Math.random() could cause collisions, but:
  31043. * "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"
  31044. * @returns a pseudo random id
  31045. */
  31046. static RandomId(): string;
  31047. /**
  31048. * Test if the given uri is a base64 string
  31049. * @param uri The uri to test
  31050. * @return True if the uri is a base64 string or false otherwise
  31051. */
  31052. static IsBase64(uri: string): boolean;
  31053. /**
  31054. * Decode the given base64 uri.
  31055. * @param uri The uri to decode
  31056. * @return The decoded base64 data.
  31057. */
  31058. static DecodeBase64(uri: string): ArrayBuffer;
  31059. /**
  31060. * No log
  31061. */
  31062. static readonly NoneLogLevel: number;
  31063. /**
  31064. * Only message logs
  31065. */
  31066. static readonly MessageLogLevel: number;
  31067. /**
  31068. * Only warning logs
  31069. */
  31070. static readonly WarningLogLevel: number;
  31071. /**
  31072. * Only error logs
  31073. */
  31074. static readonly ErrorLogLevel: number;
  31075. /**
  31076. * All logs
  31077. */
  31078. static readonly AllLogLevel: number;
  31079. /**
  31080. * Gets a value indicating the number of loading errors
  31081. * @ignorenaming
  31082. */
  31083. static readonly errorsCount: number;
  31084. /**
  31085. * Callback called when a new log is added
  31086. */
  31087. static OnNewCacheEntry: (entry: string) => void;
  31088. /**
  31089. * Log a message to the console
  31090. * @param message defines the message to log
  31091. */
  31092. static Log(message: string): void;
  31093. /**
  31094. * Write a warning message to the console
  31095. * @param message defines the message to log
  31096. */
  31097. static Warn(message: string): void;
  31098. /**
  31099. * Write an error message to the console
  31100. * @param message defines the message to log
  31101. */
  31102. static Error(message: string): void;
  31103. /**
  31104. * Gets current log cache (list of logs)
  31105. */
  31106. static readonly LogCache: string;
  31107. /**
  31108. * Clears the log cache
  31109. */
  31110. static ClearLogCache(): void;
  31111. /**
  31112. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31113. */
  31114. static LogLevels: number;
  31115. /**
  31116. * Checks if the loaded document was accessed via `file:`-Protocol.
  31117. * @returns boolean
  31118. */
  31119. static IsFileURL(): boolean;
  31120. /**
  31121. * Checks if the window object exists
  31122. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31123. */
  31124. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31125. /**
  31126. * No performance log
  31127. */
  31128. static readonly PerformanceNoneLogLevel: number;
  31129. /**
  31130. * Use user marks to log performance
  31131. */
  31132. static readonly PerformanceUserMarkLogLevel: number;
  31133. /**
  31134. * Log performance to the console
  31135. */
  31136. static readonly PerformanceConsoleLogLevel: number;
  31137. private static _performance;
  31138. /**
  31139. * Sets the current performance log level
  31140. */
  31141. static PerformanceLogLevel: number;
  31142. private static _StartPerformanceCounterDisabled;
  31143. private static _EndPerformanceCounterDisabled;
  31144. private static _StartUserMark;
  31145. private static _EndUserMark;
  31146. private static _StartPerformanceConsole;
  31147. private static _EndPerformanceConsole;
  31148. /**
  31149. * Injects the @see CustomRequestHeaders into the given request
  31150. * @param request the request that should be used for injection
  31151. */
  31152. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31153. /**
  31154. * Starts a performance counter
  31155. */
  31156. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31157. /**
  31158. * Ends a specific performance coutner
  31159. */
  31160. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31161. /**
  31162. * Gets either window.performance.now() if supported or Date.now() else
  31163. */
  31164. static readonly Now: number;
  31165. /**
  31166. * This method will return the name of the class used to create the instance of the given object.
  31167. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31168. * @param object the object to get the class name from
  31169. * @param isType defines if the object is actually a type
  31170. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31171. */
  31172. static GetClassName(object: any, isType?: boolean): string;
  31173. /**
  31174. * Gets the first element of an array satisfying a given predicate
  31175. * @param array defines the array to browse
  31176. * @param predicate defines the predicate to use
  31177. * @returns null if not found or the element
  31178. */
  31179. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31180. /**
  31181. * This method will return the name of the full name of the class, including its owning module (if any).
  31182. * 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).
  31183. * @param object the object to get the class name from
  31184. * @param isType defines if the object is actually a type
  31185. * @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.
  31186. * @ignorenaming
  31187. */
  31188. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31189. /**
  31190. * Returns a promise that resolves after the given amount of time.
  31191. * @param delay Number of milliseconds to delay
  31192. * @returns Promise that resolves after the given amount of time
  31193. */
  31194. static DelayAsync(delay: number): Promise<void>;
  31195. /**
  31196. * Gets the current gradient from an array of IValueGradient
  31197. * @param ratio defines the current ratio to get
  31198. * @param gradients defines the array of IValueGradient
  31199. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31200. */
  31201. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31202. }
  31203. /**
  31204. * This class is used to track a performance counter which is number based.
  31205. * The user has access to many properties which give statistics of different nature.
  31206. *
  31207. * The implementer can track two kinds of Performance Counter: time and count.
  31208. * 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.
  31209. * 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.
  31210. */
  31211. export class PerfCounter {
  31212. /**
  31213. * Gets or sets a global boolean to turn on and off all the counters
  31214. */
  31215. static Enabled: boolean;
  31216. /**
  31217. * Returns the smallest value ever
  31218. */
  31219. readonly min: number;
  31220. /**
  31221. * Returns the biggest value ever
  31222. */
  31223. readonly max: number;
  31224. /**
  31225. * Returns the average value since the performance counter is running
  31226. */
  31227. readonly average: number;
  31228. /**
  31229. * Returns the average value of the last second the counter was monitored
  31230. */
  31231. readonly lastSecAverage: number;
  31232. /**
  31233. * Returns the current value
  31234. */
  31235. readonly current: number;
  31236. /**
  31237. * Gets the accumulated total
  31238. */
  31239. readonly total: number;
  31240. /**
  31241. * Gets the total value count
  31242. */
  31243. readonly count: number;
  31244. /**
  31245. * Creates a new counter
  31246. */
  31247. constructor();
  31248. /**
  31249. * Call this method to start monitoring a new frame.
  31250. * 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.
  31251. */
  31252. fetchNewFrame(): void;
  31253. /**
  31254. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31255. * @param newCount the count value to add to the monitored count
  31256. * @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.
  31257. */
  31258. addCount(newCount: number, fetchResult: boolean): void;
  31259. /**
  31260. * Start monitoring this performance counter
  31261. */
  31262. beginMonitoring(): void;
  31263. /**
  31264. * Compute the time lapsed since the previous beginMonitoring() call.
  31265. * @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
  31266. */
  31267. endMonitoring(newFrame?: boolean): void;
  31268. private _fetchResult;
  31269. private _startMonitoringTime;
  31270. private _min;
  31271. private _max;
  31272. private _average;
  31273. private _current;
  31274. private _totalValueCount;
  31275. private _totalAccumulated;
  31276. private _lastSecAverage;
  31277. private _lastSecAccumulated;
  31278. private _lastSecTime;
  31279. private _lastSecValueCount;
  31280. }
  31281. /**
  31282. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31283. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31284. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31285. * @param name The name of the class, case should be preserved
  31286. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31287. */
  31288. export function className(name: string, module?: string): (target: Object) => void;
  31289. /**
  31290. * An implementation of a loop for asynchronous functions.
  31291. */
  31292. export class AsyncLoop {
  31293. /**
  31294. * Defines the number of iterations for the loop
  31295. */
  31296. iterations: number;
  31297. /**
  31298. * Defines the current index of the loop.
  31299. */
  31300. index: number;
  31301. private _done;
  31302. private _fn;
  31303. private _successCallback;
  31304. /**
  31305. * Constructor.
  31306. * @param iterations the number of iterations.
  31307. * @param func the function to run each iteration
  31308. * @param successCallback the callback that will be called upon succesful execution
  31309. * @param offset starting offset.
  31310. */
  31311. constructor(
  31312. /**
  31313. * Defines the number of iterations for the loop
  31314. */
  31315. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31316. /**
  31317. * Execute the next iteration. Must be called after the last iteration was finished.
  31318. */
  31319. executeNext(): void;
  31320. /**
  31321. * Break the loop and run the success callback.
  31322. */
  31323. breakLoop(): void;
  31324. /**
  31325. * Create and run an async loop.
  31326. * @param iterations the number of iterations.
  31327. * @param fn the function to run each iteration
  31328. * @param successCallback the callback that will be called upon succesful execution
  31329. * @param offset starting offset.
  31330. * @returns the created async loop object
  31331. */
  31332. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31333. /**
  31334. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31335. * @param iterations total number of iterations
  31336. * @param syncedIterations number of synchronous iterations in each async iteration.
  31337. * @param fn the function to call each iteration.
  31338. * @param callback a success call back that will be called when iterating stops.
  31339. * @param breakFunction a break condition (optional)
  31340. * @param timeout timeout settings for the setTimeout function. default - 0.
  31341. * @returns the created async loop object
  31342. */
  31343. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31344. }
  31345. }
  31346. declare module "babylonjs/Collisions/collisionCoordinator" {
  31347. import { Nullable } from "babylonjs/types";
  31348. import { Scene } from "babylonjs/scene";
  31349. import { Vector3 } from "babylonjs/Maths/math";
  31350. import { Collider } from "babylonjs/Collisions/collider";
  31351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31352. /** @hidden */
  31353. export interface ICollisionCoordinator {
  31354. createCollider(): Collider;
  31355. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31356. init(scene: Scene): void;
  31357. }
  31358. /** @hidden */
  31359. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31360. private _scene;
  31361. private _scaledPosition;
  31362. private _scaledVelocity;
  31363. private _finalPosition;
  31364. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31365. createCollider(): Collider;
  31366. init(scene: Scene): void;
  31367. private _collideWithWorld;
  31368. }
  31369. }
  31370. declare module "babylonjs/Animations/animationGroup" {
  31371. import { Animatable } from "babylonjs/Animations/animatable";
  31372. import { Animation } from "babylonjs/Animations/animation";
  31373. import { Scene, IDisposable } from "babylonjs/scene";
  31374. import { Observable } from "babylonjs/Misc/observable";
  31375. import { Nullable } from "babylonjs/types";
  31376. /**
  31377. * This class defines the direct association between an animation and a target
  31378. */
  31379. export class TargetedAnimation {
  31380. /**
  31381. * Animation to perform
  31382. */
  31383. animation: Animation;
  31384. /**
  31385. * Target to animate
  31386. */
  31387. target: any;
  31388. }
  31389. /**
  31390. * Use this class to create coordinated animations on multiple targets
  31391. */
  31392. export class AnimationGroup implements IDisposable {
  31393. /** The name of the animation group */
  31394. name: string;
  31395. private _scene;
  31396. private _targetedAnimations;
  31397. private _animatables;
  31398. private _from;
  31399. private _to;
  31400. private _isStarted;
  31401. private _isPaused;
  31402. private _speedRatio;
  31403. /**
  31404. * Gets or sets the unique id of the node
  31405. */
  31406. uniqueId: number;
  31407. /**
  31408. * This observable will notify when one animation have ended
  31409. */
  31410. onAnimationEndObservable: Observable<TargetedAnimation>;
  31411. /**
  31412. * Observer raised when one animation loops
  31413. */
  31414. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31415. /**
  31416. * This observable will notify when all animations have ended.
  31417. */
  31418. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31419. /**
  31420. * This observable will notify when all animations have paused.
  31421. */
  31422. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31423. /**
  31424. * This observable will notify when all animations are playing.
  31425. */
  31426. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31427. /**
  31428. * Gets the first frame
  31429. */
  31430. readonly from: number;
  31431. /**
  31432. * Gets the last frame
  31433. */
  31434. readonly to: number;
  31435. /**
  31436. * Define if the animations are started
  31437. */
  31438. readonly isStarted: boolean;
  31439. /**
  31440. * Gets a value indicating that the current group is playing
  31441. */
  31442. readonly isPlaying: boolean;
  31443. /**
  31444. * Gets or sets the speed ratio to use for all animations
  31445. */
  31446. /**
  31447. * Gets or sets the speed ratio to use for all animations
  31448. */
  31449. speedRatio: number;
  31450. /**
  31451. * Gets the targeted animations for this animation group
  31452. */
  31453. readonly targetedAnimations: Array<TargetedAnimation>;
  31454. /**
  31455. * returning the list of animatables controlled by this animation group.
  31456. */
  31457. readonly animatables: Array<Animatable>;
  31458. /**
  31459. * Instantiates a new Animation Group.
  31460. * This helps managing several animations at once.
  31461. * @see http://doc.babylonjs.com/how_to/group
  31462. * @param name Defines the name of the group
  31463. * @param scene Defines the scene the group belongs to
  31464. */
  31465. constructor(
  31466. /** The name of the animation group */
  31467. name: string, scene?: Nullable<Scene>);
  31468. /**
  31469. * Add an animation (with its target) in the group
  31470. * @param animation defines the animation we want to add
  31471. * @param target defines the target of the animation
  31472. * @returns the TargetedAnimation object
  31473. */
  31474. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31475. /**
  31476. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31477. * It can add constant keys at begin or end
  31478. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31479. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31480. * @returns the animation group
  31481. */
  31482. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31483. /**
  31484. * Start all animations on given targets
  31485. * @param loop defines if animations must loop
  31486. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31487. * @param from defines the from key (optional)
  31488. * @param to defines the to key (optional)
  31489. * @returns the current animation group
  31490. */
  31491. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31492. /**
  31493. * Pause all animations
  31494. * @returns the animation group
  31495. */
  31496. pause(): AnimationGroup;
  31497. /**
  31498. * Play all animations to initial state
  31499. * This function will start() the animations if they were not started or will restart() them if they were paused
  31500. * @param loop defines if animations must loop
  31501. * @returns the animation group
  31502. */
  31503. play(loop?: boolean): AnimationGroup;
  31504. /**
  31505. * Reset all animations to initial state
  31506. * @returns the animation group
  31507. */
  31508. reset(): AnimationGroup;
  31509. /**
  31510. * Restart animations from key 0
  31511. * @returns the animation group
  31512. */
  31513. restart(): AnimationGroup;
  31514. /**
  31515. * Stop all animations
  31516. * @returns the animation group
  31517. */
  31518. stop(): AnimationGroup;
  31519. /**
  31520. * Set animation weight for all animatables
  31521. * @param weight defines the weight to use
  31522. * @return the animationGroup
  31523. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31524. */
  31525. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31526. /**
  31527. * Synchronize and normalize all animatables with a source animatable
  31528. * @param root defines the root animatable to synchronize with
  31529. * @return the animationGroup
  31530. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31531. */
  31532. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31533. /**
  31534. * Goes to a specific frame in this animation group
  31535. * @param frame the frame number to go to
  31536. * @return the animationGroup
  31537. */
  31538. goToFrame(frame: number): AnimationGroup;
  31539. /**
  31540. * Dispose all associated resources
  31541. */
  31542. dispose(): void;
  31543. private _checkAnimationGroupEnded;
  31544. /**
  31545. * Returns a new AnimationGroup object parsed from the source provided.
  31546. * @param parsedAnimationGroup defines the source
  31547. * @param scene defines the scene that will receive the animationGroup
  31548. * @returns a new AnimationGroup
  31549. */
  31550. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31551. /**
  31552. * Returns the string "AnimationGroup"
  31553. * @returns "AnimationGroup"
  31554. */
  31555. getClassName(): string;
  31556. /**
  31557. * Creates a detailled string about the object
  31558. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31559. * @returns a string representing the object
  31560. */
  31561. toString(fullDetails?: boolean): string;
  31562. }
  31563. }
  31564. declare module "babylonjs/scene" {
  31565. import { Nullable } from "babylonjs/types";
  31566. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31567. import { Observable } from "babylonjs/Misc/observable";
  31568. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31569. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31570. import { Geometry } from "babylonjs/Meshes/geometry";
  31571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31572. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31574. import { Mesh } from "babylonjs/Meshes/mesh";
  31575. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31576. import { Bone } from "babylonjs/Bones/bone";
  31577. import { Skeleton } from "babylonjs/Bones/skeleton";
  31578. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31579. import { Camera } from "babylonjs/Cameras/camera";
  31580. import { AbstractScene } from "babylonjs/abstractScene";
  31581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31583. import { Material } from "babylonjs/Materials/material";
  31584. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31585. import { Effect } from "babylonjs/Materials/effect";
  31586. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31587. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31588. import { Light } from "babylonjs/Lights/light";
  31589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31590. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31591. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31592. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31593. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31594. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31595. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31596. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31597. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31598. import { Engine } from "babylonjs/Engines/engine";
  31599. import { Node } from "babylonjs/node";
  31600. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31601. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31602. import { Ray } from "babylonjs/Culling/ray";
  31603. import { Animation } from "babylonjs/Animations/animation";
  31604. import { Animatable } from "babylonjs/Animations/animatable";
  31605. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31606. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31607. import { Collider } from "babylonjs/Collisions/collider";
  31608. /**
  31609. * Define an interface for all classes that will hold resources
  31610. */
  31611. export interface IDisposable {
  31612. /**
  31613. * Releases all held resources
  31614. */
  31615. dispose(): void;
  31616. }
  31617. /** Interface defining initialization parameters for Scene class */
  31618. export interface SceneOptions {
  31619. /**
  31620. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31621. * It will improve performance when the number of geometries becomes important.
  31622. */
  31623. useGeometryUniqueIdsMap?: boolean;
  31624. /**
  31625. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31626. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31627. */
  31628. useMaterialMeshMap?: boolean;
  31629. /**
  31630. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31631. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31632. */
  31633. useClonedMeshhMap?: boolean;
  31634. }
  31635. /**
  31636. * Represents a scene to be rendered by the engine.
  31637. * @see http://doc.babylonjs.com/features/scene
  31638. */
  31639. export class Scene extends AbstractScene implements IAnimatable {
  31640. private static _uniqueIdCounter;
  31641. /** The fog is deactivated */
  31642. static readonly FOGMODE_NONE: number;
  31643. /** The fog density is following an exponential function */
  31644. static readonly FOGMODE_EXP: number;
  31645. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31646. static readonly FOGMODE_EXP2: number;
  31647. /** The fog density is following a linear function. */
  31648. static readonly FOGMODE_LINEAR: number;
  31649. /**
  31650. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31652. */
  31653. static MinDeltaTime: number;
  31654. /**
  31655. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31657. */
  31658. static MaxDeltaTime: number;
  31659. /**
  31660. * Factory used to create the default material.
  31661. * @param name The name of the material to create
  31662. * @param scene The scene to create the material for
  31663. * @returns The default material
  31664. */
  31665. static DefaultMaterialFactory(scene: Scene): Material;
  31666. /**
  31667. * Factory used to create the a collision coordinator.
  31668. * @returns The collision coordinator
  31669. */
  31670. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31671. /** @hidden */
  31672. readonly _isScene: boolean;
  31673. /**
  31674. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31675. */
  31676. autoClear: boolean;
  31677. /**
  31678. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31679. */
  31680. autoClearDepthAndStencil: boolean;
  31681. /**
  31682. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31683. */
  31684. clearColor: Color4;
  31685. /**
  31686. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31687. */
  31688. ambientColor: Color3;
  31689. /** @hidden */
  31690. _environmentBRDFTexture: BaseTexture;
  31691. /** @hidden */
  31692. protected _environmentTexture: Nullable<BaseTexture>;
  31693. /**
  31694. * Texture used in all pbr material as the reflection texture.
  31695. * As in the majority of the scene they are the same (exception for multi room and so on),
  31696. * this is easier to reference from here than from all the materials.
  31697. */
  31698. /**
  31699. * Texture used in all pbr material as the reflection texture.
  31700. * As in the majority of the scene they are the same (exception for multi room and so on),
  31701. * this is easier to set here than in all the materials.
  31702. */
  31703. environmentTexture: Nullable<BaseTexture>;
  31704. /** @hidden */
  31705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31706. /**
  31707. * Default image processing configuration used either in the rendering
  31708. * Forward main pass or through the imageProcessingPostProcess if present.
  31709. * As in the majority of the scene they are the same (exception for multi camera),
  31710. * this is easier to reference from here than from all the materials and post process.
  31711. *
  31712. * No setter as we it is a shared configuration, you can set the values instead.
  31713. */
  31714. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31715. private _forceWireframe;
  31716. /**
  31717. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31718. */
  31719. forceWireframe: boolean;
  31720. private _forcePointsCloud;
  31721. /**
  31722. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31723. */
  31724. forcePointsCloud: boolean;
  31725. /**
  31726. * Gets or sets the active clipplane 1
  31727. */
  31728. clipPlane: Nullable<Plane>;
  31729. /**
  31730. * Gets or sets the active clipplane 2
  31731. */
  31732. clipPlane2: Nullable<Plane>;
  31733. /**
  31734. * Gets or sets the active clipplane 3
  31735. */
  31736. clipPlane3: Nullable<Plane>;
  31737. /**
  31738. * Gets or sets the active clipplane 4
  31739. */
  31740. clipPlane4: Nullable<Plane>;
  31741. /**
  31742. * Gets or sets a boolean indicating if animations are enabled
  31743. */
  31744. animationsEnabled: boolean;
  31745. private _animationPropertiesOverride;
  31746. /**
  31747. * Gets or sets the animation properties override
  31748. */
  31749. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31750. /**
  31751. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31752. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31753. */
  31754. useConstantAnimationDeltaTime: boolean;
  31755. /**
  31756. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31757. * Please note that it requires to run a ray cast through the scene on every frame
  31758. */
  31759. constantlyUpdateMeshUnderPointer: boolean;
  31760. /**
  31761. * Defines the HTML cursor to use when hovering over interactive elements
  31762. */
  31763. hoverCursor: string;
  31764. /**
  31765. * Defines the HTML default cursor to use (empty by default)
  31766. */
  31767. defaultCursor: string;
  31768. /**
  31769. * This is used to call preventDefault() on pointer down
  31770. * in order to block unwanted artifacts like system double clicks
  31771. */
  31772. preventDefaultOnPointerDown: boolean;
  31773. /**
  31774. * This is used to call preventDefault() on pointer up
  31775. * in order to block unwanted artifacts like system double clicks
  31776. */
  31777. preventDefaultOnPointerUp: boolean;
  31778. /**
  31779. * Gets or sets user defined metadata
  31780. */
  31781. metadata: any;
  31782. /**
  31783. * For internal use only. Please do not use.
  31784. */
  31785. reservedDataStore: any;
  31786. /**
  31787. * Gets the name of the plugin used to load this scene (null by default)
  31788. */
  31789. loadingPluginName: string;
  31790. /**
  31791. * Use this array to add regular expressions used to disable offline support for specific urls
  31792. */
  31793. disableOfflineSupportExceptionRules: RegExp[];
  31794. /**
  31795. * An event triggered when the scene is disposed.
  31796. */
  31797. onDisposeObservable: Observable<Scene>;
  31798. private _onDisposeObserver;
  31799. /** Sets a function to be executed when this scene is disposed. */
  31800. onDispose: () => void;
  31801. /**
  31802. * An event triggered before rendering the scene (right after animations and physics)
  31803. */
  31804. onBeforeRenderObservable: Observable<Scene>;
  31805. private _onBeforeRenderObserver;
  31806. /** Sets a function to be executed before rendering this scene */
  31807. beforeRender: Nullable<() => void>;
  31808. /**
  31809. * An event triggered after rendering the scene
  31810. */
  31811. onAfterRenderObservable: Observable<Scene>;
  31812. private _onAfterRenderObserver;
  31813. /** Sets a function to be executed after rendering this scene */
  31814. afterRender: Nullable<() => void>;
  31815. /**
  31816. * An event triggered before animating the scene
  31817. */
  31818. onBeforeAnimationsObservable: Observable<Scene>;
  31819. /**
  31820. * An event triggered after animations processing
  31821. */
  31822. onAfterAnimationsObservable: Observable<Scene>;
  31823. /**
  31824. * An event triggered before draw calls are ready to be sent
  31825. */
  31826. onBeforeDrawPhaseObservable: Observable<Scene>;
  31827. /**
  31828. * An event triggered after draw calls have been sent
  31829. */
  31830. onAfterDrawPhaseObservable: Observable<Scene>;
  31831. /**
  31832. * An event triggered when the scene is ready
  31833. */
  31834. onReadyObservable: Observable<Scene>;
  31835. /**
  31836. * An event triggered before rendering a camera
  31837. */
  31838. onBeforeCameraRenderObservable: Observable<Camera>;
  31839. private _onBeforeCameraRenderObserver;
  31840. /** Sets a function to be executed before rendering a camera*/
  31841. beforeCameraRender: () => void;
  31842. /**
  31843. * An event triggered after rendering a camera
  31844. */
  31845. onAfterCameraRenderObservable: Observable<Camera>;
  31846. private _onAfterCameraRenderObserver;
  31847. /** Sets a function to be executed after rendering a camera*/
  31848. afterCameraRender: () => void;
  31849. /**
  31850. * An event triggered when active meshes evaluation is about to start
  31851. */
  31852. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31853. /**
  31854. * An event triggered when active meshes evaluation is done
  31855. */
  31856. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31857. /**
  31858. * An event triggered when particles rendering is about to start
  31859. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31860. */
  31861. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31862. /**
  31863. * An event triggered when particles rendering is done
  31864. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31865. */
  31866. onAfterParticlesRenderingObservable: Observable<Scene>;
  31867. /**
  31868. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31869. */
  31870. onDataLoadedObservable: Observable<Scene>;
  31871. /**
  31872. * An event triggered when a camera is created
  31873. */
  31874. onNewCameraAddedObservable: Observable<Camera>;
  31875. /**
  31876. * An event triggered when a camera is removed
  31877. */
  31878. onCameraRemovedObservable: Observable<Camera>;
  31879. /**
  31880. * An event triggered when a light is created
  31881. */
  31882. onNewLightAddedObservable: Observable<Light>;
  31883. /**
  31884. * An event triggered when a light is removed
  31885. */
  31886. onLightRemovedObservable: Observable<Light>;
  31887. /**
  31888. * An event triggered when a geometry is created
  31889. */
  31890. onNewGeometryAddedObservable: Observable<Geometry>;
  31891. /**
  31892. * An event triggered when a geometry is removed
  31893. */
  31894. onGeometryRemovedObservable: Observable<Geometry>;
  31895. /**
  31896. * An event triggered when a transform node is created
  31897. */
  31898. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31899. /**
  31900. * An event triggered when a transform node is removed
  31901. */
  31902. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31903. /**
  31904. * An event triggered when a mesh is created
  31905. */
  31906. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31907. /**
  31908. * An event triggered when a mesh is removed
  31909. */
  31910. onMeshRemovedObservable: Observable<AbstractMesh>;
  31911. /**
  31912. * An event triggered when a material is created
  31913. */
  31914. onNewMaterialAddedObservable: Observable<Material>;
  31915. /**
  31916. * An event triggered when a material is removed
  31917. */
  31918. onMaterialRemovedObservable: Observable<Material>;
  31919. /**
  31920. * An event triggered when a texture is created
  31921. */
  31922. onNewTextureAddedObservable: Observable<BaseTexture>;
  31923. /**
  31924. * An event triggered when a texture is removed
  31925. */
  31926. onTextureRemovedObservable: Observable<BaseTexture>;
  31927. /**
  31928. * An event triggered when render targets are about to be rendered
  31929. * Can happen multiple times per frame.
  31930. */
  31931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31932. /**
  31933. * An event triggered when render targets were rendered.
  31934. * Can happen multiple times per frame.
  31935. */
  31936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31937. /**
  31938. * An event triggered before calculating deterministic simulation step
  31939. */
  31940. onBeforeStepObservable: Observable<Scene>;
  31941. /**
  31942. * An event triggered after calculating deterministic simulation step
  31943. */
  31944. onAfterStepObservable: Observable<Scene>;
  31945. /**
  31946. * An event triggered when the activeCamera property is updated
  31947. */
  31948. onActiveCameraChanged: Observable<Scene>;
  31949. /**
  31950. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31951. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31952. * 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)
  31953. */
  31954. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31955. /**
  31956. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31958. * 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)
  31959. */
  31960. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31961. /**
  31962. * This Observable will when a mesh has been imported into the scene.
  31963. */
  31964. onMeshImportedObservable: Observable<AbstractMesh>;
  31965. /** @hidden */
  31966. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31967. /**
  31968. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31969. */
  31970. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31971. /**
  31972. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31973. */
  31974. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31975. /**
  31976. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31977. */
  31978. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31979. private _onPointerMove;
  31980. private _onPointerDown;
  31981. private _onPointerUp;
  31982. /** Callback called when a pointer move is detected */
  31983. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31984. /** Callback called when a pointer down is detected */
  31985. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31986. /** Callback called when a pointer up is detected */
  31987. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31988. /** Callback called when a pointer pick is detected */
  31989. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31990. /**
  31991. * 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).
  31992. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31993. */
  31994. onPrePointerObservable: Observable<PointerInfoPre>;
  31995. /**
  31996. * Observable event triggered each time an input event is received from the rendering canvas
  31997. */
  31998. onPointerObservable: Observable<PointerInfo>;
  31999. /**
  32000. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32001. */
  32002. readonly unTranslatedPointer: Vector2;
  32003. /** The distance in pixel that you have to move to prevent some events */
  32004. static DragMovementThreshold: number;
  32005. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32006. static LongPressDelay: number;
  32007. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32008. static DoubleClickDelay: number;
  32009. /** If you need to check double click without raising a single click at first click, enable this flag */
  32010. static ExclusiveDoubleClickMode: boolean;
  32011. private _initClickEvent;
  32012. private _initActionManager;
  32013. private _delayedSimpleClick;
  32014. private _delayedSimpleClickTimeout;
  32015. private _previousDelayedSimpleClickTimeout;
  32016. private _meshPickProceed;
  32017. private _previousButtonPressed;
  32018. private _currentPickResult;
  32019. private _previousPickResult;
  32020. private _totalPointersPressed;
  32021. private _doubleClickOccured;
  32022. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32023. cameraToUseForPointers: Nullable<Camera>;
  32024. private _pointerX;
  32025. private _pointerY;
  32026. private _unTranslatedPointerX;
  32027. private _unTranslatedPointerY;
  32028. private _startingPointerPosition;
  32029. private _previousStartingPointerPosition;
  32030. private _startingPointerTime;
  32031. private _previousStartingPointerTime;
  32032. private _pointerCaptures;
  32033. private _timeAccumulator;
  32034. private _currentStepId;
  32035. private _currentInternalStep;
  32036. /** @hidden */
  32037. _mirroredCameraPosition: Nullable<Vector3>;
  32038. /**
  32039. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32040. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32041. */
  32042. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32043. /**
  32044. * Observable event triggered each time an keyboard event is received from the hosting window
  32045. */
  32046. onKeyboardObservable: Observable<KeyboardInfo>;
  32047. private _onKeyDown;
  32048. private _onKeyUp;
  32049. private _onCanvasFocusObserver;
  32050. private _onCanvasBlurObserver;
  32051. private _useRightHandedSystem;
  32052. /**
  32053. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32054. */
  32055. useRightHandedSystem: boolean;
  32056. /**
  32057. * Sets the step Id used by deterministic lock step
  32058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32059. * @param newStepId defines the step Id
  32060. */
  32061. setStepId(newStepId: number): void;
  32062. /**
  32063. * Gets the step Id used by deterministic lock step
  32064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32065. * @returns the step Id
  32066. */
  32067. getStepId(): number;
  32068. /**
  32069. * Gets the internal step used by deterministic lock step
  32070. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32071. * @returns the internal step
  32072. */
  32073. getInternalStep(): number;
  32074. private _fogEnabled;
  32075. /**
  32076. * Gets or sets a boolean indicating if fog is enabled on this scene
  32077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32078. * (Default is true)
  32079. */
  32080. fogEnabled: boolean;
  32081. private _fogMode;
  32082. /**
  32083. * Gets or sets the fog mode to use
  32084. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32085. * | mode | value |
  32086. * | --- | --- |
  32087. * | FOGMODE_NONE | 0 |
  32088. * | FOGMODE_EXP | 1 |
  32089. * | FOGMODE_EXP2 | 2 |
  32090. * | FOGMODE_LINEAR | 3 |
  32091. */
  32092. fogMode: number;
  32093. /**
  32094. * Gets or sets the fog color to use
  32095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32096. * (Default is Color3(0.2, 0.2, 0.3))
  32097. */
  32098. fogColor: Color3;
  32099. /**
  32100. * Gets or sets the fog density to use
  32101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32102. * (Default is 0.1)
  32103. */
  32104. fogDensity: number;
  32105. /**
  32106. * Gets or sets the fog start distance to use
  32107. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32108. * (Default is 0)
  32109. */
  32110. fogStart: number;
  32111. /**
  32112. * Gets or sets the fog end distance to use
  32113. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32114. * (Default is 1000)
  32115. */
  32116. fogEnd: number;
  32117. private _shadowsEnabled;
  32118. /**
  32119. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32120. */
  32121. shadowsEnabled: boolean;
  32122. private _lightsEnabled;
  32123. /**
  32124. * Gets or sets a boolean indicating if lights are enabled on this scene
  32125. */
  32126. lightsEnabled: boolean;
  32127. /** All of the active cameras added to this scene. */
  32128. activeCameras: Camera[];
  32129. private _activeCamera;
  32130. /** Gets or sets the current active camera */
  32131. activeCamera: Nullable<Camera>;
  32132. private _defaultMaterial;
  32133. /** The default material used on meshes when no material is affected */
  32134. /** The default material used on meshes when no material is affected */
  32135. defaultMaterial: Material;
  32136. private _texturesEnabled;
  32137. /**
  32138. * Gets or sets a boolean indicating if textures are enabled on this scene
  32139. */
  32140. texturesEnabled: boolean;
  32141. /**
  32142. * Gets or sets a boolean indicating if particles are enabled on this scene
  32143. */
  32144. particlesEnabled: boolean;
  32145. /**
  32146. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32147. */
  32148. spritesEnabled: boolean;
  32149. private _skeletonsEnabled;
  32150. /**
  32151. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32152. */
  32153. skeletonsEnabled: boolean;
  32154. /**
  32155. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32156. */
  32157. lensFlaresEnabled: boolean;
  32158. /**
  32159. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32161. */
  32162. collisionsEnabled: boolean;
  32163. private _collisionCoordinator;
  32164. /** @hidden */
  32165. readonly collisionCoordinator: ICollisionCoordinator;
  32166. /**
  32167. * Defines the gravity applied to this scene (used only for collisions)
  32168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32169. */
  32170. gravity: Vector3;
  32171. /**
  32172. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32173. */
  32174. postProcessesEnabled: boolean;
  32175. /**
  32176. * The list of postprocesses added to the scene
  32177. */
  32178. postProcesses: PostProcess[];
  32179. /**
  32180. * Gets the current postprocess manager
  32181. */
  32182. postProcessManager: PostProcessManager;
  32183. /**
  32184. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32185. */
  32186. renderTargetsEnabled: boolean;
  32187. /**
  32188. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32189. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32190. */
  32191. dumpNextRenderTargets: boolean;
  32192. /**
  32193. * The list of user defined render targets added to the scene
  32194. */
  32195. customRenderTargets: RenderTargetTexture[];
  32196. /**
  32197. * Defines if texture loading must be delayed
  32198. * If true, textures will only be loaded when they need to be rendered
  32199. */
  32200. useDelayedTextureLoading: boolean;
  32201. /**
  32202. * Gets the list of meshes imported to the scene through SceneLoader
  32203. */
  32204. importedMeshesFiles: String[];
  32205. /**
  32206. * Gets or sets a boolean indicating if probes are enabled on this scene
  32207. */
  32208. probesEnabled: boolean;
  32209. /**
  32210. * Gets or sets the current offline provider to use to store scene data
  32211. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32212. */
  32213. offlineProvider: IOfflineProvider;
  32214. /**
  32215. * Gets or sets the action manager associated with the scene
  32216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32217. */
  32218. actionManager: AbstractActionManager;
  32219. private _meshesForIntersections;
  32220. /**
  32221. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32222. */
  32223. proceduralTexturesEnabled: boolean;
  32224. private _engine;
  32225. private _totalVertices;
  32226. /** @hidden */
  32227. _activeIndices: PerfCounter;
  32228. /** @hidden */
  32229. _activeParticles: PerfCounter;
  32230. /** @hidden */
  32231. _activeBones: PerfCounter;
  32232. private _animationRatio;
  32233. /** @hidden */
  32234. _animationTimeLast: number;
  32235. /** @hidden */
  32236. _animationTime: number;
  32237. /**
  32238. * Gets or sets a general scale for animation speed
  32239. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32240. */
  32241. animationTimeScale: number;
  32242. /** @hidden */
  32243. _cachedMaterial: Nullable<Material>;
  32244. /** @hidden */
  32245. _cachedEffect: Nullable<Effect>;
  32246. /** @hidden */
  32247. _cachedVisibility: Nullable<number>;
  32248. private _renderId;
  32249. private _frameId;
  32250. private _executeWhenReadyTimeoutId;
  32251. private _intermediateRendering;
  32252. private _viewUpdateFlag;
  32253. private _projectionUpdateFlag;
  32254. private _alternateViewUpdateFlag;
  32255. private _alternateProjectionUpdateFlag;
  32256. /** @hidden */
  32257. _toBeDisposed: Nullable<IDisposable>[];
  32258. private _activeRequests;
  32259. /** @hidden */
  32260. _pendingData: any[];
  32261. private _isDisposed;
  32262. /**
  32263. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32264. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32265. */
  32266. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32267. private _activeMeshes;
  32268. private _processedMaterials;
  32269. private _renderTargets;
  32270. /** @hidden */
  32271. _activeParticleSystems: SmartArray<IParticleSystem>;
  32272. private _activeSkeletons;
  32273. private _softwareSkinnedMeshes;
  32274. private _renderingManager;
  32275. /** @hidden */
  32276. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32277. private _transformMatrix;
  32278. private _sceneUbo;
  32279. private _alternateSceneUbo;
  32280. private _viewMatrix;
  32281. private _projectionMatrix;
  32282. private _alternateViewMatrix;
  32283. private _alternateProjectionMatrix;
  32284. private _alternateTransformMatrix;
  32285. private _useAlternateCameraConfiguration;
  32286. private _alternateRendering;
  32287. private _wheelEventName;
  32288. /** @hidden */
  32289. _forcedViewPosition: Nullable<Vector3>;
  32290. /** @hidden */
  32291. readonly _isAlternateRenderingEnabled: boolean;
  32292. private _frustumPlanes;
  32293. /**
  32294. * Gets the list of frustum planes (built from the active camera)
  32295. */
  32296. readonly frustumPlanes: Plane[];
  32297. /**
  32298. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32299. * This is useful if there are more lights that the maximum simulteanous authorized
  32300. */
  32301. requireLightSorting: boolean;
  32302. /** @hidden */
  32303. readonly useMaterialMeshMap: boolean;
  32304. /** @hidden */
  32305. readonly useClonedMeshhMap: boolean;
  32306. private _pointerOverMesh;
  32307. private _pickedDownMesh;
  32308. private _pickedUpMesh;
  32309. private _externalData;
  32310. private _uid;
  32311. /**
  32312. * @hidden
  32313. * Backing store of defined scene components.
  32314. */
  32315. _components: ISceneComponent[];
  32316. /**
  32317. * @hidden
  32318. * Backing store of defined scene components.
  32319. */
  32320. _serializableComponents: ISceneSerializableComponent[];
  32321. /**
  32322. * List of components to register on the next registration step.
  32323. */
  32324. private _transientComponents;
  32325. /**
  32326. * Registers the transient components if needed.
  32327. */
  32328. private _registerTransientComponents;
  32329. /**
  32330. * @hidden
  32331. * Add a component to the scene.
  32332. * Note that the ccomponent could be registered on th next frame if this is called after
  32333. * the register component stage.
  32334. * @param component Defines the component to add to the scene
  32335. */
  32336. _addComponent(component: ISceneComponent): void;
  32337. /**
  32338. * @hidden
  32339. * Gets a component from the scene.
  32340. * @param name defines the name of the component to retrieve
  32341. * @returns the component or null if not present
  32342. */
  32343. _getComponent(name: string): Nullable<ISceneComponent>;
  32344. /**
  32345. * @hidden
  32346. * Defines the actions happening before camera updates.
  32347. */
  32348. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32349. /**
  32350. * @hidden
  32351. * Defines the actions happening before clear the canvas.
  32352. */
  32353. _beforeClearStage: Stage<SimpleStageAction>;
  32354. /**
  32355. * @hidden
  32356. * Defines the actions when collecting render targets for the frame.
  32357. */
  32358. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32359. /**
  32360. * @hidden
  32361. * Defines the actions happening for one camera in the frame.
  32362. */
  32363. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32364. /**
  32365. * @hidden
  32366. * Defines the actions happening during the per mesh ready checks.
  32367. */
  32368. _isReadyForMeshStage: Stage<MeshStageAction>;
  32369. /**
  32370. * @hidden
  32371. * Defines the actions happening before evaluate active mesh checks.
  32372. */
  32373. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32374. /**
  32375. * @hidden
  32376. * Defines the actions happening during the evaluate sub mesh checks.
  32377. */
  32378. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32379. /**
  32380. * @hidden
  32381. * Defines the actions happening during the active mesh stage.
  32382. */
  32383. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32384. /**
  32385. * @hidden
  32386. * Defines the actions happening during the per camera render target step.
  32387. */
  32388. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32389. /**
  32390. * @hidden
  32391. * Defines the actions happening just before the active camera is drawing.
  32392. */
  32393. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32394. /**
  32395. * @hidden
  32396. * Defines the actions happening just before a render target is drawing.
  32397. */
  32398. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32399. /**
  32400. * @hidden
  32401. * Defines the actions happening just before a rendering group is drawing.
  32402. */
  32403. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32404. /**
  32405. * @hidden
  32406. * Defines the actions happening just before a mesh is drawing.
  32407. */
  32408. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32409. /**
  32410. * @hidden
  32411. * Defines the actions happening just after a mesh has been drawn.
  32412. */
  32413. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32414. /**
  32415. * @hidden
  32416. * Defines the actions happening just after a rendering group has been drawn.
  32417. */
  32418. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32419. /**
  32420. * @hidden
  32421. * Defines the actions happening just after the active camera has been drawn.
  32422. */
  32423. _afterCameraDrawStage: Stage<CameraStageAction>;
  32424. /**
  32425. * @hidden
  32426. * Defines the actions happening just after a render target has been drawn.
  32427. */
  32428. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32429. /**
  32430. * @hidden
  32431. * Defines the actions happening just after rendering all cameras and computing intersections.
  32432. */
  32433. _afterRenderStage: Stage<SimpleStageAction>;
  32434. /**
  32435. * @hidden
  32436. * Defines the actions happening when a pointer move event happens.
  32437. */
  32438. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32439. /**
  32440. * @hidden
  32441. * Defines the actions happening when a pointer down event happens.
  32442. */
  32443. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32444. /**
  32445. * @hidden
  32446. * Defines the actions happening when a pointer up event happens.
  32447. */
  32448. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32449. /**
  32450. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32451. */
  32452. private geometriesByUniqueId;
  32453. /**
  32454. * Creates a new Scene
  32455. * @param engine defines the engine to use to render this scene
  32456. * @param options defines the scene options
  32457. */
  32458. constructor(engine: Engine, options?: SceneOptions);
  32459. private _defaultMeshCandidates;
  32460. /**
  32461. * @hidden
  32462. */
  32463. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32464. private _defaultSubMeshCandidates;
  32465. /**
  32466. * @hidden
  32467. */
  32468. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32469. /**
  32470. * Sets the default candidate providers for the scene.
  32471. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32472. * and getCollidingSubMeshCandidates to their default function
  32473. */
  32474. setDefaultCandidateProviders(): void;
  32475. /**
  32476. * Gets the mesh that is currently under the pointer
  32477. */
  32478. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32479. /**
  32480. * Gets or sets the current on-screen X position of the pointer
  32481. */
  32482. pointerX: number;
  32483. /**
  32484. * Gets or sets the current on-screen Y position of the pointer
  32485. */
  32486. pointerY: number;
  32487. /**
  32488. * Gets the cached material (ie. the latest rendered one)
  32489. * @returns the cached material
  32490. */
  32491. getCachedMaterial(): Nullable<Material>;
  32492. /**
  32493. * Gets the cached effect (ie. the latest rendered one)
  32494. * @returns the cached effect
  32495. */
  32496. getCachedEffect(): Nullable<Effect>;
  32497. /**
  32498. * Gets the cached visibility state (ie. the latest rendered one)
  32499. * @returns the cached visibility state
  32500. */
  32501. getCachedVisibility(): Nullable<number>;
  32502. /**
  32503. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32504. * @param material defines the current material
  32505. * @param effect defines the current effect
  32506. * @param visibility defines the current visibility state
  32507. * @returns true if one parameter is not cached
  32508. */
  32509. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32510. /**
  32511. * Gets the engine associated with the scene
  32512. * @returns an Engine
  32513. */
  32514. getEngine(): Engine;
  32515. /**
  32516. * Gets the total number of vertices rendered per frame
  32517. * @returns the total number of vertices rendered per frame
  32518. */
  32519. getTotalVertices(): number;
  32520. /**
  32521. * Gets the performance counter for total vertices
  32522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32523. */
  32524. readonly totalVerticesPerfCounter: PerfCounter;
  32525. /**
  32526. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32527. * @returns the total number of active indices rendered per frame
  32528. */
  32529. getActiveIndices(): number;
  32530. /**
  32531. * Gets the performance counter for active indices
  32532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32533. */
  32534. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32535. /**
  32536. * Gets the total number of active particles rendered per frame
  32537. * @returns the total number of active particles rendered per frame
  32538. */
  32539. getActiveParticles(): number;
  32540. /**
  32541. * Gets the performance counter for active particles
  32542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32543. */
  32544. readonly activeParticlesPerfCounter: PerfCounter;
  32545. /**
  32546. * Gets the total number of active bones rendered per frame
  32547. * @returns the total number of active bones rendered per frame
  32548. */
  32549. getActiveBones(): number;
  32550. /**
  32551. * Gets the performance counter for active bones
  32552. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32553. */
  32554. readonly activeBonesPerfCounter: PerfCounter;
  32555. /**
  32556. * Gets the array of active meshes
  32557. * @returns an array of AbstractMesh
  32558. */
  32559. getActiveMeshes(): SmartArray<AbstractMesh>;
  32560. /**
  32561. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32562. * @returns a number
  32563. */
  32564. getAnimationRatio(): number;
  32565. /**
  32566. * Gets an unique Id for the current render phase
  32567. * @returns a number
  32568. */
  32569. getRenderId(): number;
  32570. /**
  32571. * Gets an unique Id for the current frame
  32572. * @returns a number
  32573. */
  32574. getFrameId(): number;
  32575. /** Call this function if you want to manually increment the render Id*/
  32576. incrementRenderId(): void;
  32577. private _updatePointerPosition;
  32578. private _createUbo;
  32579. private _createAlternateUbo;
  32580. private _setRayOnPointerInfo;
  32581. /**
  32582. * Use this method to simulate a pointer move on a mesh
  32583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32586. * @returns the current scene
  32587. */
  32588. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32589. private _processPointerMove;
  32590. private _checkPrePointerObservable;
  32591. /**
  32592. * Use this method to simulate a pointer down on a mesh
  32593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32596. * @returns the current scene
  32597. */
  32598. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32599. private _processPointerDown;
  32600. /**
  32601. * Use this method to simulate a pointer up on a mesh
  32602. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32603. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32604. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32605. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32606. * @returns the current scene
  32607. */
  32608. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32609. private _processPointerUp;
  32610. /**
  32611. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32612. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32613. * @returns true if the pointer was captured
  32614. */
  32615. isPointerCaptured(pointerId?: number): boolean;
  32616. /** @hidden */
  32617. _isPointerSwiping(): boolean;
  32618. /**
  32619. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32620. * @param attachUp defines if you want to attach events to pointerup
  32621. * @param attachDown defines if you want to attach events to pointerdown
  32622. * @param attachMove defines if you want to attach events to pointermove
  32623. */
  32624. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32625. /** Detaches all event handlers*/
  32626. detachControl(): void;
  32627. /**
  32628. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32629. * Delay loaded resources are not taking in account
  32630. * @return true if all required resources are ready
  32631. */
  32632. isReady(): boolean;
  32633. /** Resets all cached information relative to material (including effect and visibility) */
  32634. resetCachedMaterial(): void;
  32635. /**
  32636. * Registers a function to be called before every frame render
  32637. * @param func defines the function to register
  32638. */
  32639. registerBeforeRender(func: () => void): void;
  32640. /**
  32641. * Unregisters a function called before every frame render
  32642. * @param func defines the function to unregister
  32643. */
  32644. unregisterBeforeRender(func: () => void): void;
  32645. /**
  32646. * Registers a function to be called after every frame render
  32647. * @param func defines the function to register
  32648. */
  32649. registerAfterRender(func: () => void): void;
  32650. /**
  32651. * Unregisters a function called after every frame render
  32652. * @param func defines the function to unregister
  32653. */
  32654. unregisterAfterRender(func: () => void): void;
  32655. private _executeOnceBeforeRender;
  32656. /**
  32657. * The provided function will run before render once and will be disposed afterwards.
  32658. * A timeout delay can be provided so that the function will be executed in N ms.
  32659. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32660. * @param func The function to be executed.
  32661. * @param timeout optional delay in ms
  32662. */
  32663. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32664. /** @hidden */
  32665. _addPendingData(data: any): void;
  32666. /** @hidden */
  32667. _removePendingData(data: any): void;
  32668. /**
  32669. * Returns the number of items waiting to be loaded
  32670. * @returns the number of items waiting to be loaded
  32671. */
  32672. getWaitingItemsCount(): number;
  32673. /**
  32674. * Returns a boolean indicating if the scene is still loading data
  32675. */
  32676. readonly isLoading: boolean;
  32677. /**
  32678. * Registers a function to be executed when the scene is ready
  32679. * @param {Function} func - the function to be executed
  32680. */
  32681. executeWhenReady(func: () => void): void;
  32682. /**
  32683. * Returns a promise that resolves when the scene is ready
  32684. * @returns A promise that resolves when the scene is ready
  32685. */
  32686. whenReadyAsync(): Promise<void>;
  32687. /** @hidden */
  32688. _checkIsReady(): void;
  32689. /**
  32690. * Gets all animatable attached to the scene
  32691. */
  32692. readonly animatables: Animatable[];
  32693. /**
  32694. * Resets the last animation time frame.
  32695. * Useful to override when animations start running when loading a scene for the first time.
  32696. */
  32697. resetLastAnimationTimeFrame(): void;
  32698. /** @hidden */
  32699. _switchToAlternateCameraConfiguration(active: boolean): void;
  32700. /**
  32701. * Gets the current view matrix
  32702. * @returns a Matrix
  32703. */
  32704. getViewMatrix(): Matrix;
  32705. /**
  32706. * Gets the current projection matrix
  32707. * @returns a Matrix
  32708. */
  32709. getProjectionMatrix(): Matrix;
  32710. /**
  32711. * Gets the current transform matrix
  32712. * @returns a Matrix made of View * Projection
  32713. */
  32714. getTransformMatrix(): Matrix;
  32715. /**
  32716. * Sets the current transform matrix
  32717. * @param view defines the View matrix to use
  32718. * @param projection defines the Projection matrix to use
  32719. */
  32720. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32721. /** @hidden */
  32722. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32723. /**
  32724. * Gets the uniform buffer used to store scene data
  32725. * @returns a UniformBuffer
  32726. */
  32727. getSceneUniformBuffer(): UniformBuffer;
  32728. /**
  32729. * Gets an unique (relatively to the current scene) Id
  32730. * @returns an unique number for the scene
  32731. */
  32732. getUniqueId(): number;
  32733. /**
  32734. * Add a mesh to the list of scene's meshes
  32735. * @param newMesh defines the mesh to add
  32736. * @param recursive if all child meshes should also be added to the scene
  32737. */
  32738. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32739. /**
  32740. * Remove a mesh for the list of scene's meshes
  32741. * @param toRemove defines the mesh to remove
  32742. * @param recursive if all child meshes should also be removed from the scene
  32743. * @returns the index where the mesh was in the mesh list
  32744. */
  32745. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32746. /**
  32747. * Add a transform node to the list of scene's transform nodes
  32748. * @param newTransformNode defines the transform node to add
  32749. */
  32750. addTransformNode(newTransformNode: TransformNode): void;
  32751. /**
  32752. * Remove a transform node for the list of scene's transform nodes
  32753. * @param toRemove defines the transform node to remove
  32754. * @returns the index where the transform node was in the transform node list
  32755. */
  32756. removeTransformNode(toRemove: TransformNode): number;
  32757. /**
  32758. * Remove a skeleton for the list of scene's skeletons
  32759. * @param toRemove defines the skeleton to remove
  32760. * @returns the index where the skeleton was in the skeleton list
  32761. */
  32762. removeSkeleton(toRemove: Skeleton): number;
  32763. /**
  32764. * Remove a morph target for the list of scene's morph targets
  32765. * @param toRemove defines the morph target to remove
  32766. * @returns the index where the morph target was in the morph target list
  32767. */
  32768. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32769. /**
  32770. * Remove a light for the list of scene's lights
  32771. * @param toRemove defines the light to remove
  32772. * @returns the index where the light was in the light list
  32773. */
  32774. removeLight(toRemove: Light): number;
  32775. /**
  32776. * Remove a camera for the list of scene's cameras
  32777. * @param toRemove defines the camera to remove
  32778. * @returns the index where the camera was in the camera list
  32779. */
  32780. removeCamera(toRemove: Camera): number;
  32781. /**
  32782. * Remove a particle system for the list of scene's particle systems
  32783. * @param toRemove defines the particle system to remove
  32784. * @returns the index where the particle system was in the particle system list
  32785. */
  32786. removeParticleSystem(toRemove: IParticleSystem): number;
  32787. /**
  32788. * Remove a animation for the list of scene's animations
  32789. * @param toRemove defines the animation to remove
  32790. * @returns the index where the animation was in the animation list
  32791. */
  32792. removeAnimation(toRemove: Animation): number;
  32793. /**
  32794. * Removes the given animation group from this scene.
  32795. * @param toRemove The animation group to remove
  32796. * @returns The index of the removed animation group
  32797. */
  32798. removeAnimationGroup(toRemove: AnimationGroup): number;
  32799. /**
  32800. * Removes the given multi-material from this scene.
  32801. * @param toRemove The multi-material to remove
  32802. * @returns The index of the removed multi-material
  32803. */
  32804. removeMultiMaterial(toRemove: MultiMaterial): number;
  32805. /**
  32806. * Removes the given material from this scene.
  32807. * @param toRemove The material to remove
  32808. * @returns The index of the removed material
  32809. */
  32810. removeMaterial(toRemove: Material): number;
  32811. /**
  32812. * Removes the given action manager from this scene.
  32813. * @param toRemove The action manager to remove
  32814. * @returns The index of the removed action manager
  32815. */
  32816. removeActionManager(toRemove: AbstractActionManager): number;
  32817. /**
  32818. * Removes the given texture from this scene.
  32819. * @param toRemove The texture to remove
  32820. * @returns The index of the removed texture
  32821. */
  32822. removeTexture(toRemove: BaseTexture): number;
  32823. /**
  32824. * Adds the given light to this scene
  32825. * @param newLight The light to add
  32826. */
  32827. addLight(newLight: Light): void;
  32828. /**
  32829. * Sorts the list list based on light priorities
  32830. */
  32831. sortLightsByPriority(): void;
  32832. /**
  32833. * Adds the given camera to this scene
  32834. * @param newCamera The camera to add
  32835. */
  32836. addCamera(newCamera: Camera): void;
  32837. /**
  32838. * Adds the given skeleton to this scene
  32839. * @param newSkeleton The skeleton to add
  32840. */
  32841. addSkeleton(newSkeleton: Skeleton): void;
  32842. /**
  32843. * Adds the given particle system to this scene
  32844. * @param newParticleSystem The particle system to add
  32845. */
  32846. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32847. /**
  32848. * Adds the given animation to this scene
  32849. * @param newAnimation The animation to add
  32850. */
  32851. addAnimation(newAnimation: Animation): void;
  32852. /**
  32853. * Adds the given animation group to this scene.
  32854. * @param newAnimationGroup The animation group to add
  32855. */
  32856. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32857. /**
  32858. * Adds the given multi-material to this scene
  32859. * @param newMultiMaterial The multi-material to add
  32860. */
  32861. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32862. /**
  32863. * Adds the given material to this scene
  32864. * @param newMaterial The material to add
  32865. */
  32866. addMaterial(newMaterial: Material): void;
  32867. /**
  32868. * Adds the given morph target to this scene
  32869. * @param newMorphTargetManager The morph target to add
  32870. */
  32871. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32872. /**
  32873. * Adds the given geometry to this scene
  32874. * @param newGeometry The geometry to add
  32875. */
  32876. addGeometry(newGeometry: Geometry): void;
  32877. /**
  32878. * Adds the given action manager to this scene
  32879. * @param newActionManager The action manager to add
  32880. */
  32881. addActionManager(newActionManager: AbstractActionManager): void;
  32882. /**
  32883. * Adds the given texture to this scene.
  32884. * @param newTexture The texture to add
  32885. */
  32886. addTexture(newTexture: BaseTexture): void;
  32887. /**
  32888. * Switch active camera
  32889. * @param newCamera defines the new active camera
  32890. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32891. */
  32892. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32893. /**
  32894. * sets the active camera of the scene using its ID
  32895. * @param id defines the camera's ID
  32896. * @return the new active camera or null if none found.
  32897. */
  32898. setActiveCameraByID(id: string): Nullable<Camera>;
  32899. /**
  32900. * sets the active camera of the scene using its name
  32901. * @param name defines the camera's name
  32902. * @returns the new active camera or null if none found.
  32903. */
  32904. setActiveCameraByName(name: string): Nullable<Camera>;
  32905. /**
  32906. * get an animation group using its name
  32907. * @param name defines the material's name
  32908. * @return the animation group or null if none found.
  32909. */
  32910. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32911. /**
  32912. * get a material using its id
  32913. * @param id defines the material's ID
  32914. * @return the material or null if none found.
  32915. */
  32916. getMaterialByID(id: string): Nullable<Material>;
  32917. /**
  32918. * Gets a material using its name
  32919. * @param name defines the material's name
  32920. * @return the material or null if none found.
  32921. */
  32922. getMaterialByName(name: string): Nullable<Material>;
  32923. /**
  32924. * Gets a camera using its id
  32925. * @param id defines the id to look for
  32926. * @returns the camera or null if not found
  32927. */
  32928. getCameraByID(id: string): Nullable<Camera>;
  32929. /**
  32930. * Gets a camera using its unique id
  32931. * @param uniqueId defines the unique id to look for
  32932. * @returns the camera or null if not found
  32933. */
  32934. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32935. /**
  32936. * Gets a camera using its name
  32937. * @param name defines the camera's name
  32938. * @return the camera or null if none found.
  32939. */
  32940. getCameraByName(name: string): Nullable<Camera>;
  32941. /**
  32942. * Gets a bone using its id
  32943. * @param id defines the bone's id
  32944. * @return the bone or null if not found
  32945. */
  32946. getBoneByID(id: string): Nullable<Bone>;
  32947. /**
  32948. * Gets a bone using its id
  32949. * @param name defines the bone's name
  32950. * @return the bone or null if not found
  32951. */
  32952. getBoneByName(name: string): Nullable<Bone>;
  32953. /**
  32954. * Gets a light node using its name
  32955. * @param name defines the the light's name
  32956. * @return the light or null if none found.
  32957. */
  32958. getLightByName(name: string): Nullable<Light>;
  32959. /**
  32960. * Gets a light node using its id
  32961. * @param id defines the light's id
  32962. * @return the light or null if none found.
  32963. */
  32964. getLightByID(id: string): Nullable<Light>;
  32965. /**
  32966. * Gets a light node using its scene-generated unique ID
  32967. * @param uniqueId defines the light's unique id
  32968. * @return the light or null if none found.
  32969. */
  32970. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32971. /**
  32972. * Gets a particle system by id
  32973. * @param id defines the particle system id
  32974. * @return the corresponding system or null if none found
  32975. */
  32976. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32977. /**
  32978. * Gets a geometry using its ID
  32979. * @param id defines the geometry's id
  32980. * @return the geometry or null if none found.
  32981. */
  32982. getGeometryByID(id: string): Nullable<Geometry>;
  32983. private _getGeometryByUniqueID;
  32984. /**
  32985. * Add a new geometry to this scene
  32986. * @param geometry defines the geometry to be added to the scene.
  32987. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32988. * @return a boolean defining if the geometry was added or not
  32989. */
  32990. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32991. /**
  32992. * Removes an existing geometry
  32993. * @param geometry defines the geometry to be removed from the scene
  32994. * @return a boolean defining if the geometry was removed or not
  32995. */
  32996. removeGeometry(geometry: Geometry): boolean;
  32997. /**
  32998. * Gets the list of geometries attached to the scene
  32999. * @returns an array of Geometry
  33000. */
  33001. getGeometries(): Geometry[];
  33002. /**
  33003. * Gets the first added mesh found of a given ID
  33004. * @param id defines the id to search for
  33005. * @return the mesh found or null if not found at all
  33006. */
  33007. getMeshByID(id: string): Nullable<AbstractMesh>;
  33008. /**
  33009. * Gets a list of meshes using their id
  33010. * @param id defines the id to search for
  33011. * @returns a list of meshes
  33012. */
  33013. getMeshesByID(id: string): Array<AbstractMesh>;
  33014. /**
  33015. * Gets the first added transform node found of a given ID
  33016. * @param id defines the id to search for
  33017. * @return the found transform node or null if not found at all.
  33018. */
  33019. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33020. /**
  33021. * Gets a list of transform nodes using their id
  33022. * @param id defines the id to search for
  33023. * @returns a list of transform nodes
  33024. */
  33025. getTransformNodesByID(id: string): Array<TransformNode>;
  33026. /**
  33027. * Gets a mesh with its auto-generated unique id
  33028. * @param uniqueId defines the unique id to search for
  33029. * @return the found mesh or null if not found at all.
  33030. */
  33031. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33032. /**
  33033. * Gets a the last added mesh using a given id
  33034. * @param id defines the id to search for
  33035. * @return the found mesh or null if not found at all.
  33036. */
  33037. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33038. /**
  33039. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33040. * @param id defines the id to search for
  33041. * @return the found node or null if not found at all
  33042. */
  33043. getLastEntryByID(id: string): Nullable<Node>;
  33044. /**
  33045. * Gets a node (Mesh, Camera, Light) using a given id
  33046. * @param id defines the id to search for
  33047. * @return the found node or null if not found at all
  33048. */
  33049. getNodeByID(id: string): Nullable<Node>;
  33050. /**
  33051. * Gets a node (Mesh, Camera, Light) using a given name
  33052. * @param name defines the name to search for
  33053. * @return the found node or null if not found at all.
  33054. */
  33055. getNodeByName(name: string): Nullable<Node>;
  33056. /**
  33057. * Gets a mesh using a given name
  33058. * @param name defines the name to search for
  33059. * @return the found mesh or null if not found at all.
  33060. */
  33061. getMeshByName(name: string): Nullable<AbstractMesh>;
  33062. /**
  33063. * Gets a transform node using a given name
  33064. * @param name defines the name to search for
  33065. * @return the found transform node or null if not found at all.
  33066. */
  33067. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33068. /**
  33069. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33070. * @param id defines the id to search for
  33071. * @return the found skeleton or null if not found at all.
  33072. */
  33073. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33074. /**
  33075. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33076. * @param id defines the id to search for
  33077. * @return the found skeleton or null if not found at all.
  33078. */
  33079. getSkeletonById(id: string): Nullable<Skeleton>;
  33080. /**
  33081. * Gets a skeleton using a given name
  33082. * @param name defines the name to search for
  33083. * @return the found skeleton or null if not found at all.
  33084. */
  33085. getSkeletonByName(name: string): Nullable<Skeleton>;
  33086. /**
  33087. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33088. * @param id defines the id to search for
  33089. * @return the found morph target manager or null if not found at all.
  33090. */
  33091. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33092. /**
  33093. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33094. * @param id defines the id to search for
  33095. * @return the found morph target or null if not found at all.
  33096. */
  33097. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33098. /**
  33099. * Gets a boolean indicating if the given mesh is active
  33100. * @param mesh defines the mesh to look for
  33101. * @returns true if the mesh is in the active list
  33102. */
  33103. isActiveMesh(mesh: AbstractMesh): boolean;
  33104. /**
  33105. * Return a unique id as a string which can serve as an identifier for the scene
  33106. */
  33107. readonly uid: string;
  33108. /**
  33109. * Add an externaly attached data from its key.
  33110. * This method call will fail and return false, if such key already exists.
  33111. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33112. * @param key the unique key that identifies the data
  33113. * @param data the data object to associate to the key for this Engine instance
  33114. * @return true if no such key were already present and the data was added successfully, false otherwise
  33115. */
  33116. addExternalData<T>(key: string, data: T): boolean;
  33117. /**
  33118. * Get an externaly attached data from its key
  33119. * @param key the unique key that identifies the data
  33120. * @return the associated data, if present (can be null), or undefined if not present
  33121. */
  33122. getExternalData<T>(key: string): Nullable<T>;
  33123. /**
  33124. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33125. * @param key the unique key that identifies the data
  33126. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33127. * @return the associated data, can be null if the factory returned null.
  33128. */
  33129. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33130. /**
  33131. * Remove an externaly attached data from the Engine instance
  33132. * @param key the unique key that identifies the data
  33133. * @return true if the data was successfully removed, false if it doesn't exist
  33134. */
  33135. removeExternalData(key: string): boolean;
  33136. private _evaluateSubMesh;
  33137. /**
  33138. * Clear the processed materials smart array preventing retention point in material dispose.
  33139. */
  33140. freeProcessedMaterials(): void;
  33141. private _preventFreeActiveMeshesAndRenderingGroups;
  33142. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33143. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33144. * when disposing several meshes in a row or a hierarchy of meshes.
  33145. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33146. */
  33147. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33148. /**
  33149. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33150. */
  33151. freeActiveMeshes(): void;
  33152. /**
  33153. * Clear the info related to rendering groups preventing retention points during dispose.
  33154. */
  33155. freeRenderingGroups(): void;
  33156. /** @hidden */
  33157. _isInIntermediateRendering(): boolean;
  33158. /**
  33159. * Lambda returning the list of potentially active meshes.
  33160. */
  33161. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33162. /**
  33163. * Lambda returning the list of potentially active sub meshes.
  33164. */
  33165. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33166. /**
  33167. * Lambda returning the list of potentially intersecting sub meshes.
  33168. */
  33169. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33170. /**
  33171. * Lambda returning the list of potentially colliding sub meshes.
  33172. */
  33173. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33174. private _activeMeshesFrozen;
  33175. /**
  33176. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33177. * @returns the current scene
  33178. */
  33179. freezeActiveMeshes(): Scene;
  33180. /**
  33181. * Use this function to restart evaluating active meshes on every frame
  33182. * @returns the current scene
  33183. */
  33184. unfreezeActiveMeshes(): Scene;
  33185. private _evaluateActiveMeshes;
  33186. private _activeMesh;
  33187. /**
  33188. * Update the transform matrix to update from the current active camera
  33189. * @param force defines a boolean used to force the update even if cache is up to date
  33190. */
  33191. updateTransformMatrix(force?: boolean): void;
  33192. /**
  33193. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33194. * @param alternateCamera defines the camera to use
  33195. */
  33196. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33197. /** @hidden */
  33198. _allowPostProcessClearColor: boolean;
  33199. private _renderForCamera;
  33200. private _processSubCameras;
  33201. private _checkIntersections;
  33202. /** @hidden */
  33203. _advancePhysicsEngineStep(step: number): void;
  33204. /**
  33205. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33206. */
  33207. getDeterministicFrameTime: () => number;
  33208. /** @hidden */
  33209. _animate(): void;
  33210. /**
  33211. * Render the scene
  33212. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33213. */
  33214. render(updateCameras?: boolean): void;
  33215. /**
  33216. * Freeze all materials
  33217. * A frozen material will not be updatable but should be faster to render
  33218. */
  33219. freezeMaterials(): void;
  33220. /**
  33221. * Unfreeze all materials
  33222. * A frozen material will not be updatable but should be faster to render
  33223. */
  33224. unfreezeMaterials(): void;
  33225. /**
  33226. * Releases all held ressources
  33227. */
  33228. dispose(): void;
  33229. /**
  33230. * Gets if the scene is already disposed
  33231. */
  33232. readonly isDisposed: boolean;
  33233. /**
  33234. * Call this function to reduce memory footprint of the scene.
  33235. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33236. */
  33237. clearCachedVertexData(): void;
  33238. /**
  33239. * This function will remove the local cached buffer data from texture.
  33240. * It will save memory but will prevent the texture from being rebuilt
  33241. */
  33242. cleanCachedTextureBuffer(): void;
  33243. /**
  33244. * Get the world extend vectors with an optional filter
  33245. *
  33246. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33247. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33248. */
  33249. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33250. min: Vector3;
  33251. max: Vector3;
  33252. };
  33253. /**
  33254. * Creates a ray that can be used to pick in the scene
  33255. * @param x defines the x coordinate of the origin (on-screen)
  33256. * @param y defines the y coordinate of the origin (on-screen)
  33257. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33258. * @param camera defines the camera to use for the picking
  33259. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33260. * @returns a Ray
  33261. */
  33262. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33263. /**
  33264. * Creates a ray that can be used to pick in the scene
  33265. * @param x defines the x coordinate of the origin (on-screen)
  33266. * @param y defines the y coordinate of the origin (on-screen)
  33267. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33268. * @param result defines the ray where to store the picking ray
  33269. * @param camera defines the camera to use for the picking
  33270. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33271. * @returns the current scene
  33272. */
  33273. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33274. /**
  33275. * Creates a ray that can be used to pick in the scene
  33276. * @param x defines the x coordinate of the origin (on-screen)
  33277. * @param y defines the y coordinate of the origin (on-screen)
  33278. * @param camera defines the camera to use for the picking
  33279. * @returns a Ray
  33280. */
  33281. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33282. /**
  33283. * Creates a ray that can be used to pick in the scene
  33284. * @param x defines the x coordinate of the origin (on-screen)
  33285. * @param y defines the y coordinate of the origin (on-screen)
  33286. * @param result defines the ray where to store the picking ray
  33287. * @param camera defines the camera to use for the picking
  33288. * @returns the current scene
  33289. */
  33290. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33291. /** Launch a ray to try to pick a mesh in the scene
  33292. * @param x position on screen
  33293. * @param y position on screen
  33294. * @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
  33295. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33296. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33297. * @returns a PickingInfo
  33298. */
  33299. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33300. /** Use the given ray to pick a mesh in the scene
  33301. * @param ray The ray to use to pick meshes
  33302. * @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
  33303. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33304. * @returns a PickingInfo
  33305. */
  33306. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33307. /**
  33308. * Launch a ray to try to pick a mesh in the scene
  33309. * @param x X position on screen
  33310. * @param y Y position on screen
  33311. * @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
  33312. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33313. * @returns an array of PickingInfo
  33314. */
  33315. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33316. /**
  33317. * Launch a ray to try to pick a mesh in the scene
  33318. * @param ray Ray to use
  33319. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33320. * @returns an array of PickingInfo
  33321. */
  33322. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33323. /**
  33324. * Force the value of meshUnderPointer
  33325. * @param mesh defines the mesh to use
  33326. */
  33327. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33328. /**
  33329. * Gets the mesh under the pointer
  33330. * @returns a Mesh or null if no mesh is under the pointer
  33331. */
  33332. getPointerOverMesh(): Nullable<AbstractMesh>;
  33333. /** @hidden */
  33334. _rebuildGeometries(): void;
  33335. /** @hidden */
  33336. _rebuildTextures(): void;
  33337. private _getByTags;
  33338. /**
  33339. * Get a list of meshes by tags
  33340. * @param tagsQuery defines the tags query to use
  33341. * @param forEach defines a predicate used to filter results
  33342. * @returns an array of Mesh
  33343. */
  33344. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33345. /**
  33346. * Get a list of cameras by tags
  33347. * @param tagsQuery defines the tags query to use
  33348. * @param forEach defines a predicate used to filter results
  33349. * @returns an array of Camera
  33350. */
  33351. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33352. /**
  33353. * Get a list of lights by tags
  33354. * @param tagsQuery defines the tags query to use
  33355. * @param forEach defines a predicate used to filter results
  33356. * @returns an array of Light
  33357. */
  33358. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33359. /**
  33360. * Get a list of materials by tags
  33361. * @param tagsQuery defines the tags query to use
  33362. * @param forEach defines a predicate used to filter results
  33363. * @returns an array of Material
  33364. */
  33365. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33366. /**
  33367. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33368. * This allowed control for front to back rendering or reversly depending of the special needs.
  33369. *
  33370. * @param renderingGroupId The rendering group id corresponding to its index
  33371. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33372. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33373. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33374. */
  33375. 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;
  33376. /**
  33377. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33378. *
  33379. * @param renderingGroupId The rendering group id corresponding to its index
  33380. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33381. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33382. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33383. */
  33384. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33385. /**
  33386. * Gets the current auto clear configuration for one rendering group of the rendering
  33387. * manager.
  33388. * @param index the rendering group index to get the information for
  33389. * @returns The auto clear setup for the requested rendering group
  33390. */
  33391. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33392. private _blockMaterialDirtyMechanism;
  33393. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33394. blockMaterialDirtyMechanism: boolean;
  33395. /**
  33396. * Will flag all materials as dirty to trigger new shader compilation
  33397. * @param flag defines the flag used to specify which material part must be marked as dirty
  33398. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33399. */
  33400. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33401. /** @hidden */
  33402. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33403. /** @hidden */
  33404. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33405. }
  33406. }
  33407. declare module "babylonjs/assetContainer" {
  33408. import { AbstractScene } from "babylonjs/abstractScene";
  33409. import { Scene } from "babylonjs/scene";
  33410. import { Mesh } from "babylonjs/Meshes/mesh";
  33411. /**
  33412. * Set of assets to keep when moving a scene into an asset container.
  33413. */
  33414. export class KeepAssets extends AbstractScene {
  33415. }
  33416. /**
  33417. * Container with a set of assets that can be added or removed from a scene.
  33418. */
  33419. export class AssetContainer extends AbstractScene {
  33420. /**
  33421. * The scene the AssetContainer belongs to.
  33422. */
  33423. scene: Scene;
  33424. /**
  33425. * Instantiates an AssetContainer.
  33426. * @param scene The scene the AssetContainer belongs to.
  33427. */
  33428. constructor(scene: Scene);
  33429. /**
  33430. * Adds all the assets from the container to the scene.
  33431. */
  33432. addAllToScene(): void;
  33433. /**
  33434. * Removes all the assets in the container from the scene
  33435. */
  33436. removeAllFromScene(): void;
  33437. /**
  33438. * Disposes all the assets in the container
  33439. */
  33440. dispose(): void;
  33441. private _moveAssets;
  33442. /**
  33443. * Removes all the assets contained in the scene and adds them to the container.
  33444. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33445. */
  33446. moveAllFromScene(keepAssets?: KeepAssets): void;
  33447. /**
  33448. * 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.
  33449. * @returns the root mesh
  33450. */
  33451. createRootMesh(): Mesh;
  33452. }
  33453. }
  33454. declare module "babylonjs/abstractScene" {
  33455. import { Scene } from "babylonjs/scene";
  33456. import { Nullable } from "babylonjs/types";
  33457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33459. import { Geometry } from "babylonjs/Meshes/geometry";
  33460. import { Skeleton } from "babylonjs/Bones/skeleton";
  33461. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33462. import { AssetContainer } from "babylonjs/assetContainer";
  33463. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33464. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33466. import { Material } from "babylonjs/Materials/material";
  33467. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33468. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33469. import { Camera } from "babylonjs/Cameras/camera";
  33470. import { Light } from "babylonjs/Lights/light";
  33471. import { Node } from "babylonjs/node";
  33472. import { Animation } from "babylonjs/Animations/animation";
  33473. /**
  33474. * Defines how the parser contract is defined.
  33475. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33476. */
  33477. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33478. /**
  33479. * Defines how the individual parser contract is defined.
  33480. * These parser can parse an individual asset
  33481. */
  33482. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33483. /**
  33484. * Base class of the scene acting as a container for the different elements composing a scene.
  33485. * This class is dynamically extended by the different components of the scene increasing
  33486. * flexibility and reducing coupling
  33487. */
  33488. export abstract class AbstractScene {
  33489. /**
  33490. * Stores the list of available parsers in the application.
  33491. */
  33492. private static _BabylonFileParsers;
  33493. /**
  33494. * Stores the list of available individual parsers in the application.
  33495. */
  33496. private static _IndividualBabylonFileParsers;
  33497. /**
  33498. * Adds a parser in the list of available ones
  33499. * @param name Defines the name of the parser
  33500. * @param parser Defines the parser to add
  33501. */
  33502. static AddParser(name: string, parser: BabylonFileParser): void;
  33503. /**
  33504. * Gets a general parser from the list of avaialble ones
  33505. * @param name Defines the name of the parser
  33506. * @returns the requested parser or null
  33507. */
  33508. static GetParser(name: string): Nullable<BabylonFileParser>;
  33509. /**
  33510. * Adds n individual parser in the list of available ones
  33511. * @param name Defines the name of the parser
  33512. * @param parser Defines the parser to add
  33513. */
  33514. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33515. /**
  33516. * Gets an individual parser from the list of avaialble ones
  33517. * @param name Defines the name of the parser
  33518. * @returns the requested parser or null
  33519. */
  33520. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33521. /**
  33522. * Parser json data and populate both a scene and its associated container object
  33523. * @param jsonData Defines the data to parse
  33524. * @param scene Defines the scene to parse the data for
  33525. * @param container Defines the container attached to the parsing sequence
  33526. * @param rootUrl Defines the root url of the data
  33527. */
  33528. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33529. /**
  33530. * Gets the list of root nodes (ie. nodes with no parent)
  33531. */
  33532. rootNodes: Node[];
  33533. /** All of the cameras added to this scene
  33534. * @see http://doc.babylonjs.com/babylon101/cameras
  33535. */
  33536. cameras: Camera[];
  33537. /**
  33538. * All of the lights added to this scene
  33539. * @see http://doc.babylonjs.com/babylon101/lights
  33540. */
  33541. lights: Light[];
  33542. /**
  33543. * All of the (abstract) meshes added to this scene
  33544. */
  33545. meshes: AbstractMesh[];
  33546. /**
  33547. * The list of skeletons added to the scene
  33548. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33549. */
  33550. skeletons: Skeleton[];
  33551. /**
  33552. * All of the particle systems added to this scene
  33553. * @see http://doc.babylonjs.com/babylon101/particles
  33554. */
  33555. particleSystems: IParticleSystem[];
  33556. /**
  33557. * Gets a list of Animations associated with the scene
  33558. */
  33559. animations: Animation[];
  33560. /**
  33561. * All of the animation groups added to this scene
  33562. * @see http://doc.babylonjs.com/how_to/group
  33563. */
  33564. animationGroups: AnimationGroup[];
  33565. /**
  33566. * All of the multi-materials added to this scene
  33567. * @see http://doc.babylonjs.com/how_to/multi_materials
  33568. */
  33569. multiMaterials: MultiMaterial[];
  33570. /**
  33571. * All of the materials added to this scene
  33572. * In the context of a Scene, it is not supposed to be modified manually.
  33573. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33574. * Note also that the order of the Material wihin the array is not significant and might change.
  33575. * @see http://doc.babylonjs.com/babylon101/materials
  33576. */
  33577. materials: Material[];
  33578. /**
  33579. * The list of morph target managers added to the scene
  33580. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33581. */
  33582. morphTargetManagers: MorphTargetManager[];
  33583. /**
  33584. * The list of geometries used in the scene.
  33585. */
  33586. geometries: Geometry[];
  33587. /**
  33588. * All of the tranform nodes added to this scene
  33589. * In the context of a Scene, it is not supposed to be modified manually.
  33590. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33591. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33592. * @see http://doc.babylonjs.com/how_to/transformnode
  33593. */
  33594. transformNodes: TransformNode[];
  33595. /**
  33596. * ActionManagers available on the scene.
  33597. */
  33598. actionManagers: AbstractActionManager[];
  33599. /**
  33600. * Textures to keep.
  33601. */
  33602. textures: BaseTexture[];
  33603. }
  33604. }
  33605. declare module "babylonjs/Audio/sound" {
  33606. import { Observable } from "babylonjs/Misc/observable";
  33607. import { Vector3 } from "babylonjs/Maths/math";
  33608. import { Nullable } from "babylonjs/types";
  33609. import { Scene } from "babylonjs/scene";
  33610. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33611. /**
  33612. * Defines a sound that can be played in the application.
  33613. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33615. */
  33616. export class Sound {
  33617. /**
  33618. * The name of the sound in the scene.
  33619. */
  33620. name: string;
  33621. /**
  33622. * Does the sound autoplay once loaded.
  33623. */
  33624. autoplay: boolean;
  33625. /**
  33626. * Does the sound loop after it finishes playing once.
  33627. */
  33628. loop: boolean;
  33629. /**
  33630. * Does the sound use a custom attenuation curve to simulate the falloff
  33631. * happening when the source gets further away from the camera.
  33632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33633. */
  33634. useCustomAttenuation: boolean;
  33635. /**
  33636. * The sound track id this sound belongs to.
  33637. */
  33638. soundTrackId: number;
  33639. /**
  33640. * Is this sound currently played.
  33641. */
  33642. isPlaying: boolean;
  33643. /**
  33644. * Is this sound currently paused.
  33645. */
  33646. isPaused: boolean;
  33647. /**
  33648. * Does this sound enables spatial sound.
  33649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33650. */
  33651. spatialSound: boolean;
  33652. /**
  33653. * Define the reference distance the sound should be heard perfectly.
  33654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33655. */
  33656. refDistance: number;
  33657. /**
  33658. * Define the roll off factor of spatial sounds.
  33659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33660. */
  33661. rolloffFactor: number;
  33662. /**
  33663. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33665. */
  33666. maxDistance: number;
  33667. /**
  33668. * Define the distance attenuation model the sound will follow.
  33669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33670. */
  33671. distanceModel: string;
  33672. /**
  33673. * @hidden
  33674. * Back Compat
  33675. **/
  33676. onended: () => any;
  33677. /**
  33678. * Observable event when the current playing sound finishes.
  33679. */
  33680. onEndedObservable: Observable<Sound>;
  33681. private _panningModel;
  33682. private _playbackRate;
  33683. private _streaming;
  33684. private _startTime;
  33685. private _startOffset;
  33686. private _position;
  33687. /** @hidden */
  33688. _positionInEmitterSpace: boolean;
  33689. private _localDirection;
  33690. private _volume;
  33691. private _isReadyToPlay;
  33692. private _isDirectional;
  33693. private _readyToPlayCallback;
  33694. private _audioBuffer;
  33695. private _soundSource;
  33696. private _streamingSource;
  33697. private _soundPanner;
  33698. private _soundGain;
  33699. private _inputAudioNode;
  33700. private _outputAudioNode;
  33701. private _coneInnerAngle;
  33702. private _coneOuterAngle;
  33703. private _coneOuterGain;
  33704. private _scene;
  33705. private _connectedTransformNode;
  33706. private _customAttenuationFunction;
  33707. private _registerFunc;
  33708. private _isOutputConnected;
  33709. private _htmlAudioElement;
  33710. private _urlType;
  33711. /** @hidden */
  33712. static _SceneComponentInitialization: (scene: Scene) => void;
  33713. /**
  33714. * Create a sound and attach it to a scene
  33715. * @param name Name of your sound
  33716. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33717. * @param scene defines the scene the sound belongs to
  33718. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33719. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33720. */
  33721. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33722. /**
  33723. * Release the sound and its associated resources
  33724. */
  33725. dispose(): void;
  33726. /**
  33727. * Gets if the sounds is ready to be played or not.
  33728. * @returns true if ready, otherwise false
  33729. */
  33730. isReady(): boolean;
  33731. private _soundLoaded;
  33732. /**
  33733. * Sets the data of the sound from an audiobuffer
  33734. * @param audioBuffer The audioBuffer containing the data
  33735. */
  33736. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33737. /**
  33738. * Updates the current sounds options such as maxdistance, loop...
  33739. * @param options A JSON object containing values named as the object properties
  33740. */
  33741. updateOptions(options: any): void;
  33742. private _createSpatialParameters;
  33743. private _updateSpatialParameters;
  33744. /**
  33745. * Switch the panning model to HRTF:
  33746. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33748. */
  33749. switchPanningModelToHRTF(): void;
  33750. /**
  33751. * Switch the panning model to Equal Power:
  33752. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33754. */
  33755. switchPanningModelToEqualPower(): void;
  33756. private _switchPanningModel;
  33757. /**
  33758. * Connect this sound to a sound track audio node like gain...
  33759. * @param soundTrackAudioNode the sound track audio node to connect to
  33760. */
  33761. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33762. /**
  33763. * Transform this sound into a directional source
  33764. * @param coneInnerAngle Size of the inner cone in degree
  33765. * @param coneOuterAngle Size of the outer cone in degree
  33766. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33767. */
  33768. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33769. /**
  33770. * Gets or sets the inner angle for the directional cone.
  33771. */
  33772. /**
  33773. * Gets or sets the inner angle for the directional cone.
  33774. */
  33775. directionalConeInnerAngle: number;
  33776. /**
  33777. * Gets or sets the outer angle for the directional cone.
  33778. */
  33779. /**
  33780. * Gets or sets the outer angle for the directional cone.
  33781. */
  33782. directionalConeOuterAngle: number;
  33783. /**
  33784. * Sets the position of the emitter if spatial sound is enabled
  33785. * @param newPosition Defines the new posisiton
  33786. */
  33787. setPosition(newPosition: Vector3): void;
  33788. /**
  33789. * Sets the local direction of the emitter if spatial sound is enabled
  33790. * @param newLocalDirection Defines the new local direction
  33791. */
  33792. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33793. private _updateDirection;
  33794. /** @hidden */
  33795. updateDistanceFromListener(): void;
  33796. /**
  33797. * Sets a new custom attenuation function for the sound.
  33798. * @param callback Defines the function used for the attenuation
  33799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33800. */
  33801. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33802. /**
  33803. * Play the sound
  33804. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33805. * @param offset (optional) Start the sound setting it at a specific time
  33806. */
  33807. play(time?: number, offset?: number): void;
  33808. private _onended;
  33809. /**
  33810. * Stop the sound
  33811. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33812. */
  33813. stop(time?: number): void;
  33814. /**
  33815. * Put the sound in pause
  33816. */
  33817. pause(): void;
  33818. /**
  33819. * Sets a dedicated volume for this sounds
  33820. * @param newVolume Define the new volume of the sound
  33821. * @param time Define in how long the sound should be at this value
  33822. */
  33823. setVolume(newVolume: number, time?: number): void;
  33824. /**
  33825. * Set the sound play back rate
  33826. * @param newPlaybackRate Define the playback rate the sound should be played at
  33827. */
  33828. setPlaybackRate(newPlaybackRate: number): void;
  33829. /**
  33830. * Gets the volume of the sound.
  33831. * @returns the volume of the sound
  33832. */
  33833. getVolume(): number;
  33834. /**
  33835. * Attach the sound to a dedicated mesh
  33836. * @param transformNode The transform node to connect the sound with
  33837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33838. */
  33839. attachToMesh(transformNode: TransformNode): void;
  33840. /**
  33841. * Detach the sound from the previously attached mesh
  33842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33843. */
  33844. detachFromMesh(): void;
  33845. private _onRegisterAfterWorldMatrixUpdate;
  33846. /**
  33847. * Clone the current sound in the scene.
  33848. * @returns the new sound clone
  33849. */
  33850. clone(): Nullable<Sound>;
  33851. /**
  33852. * Gets the current underlying audio buffer containing the data
  33853. * @returns the audio buffer
  33854. */
  33855. getAudioBuffer(): Nullable<AudioBuffer>;
  33856. /**
  33857. * Serializes the Sound in a JSON representation
  33858. * @returns the JSON representation of the sound
  33859. */
  33860. serialize(): any;
  33861. /**
  33862. * Parse a JSON representation of a sound to innstantiate in a given scene
  33863. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33864. * @param scene Define the scene the new parsed sound should be created in
  33865. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33866. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33867. * @returns the newly parsed sound
  33868. */
  33869. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33870. }
  33871. }
  33872. declare module "babylonjs/Actions/directAudioActions" {
  33873. import { Action } from "babylonjs/Actions/action";
  33874. import { Condition } from "babylonjs/Actions/condition";
  33875. import { Sound } from "babylonjs/Audio/sound";
  33876. /**
  33877. * This defines an action helpful to play a defined sound on a triggered action.
  33878. */
  33879. export class PlaySoundAction extends Action {
  33880. private _sound;
  33881. /**
  33882. * Instantiate the action
  33883. * @param triggerOptions defines the trigger options
  33884. * @param sound defines the sound to play
  33885. * @param condition defines the trigger related conditions
  33886. */
  33887. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33888. /** @hidden */
  33889. _prepare(): void;
  33890. /**
  33891. * Execute the action and play the sound.
  33892. */
  33893. execute(): void;
  33894. /**
  33895. * Serializes the actions and its related information.
  33896. * @param parent defines the object to serialize in
  33897. * @returns the serialized object
  33898. */
  33899. serialize(parent: any): any;
  33900. }
  33901. /**
  33902. * This defines an action helpful to stop a defined sound on a triggered action.
  33903. */
  33904. export class StopSoundAction extends Action {
  33905. private _sound;
  33906. /**
  33907. * Instantiate the action
  33908. * @param triggerOptions defines the trigger options
  33909. * @param sound defines the sound to stop
  33910. * @param condition defines the trigger related conditions
  33911. */
  33912. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33913. /** @hidden */
  33914. _prepare(): void;
  33915. /**
  33916. * Execute the action and stop the sound.
  33917. */
  33918. execute(): void;
  33919. /**
  33920. * Serializes the actions and its related information.
  33921. * @param parent defines the object to serialize in
  33922. * @returns the serialized object
  33923. */
  33924. serialize(parent: any): any;
  33925. }
  33926. }
  33927. declare module "babylonjs/Actions/interpolateValueAction" {
  33928. import { Action } from "babylonjs/Actions/action";
  33929. import { Condition } from "babylonjs/Actions/condition";
  33930. import { Observable } from "babylonjs/Misc/observable";
  33931. /**
  33932. * This defines an action responsible to change the value of a property
  33933. * by interpolating between its current value and the newly set one once triggered.
  33934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33935. */
  33936. export class InterpolateValueAction extends Action {
  33937. /**
  33938. * Defines the path of the property where the value should be interpolated
  33939. */
  33940. propertyPath: string;
  33941. /**
  33942. * Defines the target value at the end of the interpolation.
  33943. */
  33944. value: any;
  33945. /**
  33946. * Defines the time it will take for the property to interpolate to the value.
  33947. */
  33948. duration: number;
  33949. /**
  33950. * Defines if the other scene animations should be stopped when the action has been triggered
  33951. */
  33952. stopOtherAnimations?: boolean;
  33953. /**
  33954. * Defines a callback raised once the interpolation animation has been done.
  33955. */
  33956. onInterpolationDone?: () => void;
  33957. /**
  33958. * Observable triggered once the interpolation animation has been done.
  33959. */
  33960. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33961. private _target;
  33962. private _effectiveTarget;
  33963. private _property;
  33964. /**
  33965. * Instantiate the action
  33966. * @param triggerOptions defines the trigger options
  33967. * @param target defines the object containing the value to interpolate
  33968. * @param propertyPath defines the path to the property in the target object
  33969. * @param value defines the target value at the end of the interpolation
  33970. * @param duration deines the time it will take for the property to interpolate to the value.
  33971. * @param condition defines the trigger related conditions
  33972. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33973. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33974. */
  33975. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33976. /** @hidden */
  33977. _prepare(): void;
  33978. /**
  33979. * Execute the action starts the value interpolation.
  33980. */
  33981. execute(): void;
  33982. /**
  33983. * Serializes the actions and its related information.
  33984. * @param parent defines the object to serialize in
  33985. * @returns the serialized object
  33986. */
  33987. serialize(parent: any): any;
  33988. }
  33989. }
  33990. declare module "babylonjs/Actions/index" {
  33991. export * from "babylonjs/Actions/action";
  33992. export * from "babylonjs/Actions/actionEvent";
  33993. export * from "babylonjs/Actions/actionManager";
  33994. export * from "babylonjs/Actions/condition";
  33995. export * from "babylonjs/Actions/directActions";
  33996. export * from "babylonjs/Actions/directAudioActions";
  33997. export * from "babylonjs/Actions/interpolateValueAction";
  33998. }
  33999. declare module "babylonjs/Animations/index" {
  34000. export * from "babylonjs/Animations/animatable";
  34001. export * from "babylonjs/Animations/animation";
  34002. export * from "babylonjs/Animations/animationGroup";
  34003. export * from "babylonjs/Animations/animationPropertiesOverride";
  34004. export * from "babylonjs/Animations/easing";
  34005. export * from "babylonjs/Animations/runtimeAnimation";
  34006. export * from "babylonjs/Animations/animationEvent";
  34007. export * from "babylonjs/Animations/animationGroup";
  34008. export * from "babylonjs/Animations/animationKey";
  34009. export * from "babylonjs/Animations/animationRange";
  34010. }
  34011. declare module "babylonjs/Audio/soundTrack" {
  34012. import { Sound } from "babylonjs/Audio/sound";
  34013. import { Analyser } from "babylonjs/Audio/analyser";
  34014. import { Scene } from "babylonjs/scene";
  34015. /**
  34016. * Options allowed during the creation of a sound track.
  34017. */
  34018. export interface ISoundTrackOptions {
  34019. /**
  34020. * The volume the sound track should take during creation
  34021. */
  34022. volume?: number;
  34023. /**
  34024. * Define if the sound track is the main sound track of the scene
  34025. */
  34026. mainTrack?: boolean;
  34027. }
  34028. /**
  34029. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34030. * It will be also used in a future release to apply effects on a specific track.
  34031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34032. */
  34033. export class SoundTrack {
  34034. /**
  34035. * The unique identifier of the sound track in the scene.
  34036. */
  34037. id: number;
  34038. /**
  34039. * The list of sounds included in the sound track.
  34040. */
  34041. soundCollection: Array<Sound>;
  34042. private _outputAudioNode;
  34043. private _scene;
  34044. private _isMainTrack;
  34045. private _connectedAnalyser;
  34046. private _options;
  34047. private _isInitialized;
  34048. /**
  34049. * Creates a new sound track.
  34050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34051. * @param scene Define the scene the sound track belongs to
  34052. * @param options
  34053. */
  34054. constructor(scene: Scene, options?: ISoundTrackOptions);
  34055. private _initializeSoundTrackAudioGraph;
  34056. /**
  34057. * Release the sound track and its associated resources
  34058. */
  34059. dispose(): void;
  34060. /**
  34061. * Adds a sound to this sound track
  34062. * @param sound define the cound to add
  34063. * @ignoreNaming
  34064. */
  34065. AddSound(sound: Sound): void;
  34066. /**
  34067. * Removes a sound to this sound track
  34068. * @param sound define the cound to remove
  34069. * @ignoreNaming
  34070. */
  34071. RemoveSound(sound: Sound): void;
  34072. /**
  34073. * Set a global volume for the full sound track.
  34074. * @param newVolume Define the new volume of the sound track
  34075. */
  34076. setVolume(newVolume: number): void;
  34077. /**
  34078. * Switch the panning model to HRTF:
  34079. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34081. */
  34082. switchPanningModelToHRTF(): void;
  34083. /**
  34084. * Switch the panning model to Equal Power:
  34085. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34087. */
  34088. switchPanningModelToEqualPower(): void;
  34089. /**
  34090. * Connect the sound track to an audio analyser allowing some amazing
  34091. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34093. * @param analyser The analyser to connect to the engine
  34094. */
  34095. connectToAnalyser(analyser: Analyser): void;
  34096. }
  34097. }
  34098. declare module "babylonjs/Audio/audioSceneComponent" {
  34099. import { Sound } from "babylonjs/Audio/sound";
  34100. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34101. import { Nullable } from "babylonjs/types";
  34102. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34103. import { Scene } from "babylonjs/scene";
  34104. import { AbstractScene } from "babylonjs/abstractScene";
  34105. module "babylonjs/abstractScene" {
  34106. interface AbstractScene {
  34107. /**
  34108. * The list of sounds used in the scene.
  34109. */
  34110. sounds: Nullable<Array<Sound>>;
  34111. }
  34112. }
  34113. module "babylonjs/scene" {
  34114. interface Scene {
  34115. /**
  34116. * @hidden
  34117. * Backing field
  34118. */
  34119. _mainSoundTrack: SoundTrack;
  34120. /**
  34121. * The main sound track played by the scene.
  34122. * It cotains your primary collection of sounds.
  34123. */
  34124. mainSoundTrack: SoundTrack;
  34125. /**
  34126. * The list of sound tracks added to the scene
  34127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34128. */
  34129. soundTracks: Nullable<Array<SoundTrack>>;
  34130. /**
  34131. * Gets a sound using a given name
  34132. * @param name defines the name to search for
  34133. * @return the found sound or null if not found at all.
  34134. */
  34135. getSoundByName(name: string): Nullable<Sound>;
  34136. /**
  34137. * Gets or sets if audio support is enabled
  34138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34139. */
  34140. audioEnabled: boolean;
  34141. /**
  34142. * Gets or sets if audio will be output to headphones
  34143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34144. */
  34145. headphone: boolean;
  34146. }
  34147. }
  34148. /**
  34149. * Defines the sound scene component responsible to manage any sounds
  34150. * in a given scene.
  34151. */
  34152. export class AudioSceneComponent implements ISceneSerializableComponent {
  34153. /**
  34154. * The component name helpfull to identify the component in the list of scene components.
  34155. */
  34156. readonly name: string;
  34157. /**
  34158. * The scene the component belongs to.
  34159. */
  34160. scene: Scene;
  34161. private _audioEnabled;
  34162. /**
  34163. * Gets whether audio is enabled or not.
  34164. * Please use related enable/disable method to switch state.
  34165. */
  34166. readonly audioEnabled: boolean;
  34167. private _headphone;
  34168. /**
  34169. * Gets whether audio is outputing to headphone or not.
  34170. * Please use the according Switch methods to change output.
  34171. */
  34172. readonly headphone: boolean;
  34173. /**
  34174. * Creates a new instance of the component for the given scene
  34175. * @param scene Defines the scene to register the component in
  34176. */
  34177. constructor(scene: Scene);
  34178. /**
  34179. * Registers the component in a given scene
  34180. */
  34181. register(): void;
  34182. /**
  34183. * Rebuilds the elements related to this component in case of
  34184. * context lost for instance.
  34185. */
  34186. rebuild(): void;
  34187. /**
  34188. * Serializes the component data to the specified json object
  34189. * @param serializationObject The object to serialize to
  34190. */
  34191. serialize(serializationObject: any): void;
  34192. /**
  34193. * Adds all the element from the container to the scene
  34194. * @param container the container holding the elements
  34195. */
  34196. addFromContainer(container: AbstractScene): void;
  34197. /**
  34198. * Removes all the elements in the container from the scene
  34199. * @param container contains the elements to remove
  34200. */
  34201. removeFromContainer(container: AbstractScene): void;
  34202. /**
  34203. * Disposes the component and the associated ressources.
  34204. */
  34205. dispose(): void;
  34206. /**
  34207. * Disables audio in the associated scene.
  34208. */
  34209. disableAudio(): void;
  34210. /**
  34211. * Enables audio in the associated scene.
  34212. */
  34213. enableAudio(): void;
  34214. /**
  34215. * Switch audio to headphone output.
  34216. */
  34217. switchAudioModeForHeadphones(): void;
  34218. /**
  34219. * Switch audio to normal speakers.
  34220. */
  34221. switchAudioModeForNormalSpeakers(): void;
  34222. private _afterRender;
  34223. }
  34224. }
  34225. declare module "babylonjs/Audio/weightedsound" {
  34226. import { Sound } from "babylonjs/Audio/sound";
  34227. /**
  34228. * Wraps one or more Sound objects and selects one with random weight for playback.
  34229. */
  34230. export class WeightedSound {
  34231. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34232. loop: boolean;
  34233. private _coneInnerAngle;
  34234. private _coneOuterAngle;
  34235. private _volume;
  34236. /** A Sound is currently playing. */
  34237. isPlaying: boolean;
  34238. /** A Sound is currently paused. */
  34239. isPaused: boolean;
  34240. private _sounds;
  34241. private _weights;
  34242. private _currentIndex?;
  34243. /**
  34244. * Creates a new WeightedSound from the list of sounds given.
  34245. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34246. * @param sounds Array of Sounds that will be selected from.
  34247. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34248. */
  34249. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34250. /**
  34251. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34252. */
  34253. /**
  34254. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34255. */
  34256. directionalConeInnerAngle: number;
  34257. /**
  34258. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34259. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34260. */
  34261. /**
  34262. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34263. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34264. */
  34265. directionalConeOuterAngle: number;
  34266. /**
  34267. * Playback volume.
  34268. */
  34269. /**
  34270. * Playback volume.
  34271. */
  34272. volume: number;
  34273. private _onended;
  34274. /**
  34275. * Suspend playback
  34276. */
  34277. pause(): void;
  34278. /**
  34279. * Stop playback
  34280. */
  34281. stop(): void;
  34282. /**
  34283. * Start playback.
  34284. * @param startOffset Position the clip head at a specific time in seconds.
  34285. */
  34286. play(startOffset?: number): void;
  34287. }
  34288. }
  34289. declare module "babylonjs/Audio/index" {
  34290. export * from "babylonjs/Audio/analyser";
  34291. export * from "babylonjs/Audio/audioEngine";
  34292. export * from "babylonjs/Audio/audioSceneComponent";
  34293. export * from "babylonjs/Audio/sound";
  34294. export * from "babylonjs/Audio/soundTrack";
  34295. export * from "babylonjs/Audio/weightedsound";
  34296. }
  34297. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34298. import { Behavior } from "babylonjs/Behaviors/behavior";
  34299. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34300. import { BackEase } from "babylonjs/Animations/easing";
  34301. /**
  34302. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34304. */
  34305. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34306. /**
  34307. * Gets the name of the behavior.
  34308. */
  34309. readonly name: string;
  34310. /**
  34311. * The easing function used by animations
  34312. */
  34313. static EasingFunction: BackEase;
  34314. /**
  34315. * The easing mode used by animations
  34316. */
  34317. static EasingMode: number;
  34318. /**
  34319. * The duration of the animation, in milliseconds
  34320. */
  34321. transitionDuration: number;
  34322. /**
  34323. * Length of the distance animated by the transition when lower radius is reached
  34324. */
  34325. lowerRadiusTransitionRange: number;
  34326. /**
  34327. * Length of the distance animated by the transition when upper radius is reached
  34328. */
  34329. upperRadiusTransitionRange: number;
  34330. private _autoTransitionRange;
  34331. /**
  34332. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34333. */
  34334. /**
  34335. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34336. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34337. */
  34338. autoTransitionRange: boolean;
  34339. private _attachedCamera;
  34340. private _onAfterCheckInputsObserver;
  34341. private _onMeshTargetChangedObserver;
  34342. /**
  34343. * Initializes the behavior.
  34344. */
  34345. init(): void;
  34346. /**
  34347. * Attaches the behavior to its arc rotate camera.
  34348. * @param camera Defines the camera to attach the behavior to
  34349. */
  34350. attach(camera: ArcRotateCamera): void;
  34351. /**
  34352. * Detaches the behavior from its current arc rotate camera.
  34353. */
  34354. detach(): void;
  34355. private _radiusIsAnimating;
  34356. private _radiusBounceTransition;
  34357. private _animatables;
  34358. private _cachedWheelPrecision;
  34359. /**
  34360. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34361. * @param radiusLimit The limit to check against.
  34362. * @return Bool to indicate if at limit.
  34363. */
  34364. private _isRadiusAtLimit;
  34365. /**
  34366. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34367. * @param radiusDelta The delta by which to animate to. Can be negative.
  34368. */
  34369. private _applyBoundRadiusAnimation;
  34370. /**
  34371. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34372. */
  34373. protected _clearAnimationLocks(): void;
  34374. /**
  34375. * Stops and removes all animations that have been applied to the camera
  34376. */
  34377. stopAllAnimations(): void;
  34378. }
  34379. }
  34380. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34381. import { Behavior } from "babylonjs/Behaviors/behavior";
  34382. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34383. import { ExponentialEase } from "babylonjs/Animations/easing";
  34384. import { Nullable } from "babylonjs/types";
  34385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34386. import { Vector3 } from "babylonjs/Maths/math";
  34387. /**
  34388. * 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.
  34389. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34390. */
  34391. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34392. /**
  34393. * Gets the name of the behavior.
  34394. */
  34395. readonly name: string;
  34396. private _mode;
  34397. private _radiusScale;
  34398. private _positionScale;
  34399. private _defaultElevation;
  34400. private _elevationReturnTime;
  34401. private _elevationReturnWaitTime;
  34402. private _zoomStopsAnimation;
  34403. private _framingTime;
  34404. /**
  34405. * The easing function used by animations
  34406. */
  34407. static EasingFunction: ExponentialEase;
  34408. /**
  34409. * The easing mode used by animations
  34410. */
  34411. static EasingMode: number;
  34412. /**
  34413. * Sets the current mode used by the behavior
  34414. */
  34415. /**
  34416. * Gets current mode used by the behavior.
  34417. */
  34418. mode: number;
  34419. /**
  34420. * Sets the scale applied to the radius (1 by default)
  34421. */
  34422. /**
  34423. * Gets the scale applied to the radius
  34424. */
  34425. radiusScale: number;
  34426. /**
  34427. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34428. */
  34429. /**
  34430. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34431. */
  34432. positionScale: number;
  34433. /**
  34434. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34435. * behaviour is triggered, in radians.
  34436. */
  34437. /**
  34438. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34439. * behaviour is triggered, in radians.
  34440. */
  34441. defaultElevation: number;
  34442. /**
  34443. * Sets the time (in milliseconds) taken to return to the default beta position.
  34444. * Negative value indicates camera should not return to default.
  34445. */
  34446. /**
  34447. * Gets the time (in milliseconds) taken to return to the default beta position.
  34448. * Negative value indicates camera should not return to default.
  34449. */
  34450. elevationReturnTime: number;
  34451. /**
  34452. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34453. */
  34454. /**
  34455. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34456. */
  34457. elevationReturnWaitTime: number;
  34458. /**
  34459. * Sets the flag that indicates if user zooming should stop animation.
  34460. */
  34461. /**
  34462. * Gets the flag that indicates if user zooming should stop animation.
  34463. */
  34464. zoomStopsAnimation: boolean;
  34465. /**
  34466. * Sets the transition time when framing the mesh, in milliseconds
  34467. */
  34468. /**
  34469. * Gets the transition time when framing the mesh, in milliseconds
  34470. */
  34471. framingTime: number;
  34472. /**
  34473. * Define if the behavior should automatically change the configured
  34474. * camera limits and sensibilities.
  34475. */
  34476. autoCorrectCameraLimitsAndSensibility: boolean;
  34477. private _onPrePointerObservableObserver;
  34478. private _onAfterCheckInputsObserver;
  34479. private _onMeshTargetChangedObserver;
  34480. private _attachedCamera;
  34481. private _isPointerDown;
  34482. private _lastInteractionTime;
  34483. /**
  34484. * Initializes the behavior.
  34485. */
  34486. init(): void;
  34487. /**
  34488. * Attaches the behavior to its arc rotate camera.
  34489. * @param camera Defines the camera to attach the behavior to
  34490. */
  34491. attach(camera: ArcRotateCamera): void;
  34492. /**
  34493. * Detaches the behavior from its current arc rotate camera.
  34494. */
  34495. detach(): void;
  34496. private _animatables;
  34497. private _betaIsAnimating;
  34498. private _betaTransition;
  34499. private _radiusTransition;
  34500. private _vectorTransition;
  34501. /**
  34502. * Targets the given mesh and updates zoom level accordingly.
  34503. * @param mesh The mesh to target.
  34504. * @param radius Optional. If a cached radius position already exists, overrides default.
  34505. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34506. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34507. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34508. */
  34509. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34510. /**
  34511. * Targets the given mesh with its children and updates zoom level accordingly.
  34512. * @param mesh The mesh to target.
  34513. * @param radius Optional. If a cached radius position already exists, overrides default.
  34514. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34517. */
  34518. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34519. /**
  34520. * Targets the given meshes with their children and updates zoom level accordingly.
  34521. * @param meshes The mesh to target.
  34522. * @param radius Optional. If a cached radius position already exists, overrides default.
  34523. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34524. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34525. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34526. */
  34527. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34528. /**
  34529. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34530. * @param minimumWorld Determines the smaller position of the bounding box extend
  34531. * @param maximumWorld Determines the bigger position of the bounding box extend
  34532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34534. */
  34535. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34536. /**
  34537. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34538. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34539. * frustum width.
  34540. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34541. * to fully enclose the mesh in the viewing frustum.
  34542. */
  34543. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34544. /**
  34545. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34546. * is automatically returned to its default position (expected to be above ground plane).
  34547. */
  34548. private _maintainCameraAboveGround;
  34549. /**
  34550. * Returns the frustum slope based on the canvas ratio and camera FOV
  34551. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34552. */
  34553. private _getFrustumSlope;
  34554. /**
  34555. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34556. */
  34557. private _clearAnimationLocks;
  34558. /**
  34559. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34560. */
  34561. private _applyUserInteraction;
  34562. /**
  34563. * Stops and removes all animations that have been applied to the camera
  34564. */
  34565. stopAllAnimations(): void;
  34566. /**
  34567. * Gets a value indicating if the user is moving the camera
  34568. */
  34569. readonly isUserIsMoving: boolean;
  34570. /**
  34571. * The camera can move all the way towards the mesh.
  34572. */
  34573. static IgnoreBoundsSizeMode: number;
  34574. /**
  34575. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34576. */
  34577. static FitFrustumSidesMode: number;
  34578. }
  34579. }
  34580. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34581. import { Nullable } from "babylonjs/types";
  34582. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34583. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34584. /**
  34585. * Manage the pointers inputs to control an arc rotate camera.
  34586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34587. */
  34588. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34589. /**
  34590. * Defines the camera the input is attached to.
  34591. */
  34592. camera: ArcRotateCamera;
  34593. /**
  34594. * Defines the buttons associated with the input to handle camera move.
  34595. */
  34596. buttons: number[];
  34597. /**
  34598. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34599. */
  34600. angularSensibilityX: number;
  34601. /**
  34602. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34603. */
  34604. angularSensibilityY: number;
  34605. /**
  34606. * Defines the pointer pinch precision or how fast is the camera zooming.
  34607. */
  34608. pinchPrecision: number;
  34609. /**
  34610. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34611. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34612. */
  34613. pinchDeltaPercentage: number;
  34614. /**
  34615. * Defines the pointer panning sensibility or how fast is the camera moving.
  34616. */
  34617. panningSensibility: number;
  34618. /**
  34619. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34620. */
  34621. multiTouchPanning: boolean;
  34622. /**
  34623. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34624. */
  34625. multiTouchPanAndZoom: boolean;
  34626. /**
  34627. * Revers pinch action direction.
  34628. */
  34629. pinchInwards: boolean;
  34630. private _isPanClick;
  34631. private _pointerInput;
  34632. private _observer;
  34633. private _onMouseMove;
  34634. private _onGestureStart;
  34635. private _onGesture;
  34636. private _MSGestureHandler;
  34637. private _onLostFocus;
  34638. private _onContextMenu;
  34639. /**
  34640. * Attach the input controls to a specific dom element to get the input from.
  34641. * @param element Defines the element the controls should be listened from
  34642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34643. */
  34644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34645. /**
  34646. * Detach the current controls from the specified dom element.
  34647. * @param element Defines the element to stop listening the inputs from
  34648. */
  34649. detachControl(element: Nullable<HTMLElement>): void;
  34650. /**
  34651. * Gets the class name of the current intput.
  34652. * @returns the class name
  34653. */
  34654. getClassName(): string;
  34655. /**
  34656. * Get the friendly name associated with the input class.
  34657. * @returns the input friendly name
  34658. */
  34659. getSimpleName(): string;
  34660. }
  34661. }
  34662. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34663. import { Nullable } from "babylonjs/types";
  34664. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34666. /**
  34667. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34669. */
  34670. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34671. /**
  34672. * Defines the camera the input is attached to.
  34673. */
  34674. camera: ArcRotateCamera;
  34675. /**
  34676. * Defines the list of key codes associated with the up action (increase alpha)
  34677. */
  34678. keysUp: number[];
  34679. /**
  34680. * Defines the list of key codes associated with the down action (decrease alpha)
  34681. */
  34682. keysDown: number[];
  34683. /**
  34684. * Defines the list of key codes associated with the left action (increase beta)
  34685. */
  34686. keysLeft: number[];
  34687. /**
  34688. * Defines the list of key codes associated with the right action (decrease beta)
  34689. */
  34690. keysRight: number[];
  34691. /**
  34692. * Defines the list of key codes associated with the reset action.
  34693. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34694. */
  34695. keysReset: number[];
  34696. /**
  34697. * Defines the panning sensibility of the inputs.
  34698. * (How fast is the camera paning)
  34699. */
  34700. panningSensibility: number;
  34701. /**
  34702. * Defines the zooming sensibility of the inputs.
  34703. * (How fast is the camera zooming)
  34704. */
  34705. zoomingSensibility: number;
  34706. /**
  34707. * Defines wether maintaining the alt key down switch the movement mode from
  34708. * orientation to zoom.
  34709. */
  34710. useAltToZoom: boolean;
  34711. /**
  34712. * Rotation speed of the camera
  34713. */
  34714. angularSpeed: number;
  34715. private _keys;
  34716. private _ctrlPressed;
  34717. private _altPressed;
  34718. private _onCanvasBlurObserver;
  34719. private _onKeyboardObserver;
  34720. private _engine;
  34721. private _scene;
  34722. /**
  34723. * Attach the input controls to a specific dom element to get the input from.
  34724. * @param element Defines the element the controls should be listened from
  34725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34726. */
  34727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34728. /**
  34729. * Detach the current controls from the specified dom element.
  34730. * @param element Defines the element to stop listening the inputs from
  34731. */
  34732. detachControl(element: Nullable<HTMLElement>): void;
  34733. /**
  34734. * Update the current camera state depending on the inputs that have been used this frame.
  34735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34736. */
  34737. checkInputs(): void;
  34738. /**
  34739. * Gets the class name of the current intput.
  34740. * @returns the class name
  34741. */
  34742. getClassName(): string;
  34743. /**
  34744. * Get the friendly name associated with the input class.
  34745. * @returns the input friendly name
  34746. */
  34747. getSimpleName(): string;
  34748. }
  34749. }
  34750. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34751. import { Nullable } from "babylonjs/types";
  34752. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34754. /**
  34755. * Manage the mouse wheel inputs to control an arc rotate camera.
  34756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34757. */
  34758. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34759. /**
  34760. * Defines the camera the input is attached to.
  34761. */
  34762. camera: ArcRotateCamera;
  34763. /**
  34764. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34765. */
  34766. wheelPrecision: number;
  34767. /**
  34768. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34769. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34770. */
  34771. wheelDeltaPercentage: number;
  34772. private _wheel;
  34773. private _observer;
  34774. /**
  34775. * Attach the input controls to a specific dom element to get the input from.
  34776. * @param element Defines the element the controls should be listened from
  34777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34778. */
  34779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34780. /**
  34781. * Detach the current controls from the specified dom element.
  34782. * @param element Defines the element to stop listening the inputs from
  34783. */
  34784. detachControl(element: Nullable<HTMLElement>): void;
  34785. /**
  34786. * Gets the class name of the current intput.
  34787. * @returns the class name
  34788. */
  34789. getClassName(): string;
  34790. /**
  34791. * Get the friendly name associated with the input class.
  34792. * @returns the input friendly name
  34793. */
  34794. getSimpleName(): string;
  34795. }
  34796. }
  34797. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34798. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34799. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34800. /**
  34801. * Default Inputs manager for the ArcRotateCamera.
  34802. * It groups all the default supported inputs for ease of use.
  34803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34804. */
  34805. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34806. /**
  34807. * Instantiates a new ArcRotateCameraInputsManager.
  34808. * @param camera Defines the camera the inputs belong to
  34809. */
  34810. constructor(camera: ArcRotateCamera);
  34811. /**
  34812. * Add mouse wheel input support to the input manager.
  34813. * @returns the current input manager
  34814. */
  34815. addMouseWheel(): ArcRotateCameraInputsManager;
  34816. /**
  34817. * Add pointers input support to the input manager.
  34818. * @returns the current input manager
  34819. */
  34820. addPointers(): ArcRotateCameraInputsManager;
  34821. /**
  34822. * Add keyboard input support to the input manager.
  34823. * @returns the current input manager
  34824. */
  34825. addKeyboard(): ArcRotateCameraInputsManager;
  34826. }
  34827. }
  34828. declare module "babylonjs/Cameras/arcRotateCamera" {
  34829. import { Observable } from "babylonjs/Misc/observable";
  34830. import { Nullable } from "babylonjs/types";
  34831. import { Scene } from "babylonjs/scene";
  34832. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34834. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34835. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34836. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34837. import { Camera } from "babylonjs/Cameras/camera";
  34838. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34839. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34840. import { Collider } from "babylonjs/Collisions/collider";
  34841. /**
  34842. * This represents an orbital type of camera.
  34843. *
  34844. * 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.
  34845. * 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.
  34846. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34847. */
  34848. export class ArcRotateCamera extends TargetCamera {
  34849. /**
  34850. * Defines the rotation angle of the camera along the longitudinal axis.
  34851. */
  34852. alpha: number;
  34853. /**
  34854. * Defines the rotation angle of the camera along the latitudinal axis.
  34855. */
  34856. beta: number;
  34857. /**
  34858. * Defines the radius of the camera from it s target point.
  34859. */
  34860. radius: number;
  34861. protected _target: Vector3;
  34862. protected _targetHost: Nullable<AbstractMesh>;
  34863. /**
  34864. * Defines the target point of the camera.
  34865. * The camera looks towards it form the radius distance.
  34866. */
  34867. target: Vector3;
  34868. /**
  34869. * Current inertia value on the longitudinal axis.
  34870. * The bigger this number the longer it will take for the camera to stop.
  34871. */
  34872. inertialAlphaOffset: number;
  34873. /**
  34874. * Current inertia value on the latitudinal axis.
  34875. * The bigger this number the longer it will take for the camera to stop.
  34876. */
  34877. inertialBetaOffset: number;
  34878. /**
  34879. * Current inertia value on the radius axis.
  34880. * The bigger this number the longer it will take for the camera to stop.
  34881. */
  34882. inertialRadiusOffset: number;
  34883. /**
  34884. * Minimum allowed angle on the longitudinal axis.
  34885. * This can help limiting how the Camera is able to move in the scene.
  34886. */
  34887. lowerAlphaLimit: Nullable<number>;
  34888. /**
  34889. * Maximum allowed angle on the longitudinal axis.
  34890. * This can help limiting how the Camera is able to move in the scene.
  34891. */
  34892. upperAlphaLimit: Nullable<number>;
  34893. /**
  34894. * Minimum allowed angle on the latitudinal axis.
  34895. * This can help limiting how the Camera is able to move in the scene.
  34896. */
  34897. lowerBetaLimit: number;
  34898. /**
  34899. * Maximum allowed angle on the latitudinal axis.
  34900. * This can help limiting how the Camera is able to move in the scene.
  34901. */
  34902. upperBetaLimit: number;
  34903. /**
  34904. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34905. * This can help limiting how the Camera is able to move in the scene.
  34906. */
  34907. lowerRadiusLimit: Nullable<number>;
  34908. /**
  34909. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34910. * This can help limiting how the Camera is able to move in the scene.
  34911. */
  34912. upperRadiusLimit: Nullable<number>;
  34913. /**
  34914. * Defines the current inertia value used during panning of the camera along the X axis.
  34915. */
  34916. inertialPanningX: number;
  34917. /**
  34918. * Defines the current inertia value used during panning of the camera along the Y axis.
  34919. */
  34920. inertialPanningY: number;
  34921. /**
  34922. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34923. * Basically if your fingers moves away from more than this distance you will be considered
  34924. * in pinch mode.
  34925. */
  34926. pinchToPanMaxDistance: number;
  34927. /**
  34928. * Defines the maximum distance the camera can pan.
  34929. * This could help keeping the cammera always in your scene.
  34930. */
  34931. panningDistanceLimit: Nullable<number>;
  34932. /**
  34933. * Defines the target of the camera before paning.
  34934. */
  34935. panningOriginTarget: Vector3;
  34936. /**
  34937. * Defines the value of the inertia used during panning.
  34938. * 0 would mean stop inertia and one would mean no decelleration at all.
  34939. */
  34940. panningInertia: number;
  34941. /**
  34942. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34943. */
  34944. angularSensibilityX: number;
  34945. /**
  34946. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34947. */
  34948. angularSensibilityY: number;
  34949. /**
  34950. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34951. */
  34952. pinchPrecision: number;
  34953. /**
  34954. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34955. * It will be used instead of pinchDeltaPrecision if different from 0.
  34956. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34957. */
  34958. pinchDeltaPercentage: number;
  34959. /**
  34960. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34961. */
  34962. panningSensibility: number;
  34963. /**
  34964. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34965. */
  34966. keysUp: number[];
  34967. /**
  34968. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34969. */
  34970. keysDown: number[];
  34971. /**
  34972. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34973. */
  34974. keysLeft: number[];
  34975. /**
  34976. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34977. */
  34978. keysRight: number[];
  34979. /**
  34980. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34981. */
  34982. wheelPrecision: number;
  34983. /**
  34984. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34985. * It will be used instead of pinchDeltaPrecision if different from 0.
  34986. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34987. */
  34988. wheelDeltaPercentage: number;
  34989. /**
  34990. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34991. */
  34992. zoomOnFactor: number;
  34993. /**
  34994. * Defines a screen offset for the camera position.
  34995. */
  34996. targetScreenOffset: Vector2;
  34997. /**
  34998. * Allows the camera to be completely reversed.
  34999. * If false the camera can not arrive upside down.
  35000. */
  35001. allowUpsideDown: boolean;
  35002. /**
  35003. * Define if double tap/click is used to restore the previously saved state of the camera.
  35004. */
  35005. useInputToRestoreState: boolean;
  35006. /** @hidden */
  35007. _viewMatrix: Matrix;
  35008. /** @hidden */
  35009. _useCtrlForPanning: boolean;
  35010. /** @hidden */
  35011. _panningMouseButton: number;
  35012. /**
  35013. * Defines the input associated to the camera.
  35014. */
  35015. inputs: ArcRotateCameraInputsManager;
  35016. /** @hidden */
  35017. _reset: () => void;
  35018. /**
  35019. * Defines the allowed panning axis.
  35020. */
  35021. panningAxis: Vector3;
  35022. protected _localDirection: Vector3;
  35023. protected _transformedDirection: Vector3;
  35024. private _bouncingBehavior;
  35025. /**
  35026. * Gets the bouncing behavior of the camera if it has been enabled.
  35027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35028. */
  35029. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35030. /**
  35031. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35032. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35033. */
  35034. useBouncingBehavior: boolean;
  35035. private _framingBehavior;
  35036. /**
  35037. * Gets the framing behavior of the camera if it has been enabled.
  35038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35039. */
  35040. readonly framingBehavior: Nullable<FramingBehavior>;
  35041. /**
  35042. * Defines if the framing behavior of the camera is enabled on the camera.
  35043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35044. */
  35045. useFramingBehavior: boolean;
  35046. private _autoRotationBehavior;
  35047. /**
  35048. * Gets the auto rotation behavior of the camera if it has been enabled.
  35049. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35050. */
  35051. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35052. /**
  35053. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35054. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35055. */
  35056. useAutoRotationBehavior: boolean;
  35057. /**
  35058. * Observable triggered when the mesh target has been changed on the camera.
  35059. */
  35060. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35061. /**
  35062. * Event raised when the camera is colliding with a mesh.
  35063. */
  35064. onCollide: (collidedMesh: AbstractMesh) => void;
  35065. /**
  35066. * Defines whether the camera should check collision with the objects oh the scene.
  35067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35068. */
  35069. checkCollisions: boolean;
  35070. /**
  35071. * Defines the collision radius of the camera.
  35072. * This simulates a sphere around the camera.
  35073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35074. */
  35075. collisionRadius: Vector3;
  35076. protected _collider: Collider;
  35077. protected _previousPosition: Vector3;
  35078. protected _collisionVelocity: Vector3;
  35079. protected _newPosition: Vector3;
  35080. protected _previousAlpha: number;
  35081. protected _previousBeta: number;
  35082. protected _previousRadius: number;
  35083. protected _collisionTriggered: boolean;
  35084. protected _targetBoundingCenter: Nullable<Vector3>;
  35085. private _computationVector;
  35086. private _tempAxisVector;
  35087. private _tempAxisRotationMatrix;
  35088. /**
  35089. * Instantiates a new ArcRotateCamera in a given scene
  35090. * @param name Defines the name of the camera
  35091. * @param alpha Defines the camera rotation along the logitudinal axis
  35092. * @param beta Defines the camera rotation along the latitudinal axis
  35093. * @param radius Defines the camera distance from its target
  35094. * @param target Defines the camera target
  35095. * @param scene Defines the scene the camera belongs to
  35096. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35097. */
  35098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35099. /** @hidden */
  35100. _initCache(): void;
  35101. /** @hidden */
  35102. _updateCache(ignoreParentClass?: boolean): void;
  35103. protected _getTargetPosition(): Vector3;
  35104. private _storedAlpha;
  35105. private _storedBeta;
  35106. private _storedRadius;
  35107. private _storedTarget;
  35108. /**
  35109. * Stores the current state of the camera (alpha, beta, radius and target)
  35110. * @returns the camera itself
  35111. */
  35112. storeState(): Camera;
  35113. /**
  35114. * @hidden
  35115. * Restored camera state. You must call storeState() first
  35116. */
  35117. _restoreStateValues(): boolean;
  35118. /** @hidden */
  35119. _isSynchronizedViewMatrix(): boolean;
  35120. /**
  35121. * Attached controls to the current camera.
  35122. * @param element Defines the element the controls should be listened from
  35123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35124. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35125. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35126. */
  35127. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35128. /**
  35129. * Detach the current controls from the camera.
  35130. * The camera will stop reacting to inputs.
  35131. * @param element Defines the element to stop listening the inputs from
  35132. */
  35133. detachControl(element: HTMLElement): void;
  35134. /** @hidden */
  35135. _checkInputs(): void;
  35136. protected _checkLimits(): void;
  35137. /**
  35138. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35139. */
  35140. rebuildAnglesAndRadius(): void;
  35141. /**
  35142. * Use a position to define the current camera related information like aplha, beta and radius
  35143. * @param position Defines the position to set the camera at
  35144. */
  35145. setPosition(position: Vector3): void;
  35146. /**
  35147. * Defines the target the camera should look at.
  35148. * This will automatically adapt alpha beta and radius to fit within the new target.
  35149. * @param target Defines the new target as a Vector or a mesh
  35150. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35151. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35152. */
  35153. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35154. /** @hidden */
  35155. _getViewMatrix(): Matrix;
  35156. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35157. /**
  35158. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35159. * @param meshes Defines the mesh to zoom on
  35160. * @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)
  35161. */
  35162. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35163. /**
  35164. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35165. * The target will be changed but the radius
  35166. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35167. * @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)
  35168. */
  35169. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35170. min: Vector3;
  35171. max: Vector3;
  35172. distance: number;
  35173. }, doNotUpdateMaxZ?: boolean): void;
  35174. /**
  35175. * @override
  35176. * Override Camera.createRigCamera
  35177. */
  35178. createRigCamera(name: string, cameraIndex: number): Camera;
  35179. /**
  35180. * @hidden
  35181. * @override
  35182. * Override Camera._updateRigCameras
  35183. */
  35184. _updateRigCameras(): void;
  35185. /**
  35186. * Destroy the camera and release the current resources hold by it.
  35187. */
  35188. dispose(): void;
  35189. /**
  35190. * Gets the current object class name.
  35191. * @return the class name
  35192. */
  35193. getClassName(): string;
  35194. }
  35195. }
  35196. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35197. import { Behavior } from "babylonjs/Behaviors/behavior";
  35198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35199. /**
  35200. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35201. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35202. */
  35203. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35204. /**
  35205. * Gets the name of the behavior.
  35206. */
  35207. readonly name: string;
  35208. private _zoomStopsAnimation;
  35209. private _idleRotationSpeed;
  35210. private _idleRotationWaitTime;
  35211. private _idleRotationSpinupTime;
  35212. /**
  35213. * Sets the flag that indicates if user zooming should stop animation.
  35214. */
  35215. /**
  35216. * Gets the flag that indicates if user zooming should stop animation.
  35217. */
  35218. zoomStopsAnimation: boolean;
  35219. /**
  35220. * Sets the default speed at which the camera rotates around the model.
  35221. */
  35222. /**
  35223. * Gets the default speed at which the camera rotates around the model.
  35224. */
  35225. idleRotationSpeed: number;
  35226. /**
  35227. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35228. */
  35229. /**
  35230. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35231. */
  35232. idleRotationWaitTime: number;
  35233. /**
  35234. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35235. */
  35236. /**
  35237. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35238. */
  35239. idleRotationSpinupTime: number;
  35240. /**
  35241. * Gets a value indicating if the camera is currently rotating because of this behavior
  35242. */
  35243. readonly rotationInProgress: boolean;
  35244. private _onPrePointerObservableObserver;
  35245. private _onAfterCheckInputsObserver;
  35246. private _attachedCamera;
  35247. private _isPointerDown;
  35248. private _lastFrameTime;
  35249. private _lastInteractionTime;
  35250. private _cameraRotationSpeed;
  35251. /**
  35252. * Initializes the behavior.
  35253. */
  35254. init(): void;
  35255. /**
  35256. * Attaches the behavior to its arc rotate camera.
  35257. * @param camera Defines the camera to attach the behavior to
  35258. */
  35259. attach(camera: ArcRotateCamera): void;
  35260. /**
  35261. * Detaches the behavior from its current arc rotate camera.
  35262. */
  35263. detach(): void;
  35264. /**
  35265. * Returns true if user is scrolling.
  35266. * @return true if user is scrolling.
  35267. */
  35268. private _userIsZooming;
  35269. private _lastFrameRadius;
  35270. private _shouldAnimationStopForInteraction;
  35271. /**
  35272. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35273. */
  35274. private _applyUserInteraction;
  35275. private _userIsMoving;
  35276. }
  35277. }
  35278. declare module "babylonjs/Behaviors/Cameras/index" {
  35279. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35280. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35281. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35282. }
  35283. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35284. import { Mesh } from "babylonjs/Meshes/mesh";
  35285. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35286. import { Behavior } from "babylonjs/Behaviors/behavior";
  35287. /**
  35288. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35289. */
  35290. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35291. private ui;
  35292. /**
  35293. * The name of the behavior
  35294. */
  35295. name: string;
  35296. /**
  35297. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35298. */
  35299. distanceAwayFromFace: number;
  35300. /**
  35301. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35302. */
  35303. distanceAwayFromBottomOfFace: number;
  35304. private _faceVectors;
  35305. private _target;
  35306. private _scene;
  35307. private _onRenderObserver;
  35308. private _tmpMatrix;
  35309. private _tmpVector;
  35310. /**
  35311. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35312. * @param ui The transform node that should be attched to the mesh
  35313. */
  35314. constructor(ui: TransformNode);
  35315. /**
  35316. * Initializes the behavior
  35317. */
  35318. init(): void;
  35319. private _closestFace;
  35320. private _zeroVector;
  35321. private _lookAtTmpMatrix;
  35322. private _lookAtToRef;
  35323. /**
  35324. * Attaches the AttachToBoxBehavior to the passed in mesh
  35325. * @param target The mesh that the specified node will be attached to
  35326. */
  35327. attach(target: Mesh): void;
  35328. /**
  35329. * Detaches the behavior from the mesh
  35330. */
  35331. detach(): void;
  35332. }
  35333. }
  35334. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35335. import { Behavior } from "babylonjs/Behaviors/behavior";
  35336. import { Mesh } from "babylonjs/Meshes/mesh";
  35337. /**
  35338. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35339. */
  35340. export class FadeInOutBehavior implements Behavior<Mesh> {
  35341. /**
  35342. * Time in milliseconds to delay before fading in (Default: 0)
  35343. */
  35344. delay: number;
  35345. /**
  35346. * Time in milliseconds for the mesh to fade in (Default: 300)
  35347. */
  35348. fadeInTime: number;
  35349. private _millisecondsPerFrame;
  35350. private _hovered;
  35351. private _hoverValue;
  35352. private _ownerNode;
  35353. /**
  35354. * Instatiates the FadeInOutBehavior
  35355. */
  35356. constructor();
  35357. /**
  35358. * The name of the behavior
  35359. */
  35360. readonly name: string;
  35361. /**
  35362. * Initializes the behavior
  35363. */
  35364. init(): void;
  35365. /**
  35366. * Attaches the fade behavior on the passed in mesh
  35367. * @param ownerNode The mesh that will be faded in/out once attached
  35368. */
  35369. attach(ownerNode: Mesh): void;
  35370. /**
  35371. * Detaches the behavior from the mesh
  35372. */
  35373. detach(): void;
  35374. /**
  35375. * Triggers the mesh to begin fading in or out
  35376. * @param value if the object should fade in or out (true to fade in)
  35377. */
  35378. fadeIn(value: boolean): void;
  35379. private _update;
  35380. private _setAllVisibility;
  35381. }
  35382. }
  35383. declare module "babylonjs/Misc/pivotTools" {
  35384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35385. /**
  35386. * Class containing a set of static utilities functions for managing Pivots
  35387. * @hidden
  35388. */
  35389. export class PivotTools {
  35390. private static _PivotCached;
  35391. private static _OldPivotPoint;
  35392. private static _PivotTranslation;
  35393. private static _PivotTmpVector;
  35394. /** @hidden */
  35395. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35396. /** @hidden */
  35397. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35398. }
  35399. }
  35400. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35401. import { Scene } from "babylonjs/scene";
  35402. import { Vector4, Plane } from "babylonjs/Maths/math";
  35403. import { Mesh } from "babylonjs/Meshes/mesh";
  35404. /**
  35405. * Class containing static functions to help procedurally build meshes
  35406. */
  35407. export class PlaneBuilder {
  35408. /**
  35409. * Creates a plane mesh
  35410. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35411. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35412. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35416. * @param name defines the name of the mesh
  35417. * @param options defines the options used to create the mesh
  35418. * @param scene defines the hosting scene
  35419. * @returns the plane mesh
  35420. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35421. */
  35422. static CreatePlane(name: string, options: {
  35423. size?: number;
  35424. width?: number;
  35425. height?: number;
  35426. sideOrientation?: number;
  35427. frontUVs?: Vector4;
  35428. backUVs?: Vector4;
  35429. updatable?: boolean;
  35430. sourcePlane?: Plane;
  35431. }, scene: Scene): Mesh;
  35432. }
  35433. }
  35434. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35435. import { Behavior } from "babylonjs/Behaviors/behavior";
  35436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35437. import { Observable } from "babylonjs/Misc/observable";
  35438. import { Vector3 } from "babylonjs/Maths/math";
  35439. import { Ray } from "babylonjs/Culling/ray";
  35440. import "babylonjs/Meshes/Builders/planeBuilder";
  35441. /**
  35442. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35443. */
  35444. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35445. private static _AnyMouseID;
  35446. private _attachedNode;
  35447. private _dragPlane;
  35448. private _scene;
  35449. private _pointerObserver;
  35450. private _beforeRenderObserver;
  35451. private static _planeScene;
  35452. /**
  35453. * 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)
  35454. */
  35455. maxDragAngle: number;
  35456. /**
  35457. * @hidden
  35458. */
  35459. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35460. /**
  35461. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35462. */
  35463. currentDraggingPointerID: number;
  35464. /**
  35465. * The last position where the pointer hit the drag plane in world space
  35466. */
  35467. lastDragPosition: Vector3;
  35468. /**
  35469. * If the behavior is currently in a dragging state
  35470. */
  35471. dragging: boolean;
  35472. /**
  35473. * 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)
  35474. */
  35475. dragDeltaRatio: number;
  35476. /**
  35477. * If the drag plane orientation should be updated during the dragging (Default: true)
  35478. */
  35479. updateDragPlane: boolean;
  35480. private _debugMode;
  35481. private _moving;
  35482. /**
  35483. * Fires each time the attached mesh is dragged with the pointer
  35484. * * delta between last drag position and current drag position in world space
  35485. * * dragDistance along the drag axis
  35486. * * dragPlaneNormal normal of the current drag plane used during the drag
  35487. * * dragPlanePoint in world space where the drag intersects the drag plane
  35488. */
  35489. onDragObservable: Observable<{
  35490. delta: Vector3;
  35491. dragPlanePoint: Vector3;
  35492. dragPlaneNormal: Vector3;
  35493. dragDistance: number;
  35494. pointerId: number;
  35495. }>;
  35496. /**
  35497. * Fires each time a drag begins (eg. mouse down on mesh)
  35498. */
  35499. onDragStartObservable: Observable<{
  35500. dragPlanePoint: Vector3;
  35501. pointerId: number;
  35502. }>;
  35503. /**
  35504. * Fires each time a drag ends (eg. mouse release after drag)
  35505. */
  35506. onDragEndObservable: Observable<{
  35507. dragPlanePoint: Vector3;
  35508. pointerId: number;
  35509. }>;
  35510. /**
  35511. * If the attached mesh should be moved when dragged
  35512. */
  35513. moveAttached: boolean;
  35514. /**
  35515. * If the drag behavior will react to drag events (Default: true)
  35516. */
  35517. enabled: boolean;
  35518. /**
  35519. * If camera controls should be detached during the drag
  35520. */
  35521. detachCameraControls: boolean;
  35522. /**
  35523. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35524. */
  35525. useObjectOrienationForDragging: boolean;
  35526. private _options;
  35527. /**
  35528. * Creates a pointer drag behavior that can be attached to a mesh
  35529. * @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)
  35530. */
  35531. constructor(options?: {
  35532. dragAxis?: Vector3;
  35533. dragPlaneNormal?: Vector3;
  35534. });
  35535. /**
  35536. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35537. */
  35538. validateDrag: (targetPosition: Vector3) => boolean;
  35539. /**
  35540. * The name of the behavior
  35541. */
  35542. readonly name: string;
  35543. /**
  35544. * Initializes the behavior
  35545. */
  35546. init(): void;
  35547. private _tmpVector;
  35548. private _alternatePickedPoint;
  35549. private _worldDragAxis;
  35550. private _targetPosition;
  35551. private _attachedElement;
  35552. /**
  35553. * Attaches the drag behavior the passed in mesh
  35554. * @param ownerNode The mesh that will be dragged around once attached
  35555. */
  35556. attach(ownerNode: AbstractMesh): void;
  35557. /**
  35558. * Force relase the drag action by code.
  35559. */
  35560. releaseDrag(): void;
  35561. private _startDragRay;
  35562. private _lastPointerRay;
  35563. /**
  35564. * Simulates the start of a pointer drag event on the behavior
  35565. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35566. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35567. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35568. */
  35569. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35570. private _startDrag;
  35571. private _dragDelta;
  35572. private _moveDrag;
  35573. private _pickWithRayOnDragPlane;
  35574. private _pointA;
  35575. private _pointB;
  35576. private _pointC;
  35577. private _lineA;
  35578. private _lineB;
  35579. private _localAxis;
  35580. private _lookAt;
  35581. private _updateDragPlanePosition;
  35582. /**
  35583. * Detaches the behavior from the mesh
  35584. */
  35585. detach(): void;
  35586. }
  35587. }
  35588. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35589. import { Mesh } from "babylonjs/Meshes/mesh";
  35590. import { Behavior } from "babylonjs/Behaviors/behavior";
  35591. /**
  35592. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35593. */
  35594. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35595. private _dragBehaviorA;
  35596. private _dragBehaviorB;
  35597. private _startDistance;
  35598. private _initialScale;
  35599. private _targetScale;
  35600. private _ownerNode;
  35601. private _sceneRenderObserver;
  35602. /**
  35603. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35604. */
  35605. constructor();
  35606. /**
  35607. * The name of the behavior
  35608. */
  35609. readonly name: string;
  35610. /**
  35611. * Initializes the behavior
  35612. */
  35613. init(): void;
  35614. private _getCurrentDistance;
  35615. /**
  35616. * Attaches the scale behavior the passed in mesh
  35617. * @param ownerNode The mesh that will be scaled around once attached
  35618. */
  35619. attach(ownerNode: Mesh): void;
  35620. /**
  35621. * Detaches the behavior from the mesh
  35622. */
  35623. detach(): void;
  35624. }
  35625. }
  35626. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35627. import { Behavior } from "babylonjs/Behaviors/behavior";
  35628. import { Mesh } from "babylonjs/Meshes/mesh";
  35629. import { Observable } from "babylonjs/Misc/observable";
  35630. /**
  35631. * 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
  35632. */
  35633. export class SixDofDragBehavior implements Behavior<Mesh> {
  35634. private static _virtualScene;
  35635. private _ownerNode;
  35636. private _sceneRenderObserver;
  35637. private _scene;
  35638. private _targetPosition;
  35639. private _virtualOriginMesh;
  35640. private _virtualDragMesh;
  35641. private _pointerObserver;
  35642. private _moving;
  35643. private _startingOrientation;
  35644. /**
  35645. * 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)
  35646. */
  35647. private zDragFactor;
  35648. /**
  35649. * If the object should rotate to face the drag origin
  35650. */
  35651. rotateDraggedObject: boolean;
  35652. /**
  35653. * If the behavior is currently in a dragging state
  35654. */
  35655. dragging: boolean;
  35656. /**
  35657. * 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)
  35658. */
  35659. dragDeltaRatio: number;
  35660. /**
  35661. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35662. */
  35663. currentDraggingPointerID: number;
  35664. /**
  35665. * If camera controls should be detached during the drag
  35666. */
  35667. detachCameraControls: boolean;
  35668. /**
  35669. * Fires each time a drag starts
  35670. */
  35671. onDragStartObservable: Observable<{}>;
  35672. /**
  35673. * Fires each time a drag ends (eg. mouse release after drag)
  35674. */
  35675. onDragEndObservable: Observable<{}>;
  35676. /**
  35677. * 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
  35678. */
  35679. constructor();
  35680. /**
  35681. * The name of the behavior
  35682. */
  35683. readonly name: string;
  35684. /**
  35685. * Initializes the behavior
  35686. */
  35687. init(): void;
  35688. /**
  35689. * Attaches the scale behavior the passed in mesh
  35690. * @param ownerNode The mesh that will be scaled around once attached
  35691. */
  35692. attach(ownerNode: Mesh): void;
  35693. /**
  35694. * Detaches the behavior from the mesh
  35695. */
  35696. detach(): void;
  35697. }
  35698. }
  35699. declare module "babylonjs/Behaviors/Meshes/index" {
  35700. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35701. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35702. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35703. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35704. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35705. }
  35706. declare module "babylonjs/Behaviors/index" {
  35707. export * from "babylonjs/Behaviors/behavior";
  35708. export * from "babylonjs/Behaviors/Cameras/index";
  35709. export * from "babylonjs/Behaviors/Meshes/index";
  35710. }
  35711. declare module "babylonjs/Bones/boneIKController" {
  35712. import { Bone } from "babylonjs/Bones/bone";
  35713. import { Vector3 } from "babylonjs/Maths/math";
  35714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35715. import { Nullable } from "babylonjs/types";
  35716. /**
  35717. * Class used to apply inverse kinematics to bones
  35718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35719. */
  35720. export class BoneIKController {
  35721. private static _tmpVecs;
  35722. private static _tmpQuat;
  35723. private static _tmpMats;
  35724. /**
  35725. * Gets or sets the target mesh
  35726. */
  35727. targetMesh: AbstractMesh;
  35728. /** Gets or sets the mesh used as pole */
  35729. poleTargetMesh: AbstractMesh;
  35730. /**
  35731. * Gets or sets the bone used as pole
  35732. */
  35733. poleTargetBone: Nullable<Bone>;
  35734. /**
  35735. * Gets or sets the target position
  35736. */
  35737. targetPosition: Vector3;
  35738. /**
  35739. * Gets or sets the pole target position
  35740. */
  35741. poleTargetPosition: Vector3;
  35742. /**
  35743. * Gets or sets the pole target local offset
  35744. */
  35745. poleTargetLocalOffset: Vector3;
  35746. /**
  35747. * Gets or sets the pole angle
  35748. */
  35749. poleAngle: number;
  35750. /**
  35751. * Gets or sets the mesh associated with the controller
  35752. */
  35753. mesh: AbstractMesh;
  35754. /**
  35755. * 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)
  35756. */
  35757. slerpAmount: number;
  35758. private _bone1Quat;
  35759. private _bone1Mat;
  35760. private _bone2Ang;
  35761. private _bone1;
  35762. private _bone2;
  35763. private _bone1Length;
  35764. private _bone2Length;
  35765. private _maxAngle;
  35766. private _maxReach;
  35767. private _rightHandedSystem;
  35768. private _bendAxis;
  35769. private _slerping;
  35770. private _adjustRoll;
  35771. /**
  35772. * Gets or sets maximum allowed angle
  35773. */
  35774. maxAngle: number;
  35775. /**
  35776. * Creates a new BoneIKController
  35777. * @param mesh defines the mesh to control
  35778. * @param bone defines the bone to control
  35779. * @param options defines options to set up the controller
  35780. */
  35781. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35782. targetMesh?: AbstractMesh;
  35783. poleTargetMesh?: AbstractMesh;
  35784. poleTargetBone?: Bone;
  35785. poleTargetLocalOffset?: Vector3;
  35786. poleAngle?: number;
  35787. bendAxis?: Vector3;
  35788. maxAngle?: number;
  35789. slerpAmount?: number;
  35790. });
  35791. private _setMaxAngle;
  35792. /**
  35793. * Force the controller to update the bones
  35794. */
  35795. update(): void;
  35796. }
  35797. }
  35798. declare module "babylonjs/Bones/boneLookController" {
  35799. import { Vector3, Space } from "babylonjs/Maths/math";
  35800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35801. import { Bone } from "babylonjs/Bones/bone";
  35802. /**
  35803. * Class used to make a bone look toward a point in space
  35804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35805. */
  35806. export class BoneLookController {
  35807. private static _tmpVecs;
  35808. private static _tmpQuat;
  35809. private static _tmpMats;
  35810. /**
  35811. * The target Vector3 that the bone will look at
  35812. */
  35813. target: Vector3;
  35814. /**
  35815. * The mesh that the bone is attached to
  35816. */
  35817. mesh: AbstractMesh;
  35818. /**
  35819. * The bone that will be looking to the target
  35820. */
  35821. bone: Bone;
  35822. /**
  35823. * The up axis of the coordinate system that is used when the bone is rotated
  35824. */
  35825. upAxis: Vector3;
  35826. /**
  35827. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35828. */
  35829. upAxisSpace: Space;
  35830. /**
  35831. * Used to make an adjustment to the yaw of the bone
  35832. */
  35833. adjustYaw: number;
  35834. /**
  35835. * Used to make an adjustment to the pitch of the bone
  35836. */
  35837. adjustPitch: number;
  35838. /**
  35839. * Used to make an adjustment to the roll of the bone
  35840. */
  35841. adjustRoll: number;
  35842. /**
  35843. * 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)
  35844. */
  35845. slerpAmount: number;
  35846. private _minYaw;
  35847. private _maxYaw;
  35848. private _minPitch;
  35849. private _maxPitch;
  35850. private _minYawSin;
  35851. private _minYawCos;
  35852. private _maxYawSin;
  35853. private _maxYawCos;
  35854. private _midYawConstraint;
  35855. private _minPitchTan;
  35856. private _maxPitchTan;
  35857. private _boneQuat;
  35858. private _slerping;
  35859. private _transformYawPitch;
  35860. private _transformYawPitchInv;
  35861. private _firstFrameSkipped;
  35862. private _yawRange;
  35863. private _fowardAxis;
  35864. /**
  35865. * Gets or sets the minimum yaw angle that the bone can look to
  35866. */
  35867. minYaw: number;
  35868. /**
  35869. * Gets or sets the maximum yaw angle that the bone can look to
  35870. */
  35871. maxYaw: number;
  35872. /**
  35873. * Gets or sets the minimum pitch angle that the bone can look to
  35874. */
  35875. minPitch: number;
  35876. /**
  35877. * Gets or sets the maximum pitch angle that the bone can look to
  35878. */
  35879. maxPitch: number;
  35880. /**
  35881. * Create a BoneLookController
  35882. * @param mesh the mesh that the bone belongs to
  35883. * @param bone the bone that will be looking to the target
  35884. * @param target the target Vector3 to look at
  35885. * @param options optional settings:
  35886. * * maxYaw: the maximum angle the bone will yaw to
  35887. * * minYaw: the minimum angle the bone will yaw to
  35888. * * maxPitch: the maximum angle the bone will pitch to
  35889. * * minPitch: the minimum angle the bone will yaw to
  35890. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35891. * * upAxis: the up axis of the coordinate system
  35892. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35893. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35894. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35895. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35896. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35897. * * adjustRoll: used to make an adjustment to the roll of the bone
  35898. **/
  35899. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35900. maxYaw?: number;
  35901. minYaw?: number;
  35902. maxPitch?: number;
  35903. minPitch?: number;
  35904. slerpAmount?: number;
  35905. upAxis?: Vector3;
  35906. upAxisSpace?: Space;
  35907. yawAxis?: Vector3;
  35908. pitchAxis?: Vector3;
  35909. adjustYaw?: number;
  35910. adjustPitch?: number;
  35911. adjustRoll?: number;
  35912. });
  35913. /**
  35914. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35915. */
  35916. update(): void;
  35917. private _getAngleDiff;
  35918. private _getAngleBetween;
  35919. private _isAngleBetween;
  35920. }
  35921. }
  35922. declare module "babylonjs/Bones/index" {
  35923. export * from "babylonjs/Bones/bone";
  35924. export * from "babylonjs/Bones/boneIKController";
  35925. export * from "babylonjs/Bones/boneLookController";
  35926. export * from "babylonjs/Bones/skeleton";
  35927. }
  35928. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35929. import { Nullable } from "babylonjs/types";
  35930. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35931. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35932. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35933. /**
  35934. * Manage the gamepad inputs to control an arc rotate camera.
  35935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35936. */
  35937. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35938. /**
  35939. * Defines the camera the input is attached to.
  35940. */
  35941. camera: ArcRotateCamera;
  35942. /**
  35943. * Defines the gamepad the input is gathering event from.
  35944. */
  35945. gamepad: Nullable<Gamepad>;
  35946. /**
  35947. * Defines the gamepad rotation sensiblity.
  35948. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35949. */
  35950. gamepadRotationSensibility: number;
  35951. /**
  35952. * Defines the gamepad move sensiblity.
  35953. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35954. */
  35955. gamepadMoveSensibility: number;
  35956. private _onGamepadConnectedObserver;
  35957. private _onGamepadDisconnectedObserver;
  35958. /**
  35959. * Attach the input controls to a specific dom element to get the input from.
  35960. * @param element Defines the element the controls should be listened from
  35961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35962. */
  35963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35964. /**
  35965. * Detach the current controls from the specified dom element.
  35966. * @param element Defines the element to stop listening the inputs from
  35967. */
  35968. detachControl(element: Nullable<HTMLElement>): void;
  35969. /**
  35970. * Update the current camera state depending on the inputs that have been used this frame.
  35971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35972. */
  35973. checkInputs(): void;
  35974. /**
  35975. * Gets the class name of the current intput.
  35976. * @returns the class name
  35977. */
  35978. getClassName(): string;
  35979. /**
  35980. * Get the friendly name associated with the input class.
  35981. * @returns the input friendly name
  35982. */
  35983. getSimpleName(): string;
  35984. }
  35985. }
  35986. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  35987. import { Nullable } from "babylonjs/types";
  35988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35990. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35991. interface ArcRotateCameraInputsManager {
  35992. /**
  35993. * Add orientation input support to the input manager.
  35994. * @returns the current input manager
  35995. */
  35996. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35997. }
  35998. }
  35999. /**
  36000. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36002. */
  36003. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36004. /**
  36005. * Defines the camera the input is attached to.
  36006. */
  36007. camera: ArcRotateCamera;
  36008. /**
  36009. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36010. */
  36011. alphaCorrection: number;
  36012. /**
  36013. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36014. */
  36015. gammaCorrection: number;
  36016. private _alpha;
  36017. private _gamma;
  36018. private _dirty;
  36019. private _deviceOrientationHandler;
  36020. /**
  36021. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36022. */
  36023. constructor();
  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. /** @hidden */
  36031. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36032. /**
  36033. * Update the current camera state depending on the inputs that have been used this frame.
  36034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36035. */
  36036. checkInputs(): void;
  36037. /**
  36038. * Detach the current controls from the specified dom element.
  36039. * @param element Defines the element to stop listening the inputs from
  36040. */
  36041. detachControl(element: Nullable<HTMLElement>): void;
  36042. /**
  36043. * Gets the class name of the current intput.
  36044. * @returns the class name
  36045. */
  36046. getClassName(): string;
  36047. /**
  36048. * Get the friendly name associated with the input class.
  36049. * @returns the input friendly name
  36050. */
  36051. getSimpleName(): string;
  36052. }
  36053. }
  36054. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36055. import { Nullable } from "babylonjs/types";
  36056. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36057. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36058. /**
  36059. * Listen to mouse events to control the camera.
  36060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36061. */
  36062. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36063. /**
  36064. * Defines the camera the input is attached to.
  36065. */
  36066. camera: FlyCamera;
  36067. /**
  36068. * Defines if touch is enabled. (Default is true.)
  36069. */
  36070. touchEnabled: boolean;
  36071. /**
  36072. * Defines the buttons associated with the input to handle camera rotation.
  36073. */
  36074. buttons: number[];
  36075. /**
  36076. * Assign buttons for Yaw control.
  36077. */
  36078. buttonsYaw: number[];
  36079. /**
  36080. * Assign buttons for Pitch control.
  36081. */
  36082. buttonsPitch: number[];
  36083. /**
  36084. * Assign buttons for Roll control.
  36085. */
  36086. buttonsRoll: number[];
  36087. /**
  36088. * Detect if any button is being pressed while mouse is moved.
  36089. * -1 = Mouse locked.
  36090. * 0 = Left button.
  36091. * 1 = Middle Button.
  36092. * 2 = Right Button.
  36093. */
  36094. activeButton: number;
  36095. /**
  36096. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36097. * Higher values reduce its sensitivity.
  36098. */
  36099. angularSensibility: number;
  36100. private _mousemoveCallback;
  36101. private _observer;
  36102. private _rollObserver;
  36103. private previousPosition;
  36104. private noPreventDefault;
  36105. private element;
  36106. /**
  36107. * Listen to mouse events to control the camera.
  36108. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36110. */
  36111. constructor(touchEnabled?: boolean);
  36112. /**
  36113. * Attach the mouse control to the HTML DOM element.
  36114. * @param element Defines the element that listens to the input events.
  36115. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36116. */
  36117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36118. /**
  36119. * Detach the current controls from the specified dom element.
  36120. * @param element Defines the element to stop listening the inputs from
  36121. */
  36122. detachControl(element: Nullable<HTMLElement>): void;
  36123. /**
  36124. * Gets the class name of the current input.
  36125. * @returns the class name.
  36126. */
  36127. getClassName(): string;
  36128. /**
  36129. * Get the friendly name associated with the input class.
  36130. * @returns the input's friendly name.
  36131. */
  36132. getSimpleName(): string;
  36133. private _pointerInput;
  36134. private _onMouseMove;
  36135. /**
  36136. * Rotate camera by mouse offset.
  36137. */
  36138. private rotateCamera;
  36139. }
  36140. }
  36141. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36142. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36143. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36144. /**
  36145. * Default Inputs manager for the FlyCamera.
  36146. * It groups all the default supported inputs for ease of use.
  36147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36148. */
  36149. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36150. /**
  36151. * Instantiates a new FlyCameraInputsManager.
  36152. * @param camera Defines the camera the inputs belong to.
  36153. */
  36154. constructor(camera: FlyCamera);
  36155. /**
  36156. * Add keyboard input support to the input manager.
  36157. * @returns the new FlyCameraKeyboardMoveInput().
  36158. */
  36159. addKeyboard(): FlyCameraInputsManager;
  36160. /**
  36161. * Add mouse input support to the input manager.
  36162. * @param touchEnabled Enable touch screen support.
  36163. * @returns the new FlyCameraMouseInput().
  36164. */
  36165. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36166. }
  36167. }
  36168. declare module "babylonjs/Cameras/flyCamera" {
  36169. import { Scene } from "babylonjs/scene";
  36170. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36172. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36173. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36174. /**
  36175. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36176. * such as in a 3D Space Shooter or a Flight Simulator.
  36177. */
  36178. export class FlyCamera extends TargetCamera {
  36179. /**
  36180. * Define the collision ellipsoid of the camera.
  36181. * This is helpful for simulating a camera body, like a player's body.
  36182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36183. */
  36184. ellipsoid: Vector3;
  36185. /**
  36186. * Define an offset for the position of the ellipsoid around the camera.
  36187. * This can be helpful if the camera is attached away from the player's body center,
  36188. * such as at its head.
  36189. */
  36190. ellipsoidOffset: Vector3;
  36191. /**
  36192. * Enable or disable collisions of the camera with the rest of the scene objects.
  36193. */
  36194. checkCollisions: boolean;
  36195. /**
  36196. * Enable or disable gravity on the camera.
  36197. */
  36198. applyGravity: boolean;
  36199. /**
  36200. * Define the current direction the camera is moving to.
  36201. */
  36202. cameraDirection: Vector3;
  36203. /**
  36204. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36205. * This overrides and empties cameraRotation.
  36206. */
  36207. rotationQuaternion: Quaternion;
  36208. /**
  36209. * Track Roll to maintain the wanted Rolling when looking around.
  36210. */
  36211. _trackRoll: number;
  36212. /**
  36213. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36214. */
  36215. rollCorrect: number;
  36216. /**
  36217. * Mimic a banked turn, Rolling the camera when Yawing.
  36218. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36219. */
  36220. bankedTurn: boolean;
  36221. /**
  36222. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36223. */
  36224. bankedTurnLimit: number;
  36225. /**
  36226. * Value of 0 disables the banked Roll.
  36227. * Value of 1 is equal to the Yaw angle in radians.
  36228. */
  36229. bankedTurnMultiplier: number;
  36230. /**
  36231. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36232. */
  36233. inputs: FlyCameraInputsManager;
  36234. /**
  36235. * Gets the input sensibility for mouse input.
  36236. * Higher values reduce sensitivity.
  36237. */
  36238. /**
  36239. * Sets the input sensibility for a mouse input.
  36240. * Higher values reduce sensitivity.
  36241. */
  36242. angularSensibility: number;
  36243. /**
  36244. * Get the keys for camera movement forward.
  36245. */
  36246. /**
  36247. * Set the keys for camera movement forward.
  36248. */
  36249. keysForward: number[];
  36250. /**
  36251. * Get the keys for camera movement backward.
  36252. */
  36253. keysBackward: number[];
  36254. /**
  36255. * Get the keys for camera movement up.
  36256. */
  36257. /**
  36258. * Set the keys for camera movement up.
  36259. */
  36260. keysUp: number[];
  36261. /**
  36262. * Get the keys for camera movement down.
  36263. */
  36264. /**
  36265. * Set the keys for camera movement down.
  36266. */
  36267. keysDown: number[];
  36268. /**
  36269. * Get the keys for camera movement left.
  36270. */
  36271. /**
  36272. * Set the keys for camera movement left.
  36273. */
  36274. keysLeft: number[];
  36275. /**
  36276. * Set the keys for camera movement right.
  36277. */
  36278. /**
  36279. * Set the keys for camera movement right.
  36280. */
  36281. keysRight: number[];
  36282. /**
  36283. * Event raised when the camera collides with a mesh in the scene.
  36284. */
  36285. onCollide: (collidedMesh: AbstractMesh) => void;
  36286. private _collider;
  36287. private _needMoveForGravity;
  36288. private _oldPosition;
  36289. private _diffPosition;
  36290. private _newPosition;
  36291. /** @hidden */
  36292. _localDirection: Vector3;
  36293. /** @hidden */
  36294. _transformedDirection: Vector3;
  36295. /**
  36296. * Instantiates a FlyCamera.
  36297. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36298. * such as in a 3D Space Shooter or a Flight Simulator.
  36299. * @param name Define the name of the camera in the scene.
  36300. * @param position Define the starting position of the camera in the scene.
  36301. * @param scene Define the scene the camera belongs to.
  36302. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36303. */
  36304. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36305. /**
  36306. * Attach a control to the HTML DOM element.
  36307. * @param element Defines the element that listens to the input events.
  36308. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36309. */
  36310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36311. /**
  36312. * Detach a control from the HTML DOM element.
  36313. * The camera will stop reacting to that input.
  36314. * @param element Defines the element that listens to the input events.
  36315. */
  36316. detachControl(element: HTMLElement): void;
  36317. private _collisionMask;
  36318. /**
  36319. * Get the mask that the camera ignores in collision events.
  36320. */
  36321. /**
  36322. * Set the mask that the camera ignores in collision events.
  36323. */
  36324. collisionMask: number;
  36325. /** @hidden */
  36326. _collideWithWorld(displacement: Vector3): void;
  36327. /** @hidden */
  36328. private _onCollisionPositionChange;
  36329. /** @hidden */
  36330. _checkInputs(): void;
  36331. /** @hidden */
  36332. _decideIfNeedsToMove(): boolean;
  36333. /** @hidden */
  36334. _updatePosition(): void;
  36335. /**
  36336. * Restore the Roll to its target value at the rate specified.
  36337. * @param rate - Higher means slower restoring.
  36338. * @hidden
  36339. */
  36340. restoreRoll(rate: number): void;
  36341. /**
  36342. * Destroy the camera and release the current resources held by it.
  36343. */
  36344. dispose(): void;
  36345. /**
  36346. * Get the current object class name.
  36347. * @returns the class name.
  36348. */
  36349. getClassName(): string;
  36350. }
  36351. }
  36352. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36353. import { Nullable } from "babylonjs/types";
  36354. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36355. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36356. /**
  36357. * Listen to keyboard events to control the camera.
  36358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36359. */
  36360. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36361. /**
  36362. * Defines the camera the input is attached to.
  36363. */
  36364. camera: FlyCamera;
  36365. /**
  36366. * The list of keyboard keys used to control the forward move of the camera.
  36367. */
  36368. keysForward: number[];
  36369. /**
  36370. * The list of keyboard keys used to control the backward move of the camera.
  36371. */
  36372. keysBackward: number[];
  36373. /**
  36374. * The list of keyboard keys used to control the forward move of the camera.
  36375. */
  36376. keysUp: number[];
  36377. /**
  36378. * The list of keyboard keys used to control the backward move of the camera.
  36379. */
  36380. keysDown: number[];
  36381. /**
  36382. * The list of keyboard keys used to control the right strafe move of the camera.
  36383. */
  36384. keysRight: number[];
  36385. /**
  36386. * The list of keyboard keys used to control the left strafe move of the camera.
  36387. */
  36388. keysLeft: number[];
  36389. private _keys;
  36390. private _onCanvasBlurObserver;
  36391. private _onKeyboardObserver;
  36392. private _engine;
  36393. private _scene;
  36394. /**
  36395. * Attach the input controls to a specific dom element to get the input from.
  36396. * @param element Defines the element the controls should be listened from
  36397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36398. */
  36399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36400. /**
  36401. * Detach the current controls from the specified dom element.
  36402. * @param element Defines the element to stop listening the inputs from
  36403. */
  36404. detachControl(element: Nullable<HTMLElement>): void;
  36405. /**
  36406. * Gets the class name of the current intput.
  36407. * @returns the class name
  36408. */
  36409. getClassName(): string;
  36410. /** @hidden */
  36411. _onLostFocus(e: FocusEvent): void;
  36412. /**
  36413. * Get the friendly name associated with the input class.
  36414. * @returns the input friendly name
  36415. */
  36416. getSimpleName(): string;
  36417. /**
  36418. * Update the current camera state depending on the inputs that have been used this frame.
  36419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36420. */
  36421. checkInputs(): void;
  36422. }
  36423. }
  36424. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36425. import { Nullable } from "babylonjs/types";
  36426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36427. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36428. module "babylonjs/Cameras/freeCameraInputsManager" {
  36429. interface FreeCameraInputsManager {
  36430. /**
  36431. * Add orientation input support to the input manager.
  36432. * @returns the current input manager
  36433. */
  36434. addDeviceOrientation(): FreeCameraInputsManager;
  36435. }
  36436. }
  36437. /**
  36438. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36439. * Screen rotation is taken into account.
  36440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36441. */
  36442. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36443. private _camera;
  36444. private _screenOrientationAngle;
  36445. private _constantTranform;
  36446. private _screenQuaternion;
  36447. private _alpha;
  36448. private _beta;
  36449. private _gamma;
  36450. /**
  36451. * Instantiates a new input
  36452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36453. */
  36454. constructor();
  36455. /**
  36456. * Define the camera controlled by the input.
  36457. */
  36458. camera: FreeCamera;
  36459. /**
  36460. * Attach the input controls to a specific dom element to get the input from.
  36461. * @param element Defines the element the controls should be listened from
  36462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36463. */
  36464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36465. private _orientationChanged;
  36466. private _deviceOrientation;
  36467. /**
  36468. * Detach the current controls from the specified dom element.
  36469. * @param element Defines the element to stop listening the inputs from
  36470. */
  36471. detachControl(element: Nullable<HTMLElement>): void;
  36472. /**
  36473. * Update the current camera state depending on the inputs that have been used this frame.
  36474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36475. */
  36476. checkInputs(): void;
  36477. /**
  36478. * Gets the class name of the current intput.
  36479. * @returns the class name
  36480. */
  36481. getClassName(): string;
  36482. /**
  36483. * Get the friendly name associated with the input class.
  36484. * @returns the input friendly name
  36485. */
  36486. getSimpleName(): string;
  36487. }
  36488. }
  36489. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36490. import { Nullable } from "babylonjs/types";
  36491. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36492. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36493. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36494. /**
  36495. * Manage the gamepad inputs to control a free camera.
  36496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36497. */
  36498. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36499. /**
  36500. * Define the camera the input is attached to.
  36501. */
  36502. camera: FreeCamera;
  36503. /**
  36504. * Define the Gamepad controlling the input
  36505. */
  36506. gamepad: Nullable<Gamepad>;
  36507. /**
  36508. * Defines the gamepad rotation sensiblity.
  36509. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36510. */
  36511. gamepadAngularSensibility: number;
  36512. /**
  36513. * Defines the gamepad move sensiblity.
  36514. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36515. */
  36516. gamepadMoveSensibility: number;
  36517. private _onGamepadConnectedObserver;
  36518. private _onGamepadDisconnectedObserver;
  36519. private _cameraTransform;
  36520. private _deltaTransform;
  36521. private _vector3;
  36522. private _vector2;
  36523. /**
  36524. * Attach the input controls to a specific dom element to get the input from.
  36525. * @param element Defines the element the controls should be listened from
  36526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36527. */
  36528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36529. /**
  36530. * Detach the current controls from the specified dom element.
  36531. * @param element Defines the element to stop listening the inputs from
  36532. */
  36533. detachControl(element: Nullable<HTMLElement>): void;
  36534. /**
  36535. * Update the current camera state depending on the inputs that have been used this frame.
  36536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36537. */
  36538. checkInputs(): void;
  36539. /**
  36540. * Gets the class name of the current intput.
  36541. * @returns the class name
  36542. */
  36543. getClassName(): string;
  36544. /**
  36545. * Get the friendly name associated with the input class.
  36546. * @returns the input friendly name
  36547. */
  36548. getSimpleName(): string;
  36549. }
  36550. }
  36551. declare module "babylonjs/Misc/virtualJoystick" {
  36552. import { Nullable } from "babylonjs/types";
  36553. import { Vector3 } from "babylonjs/Maths/math";
  36554. /**
  36555. * Defines the potential axis of a Joystick
  36556. */
  36557. export enum JoystickAxis {
  36558. /** X axis */
  36559. X = 0,
  36560. /** Y axis */
  36561. Y = 1,
  36562. /** Z axis */
  36563. Z = 2
  36564. }
  36565. /**
  36566. * Class used to define virtual joystick (used in touch mode)
  36567. */
  36568. export class VirtualJoystick {
  36569. /**
  36570. * Gets or sets a boolean indicating that left and right values must be inverted
  36571. */
  36572. reverseLeftRight: boolean;
  36573. /**
  36574. * Gets or sets a boolean indicating that up and down values must be inverted
  36575. */
  36576. reverseUpDown: boolean;
  36577. /**
  36578. * Gets the offset value for the position (ie. the change of the position value)
  36579. */
  36580. deltaPosition: Vector3;
  36581. /**
  36582. * Gets a boolean indicating if the virtual joystick was pressed
  36583. */
  36584. pressed: boolean;
  36585. /**
  36586. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36587. */
  36588. static Canvas: Nullable<HTMLCanvasElement>;
  36589. private static _globalJoystickIndex;
  36590. private static vjCanvasContext;
  36591. private static vjCanvasWidth;
  36592. private static vjCanvasHeight;
  36593. private static halfWidth;
  36594. private _action;
  36595. private _axisTargetedByLeftAndRight;
  36596. private _axisTargetedByUpAndDown;
  36597. private _joystickSensibility;
  36598. private _inversedSensibility;
  36599. private _joystickPointerID;
  36600. private _joystickColor;
  36601. private _joystickPointerPos;
  36602. private _joystickPreviousPointerPos;
  36603. private _joystickPointerStartPos;
  36604. private _deltaJoystickVector;
  36605. private _leftJoystick;
  36606. private _touches;
  36607. private _onPointerDownHandlerRef;
  36608. private _onPointerMoveHandlerRef;
  36609. private _onPointerUpHandlerRef;
  36610. private _onResize;
  36611. /**
  36612. * Creates a new virtual joystick
  36613. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36614. */
  36615. constructor(leftJoystick?: boolean);
  36616. /**
  36617. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36618. * @param newJoystickSensibility defines the new sensibility
  36619. */
  36620. setJoystickSensibility(newJoystickSensibility: number): void;
  36621. private _onPointerDown;
  36622. private _onPointerMove;
  36623. private _onPointerUp;
  36624. /**
  36625. * Change the color of the virtual joystick
  36626. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36627. */
  36628. setJoystickColor(newColor: string): void;
  36629. /**
  36630. * Defines a callback to call when the joystick is touched
  36631. * @param action defines the callback
  36632. */
  36633. setActionOnTouch(action: () => any): void;
  36634. /**
  36635. * Defines which axis you'd like to control for left & right
  36636. * @param axis defines the axis to use
  36637. */
  36638. setAxisForLeftRight(axis: JoystickAxis): void;
  36639. /**
  36640. * Defines which axis you'd like to control for up & down
  36641. * @param axis defines the axis to use
  36642. */
  36643. setAxisForUpDown(axis: JoystickAxis): void;
  36644. private _drawVirtualJoystick;
  36645. /**
  36646. * Release internal HTML canvas
  36647. */
  36648. releaseCanvas(): void;
  36649. }
  36650. }
  36651. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36652. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36653. import { Nullable } from "babylonjs/types";
  36654. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36655. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36656. module "babylonjs/Cameras/freeCameraInputsManager" {
  36657. interface FreeCameraInputsManager {
  36658. /**
  36659. * Add virtual joystick input support to the input manager.
  36660. * @returns the current input manager
  36661. */
  36662. addVirtualJoystick(): FreeCameraInputsManager;
  36663. }
  36664. }
  36665. /**
  36666. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36668. */
  36669. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36670. /**
  36671. * Defines the camera the input is attached to.
  36672. */
  36673. camera: FreeCamera;
  36674. private _leftjoystick;
  36675. private _rightjoystick;
  36676. /**
  36677. * Gets the left stick of the virtual joystick.
  36678. * @returns The virtual Joystick
  36679. */
  36680. getLeftJoystick(): VirtualJoystick;
  36681. /**
  36682. * Gets the right stick of the virtual joystick.
  36683. * @returns The virtual Joystick
  36684. */
  36685. getRightJoystick(): VirtualJoystick;
  36686. /**
  36687. * Update the current camera state depending on the inputs that have been used this frame.
  36688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36689. */
  36690. checkInputs(): void;
  36691. /**
  36692. * Attach the input controls to a specific dom element to get the input from.
  36693. * @param element Defines the element the controls should be listened from
  36694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36695. */
  36696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36697. /**
  36698. * Detach the current controls from the specified dom element.
  36699. * @param element Defines the element to stop listening the inputs from
  36700. */
  36701. detachControl(element: Nullable<HTMLElement>): void;
  36702. /**
  36703. * Gets the class name of the current intput.
  36704. * @returns the class name
  36705. */
  36706. getClassName(): string;
  36707. /**
  36708. * Get the friendly name associated with the input class.
  36709. * @returns the input friendly name
  36710. */
  36711. getSimpleName(): string;
  36712. }
  36713. }
  36714. declare module "babylonjs/Cameras/Inputs/index" {
  36715. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36716. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36717. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36718. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36719. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36720. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36721. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36722. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36723. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36724. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36725. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36726. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36727. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36728. }
  36729. declare module "babylonjs/Cameras/touchCamera" {
  36730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36731. import { Scene } from "babylonjs/scene";
  36732. import { Vector3 } from "babylonjs/Maths/math";
  36733. /**
  36734. * This represents a FPS type of camera controlled by touch.
  36735. * This is like a universal camera minus the Gamepad controls.
  36736. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36737. */
  36738. export class TouchCamera extends FreeCamera {
  36739. /**
  36740. * Defines the touch sensibility for rotation.
  36741. * The higher the faster.
  36742. */
  36743. touchAngularSensibility: number;
  36744. /**
  36745. * Defines the touch sensibility for move.
  36746. * The higher the faster.
  36747. */
  36748. touchMoveSensibility: number;
  36749. /**
  36750. * Instantiates a new touch camera.
  36751. * This represents a FPS type of camera controlled by touch.
  36752. * This is like a universal camera minus the Gamepad controls.
  36753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36754. * @param name Define the name of the camera in the scene
  36755. * @param position Define the start position of the camera in the scene
  36756. * @param scene Define the scene the camera belongs to
  36757. */
  36758. constructor(name: string, position: Vector3, scene: Scene);
  36759. /**
  36760. * Gets the current object class name.
  36761. * @return the class name
  36762. */
  36763. getClassName(): string;
  36764. /** @hidden */
  36765. _setupInputs(): void;
  36766. }
  36767. }
  36768. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36769. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36770. import { Scene } from "babylonjs/scene";
  36771. import { Vector3, Axis } from "babylonjs/Maths/math";
  36772. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36773. /**
  36774. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36775. * being tilted forward or back and left or right.
  36776. */
  36777. export class DeviceOrientationCamera extends FreeCamera {
  36778. private _initialQuaternion;
  36779. private _quaternionCache;
  36780. /**
  36781. * Creates a new device orientation camera
  36782. * @param name The name of the camera
  36783. * @param position The start position camera
  36784. * @param scene The scene the camera belongs to
  36785. */
  36786. constructor(name: string, position: Vector3, scene: Scene);
  36787. /**
  36788. * Gets the current instance class name ("DeviceOrientationCamera").
  36789. * This helps avoiding instanceof at run time.
  36790. * @returns the class name
  36791. */
  36792. getClassName(): string;
  36793. /**
  36794. * @hidden
  36795. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36796. */
  36797. _checkInputs(): void;
  36798. /**
  36799. * Reset the camera to its default orientation on the specified axis only.
  36800. * @param axis The axis to reset
  36801. */
  36802. resetToCurrentRotation(axis?: Axis): void;
  36803. }
  36804. }
  36805. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36806. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36807. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36808. import { Nullable } from "babylonjs/types";
  36809. /**
  36810. * Manage the keyboard inputs to control the movement of a follow camera.
  36811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36812. */
  36813. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36814. /**
  36815. * Defines the camera the input is attached to.
  36816. */
  36817. camera: FollowCamera;
  36818. /**
  36819. * Defines the list of key codes associated with the up action (increase heightOffset)
  36820. */
  36821. keysHeightOffsetIncr: number[];
  36822. /**
  36823. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36824. */
  36825. keysHeightOffsetDecr: number[];
  36826. /**
  36827. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36828. */
  36829. keysHeightOffsetModifierAlt: boolean;
  36830. /**
  36831. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36832. */
  36833. keysHeightOffsetModifierCtrl: boolean;
  36834. /**
  36835. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36836. */
  36837. keysHeightOffsetModifierShift: boolean;
  36838. /**
  36839. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36840. */
  36841. keysRotationOffsetIncr: number[];
  36842. /**
  36843. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36844. */
  36845. keysRotationOffsetDecr: number[];
  36846. /**
  36847. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36848. */
  36849. keysRotationOffsetModifierAlt: boolean;
  36850. /**
  36851. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36852. */
  36853. keysRotationOffsetModifierCtrl: boolean;
  36854. /**
  36855. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36856. */
  36857. keysRotationOffsetModifierShift: boolean;
  36858. /**
  36859. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36860. */
  36861. keysRadiusIncr: number[];
  36862. /**
  36863. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36864. */
  36865. keysRadiusDecr: number[];
  36866. /**
  36867. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36868. */
  36869. keysRadiusModifierAlt: boolean;
  36870. /**
  36871. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36872. */
  36873. keysRadiusModifierCtrl: boolean;
  36874. /**
  36875. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36876. */
  36877. keysRadiusModifierShift: boolean;
  36878. /**
  36879. * Defines the rate of change of heightOffset.
  36880. */
  36881. heightSensibility: number;
  36882. /**
  36883. * Defines the rate of change of rotationOffset.
  36884. */
  36885. rotationSensibility: number;
  36886. /**
  36887. * Defines the rate of change of radius.
  36888. */
  36889. radiusSensibility: number;
  36890. private _keys;
  36891. private _ctrlPressed;
  36892. private _altPressed;
  36893. private _shiftPressed;
  36894. private _onCanvasBlurObserver;
  36895. private _onKeyboardObserver;
  36896. private _engine;
  36897. private _scene;
  36898. /**
  36899. * Attach the input controls to a specific dom element to get the input from.
  36900. * @param element Defines the element the controls should be listened from
  36901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36902. */
  36903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36904. /**
  36905. * Detach the current controls from the specified dom element.
  36906. * @param element Defines the element to stop listening the inputs from
  36907. */
  36908. detachControl(element: Nullable<HTMLElement>): void;
  36909. /**
  36910. * Update the current camera state depending on the inputs that have been used this frame.
  36911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36912. */
  36913. checkInputs(): void;
  36914. /**
  36915. * Gets the class name of the current input.
  36916. * @returns the class name
  36917. */
  36918. getClassName(): string;
  36919. /**
  36920. * Get the friendly name associated with the input class.
  36921. * @returns the input friendly name
  36922. */
  36923. getSimpleName(): string;
  36924. /**
  36925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36926. * allow modification of the heightOffset value.
  36927. */
  36928. private _modifierHeightOffset;
  36929. /**
  36930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36931. * allow modification of the rotationOffset value.
  36932. */
  36933. private _modifierRotationOffset;
  36934. /**
  36935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36936. * allow modification of the radius value.
  36937. */
  36938. private _modifierRadius;
  36939. }
  36940. }
  36941. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36942. import { Nullable } from "babylonjs/types";
  36943. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36944. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36945. /**
  36946. * Manage the mouse wheel inputs to control a follow camera.
  36947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36948. */
  36949. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36950. /**
  36951. * Defines the camera the input is attached to.
  36952. */
  36953. camera: FollowCamera;
  36954. /**
  36955. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36956. */
  36957. axisControlRadius: boolean;
  36958. /**
  36959. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36960. */
  36961. axisControlHeight: boolean;
  36962. /**
  36963. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36964. */
  36965. axisControlRotation: boolean;
  36966. /**
  36967. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36968. * relation to mouseWheel events.
  36969. */
  36970. wheelPrecision: number;
  36971. /**
  36972. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36973. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36974. */
  36975. wheelDeltaPercentage: number;
  36976. private _wheel;
  36977. private _observer;
  36978. /**
  36979. * Attach the input controls to a specific dom element to get the input from.
  36980. * @param element Defines the element the controls should be listened from
  36981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36982. */
  36983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36984. /**
  36985. * Detach the current controls from the specified dom element.
  36986. * @param element Defines the element to stop listening the inputs from
  36987. */
  36988. detachControl(element: Nullable<HTMLElement>): void;
  36989. /**
  36990. * Gets the class name of the current intput.
  36991. * @returns the class name
  36992. */
  36993. getClassName(): string;
  36994. /**
  36995. * Get the friendly name associated with the input class.
  36996. * @returns the input friendly name
  36997. */
  36998. getSimpleName(): string;
  36999. }
  37000. }
  37001. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37002. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37003. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37004. /**
  37005. * Default Inputs manager for the FollowCamera.
  37006. * It groups all the default supported inputs for ease of use.
  37007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37008. */
  37009. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37010. /**
  37011. * Instantiates a new FollowCameraInputsManager.
  37012. * @param camera Defines the camera the inputs belong to
  37013. */
  37014. constructor(camera: FollowCamera);
  37015. /**
  37016. * Add keyboard input support to the input manager.
  37017. * @returns the current input manager
  37018. */
  37019. addKeyboard(): FollowCameraInputsManager;
  37020. /**
  37021. * Add mouse wheel input support to the input manager.
  37022. * @returns the current input manager
  37023. */
  37024. addMouseWheel(): FollowCameraInputsManager;
  37025. /**
  37026. * Add pointers input support to the input manager.
  37027. * @returns the current input manager
  37028. */
  37029. addPointers(): FollowCameraInputsManager;
  37030. /**
  37031. * Add orientation input support to the input manager.
  37032. * @returns the current input manager
  37033. */
  37034. addVRDeviceOrientation(): FollowCameraInputsManager;
  37035. }
  37036. }
  37037. declare module "babylonjs/Cameras/followCamera" {
  37038. import { Nullable } from "babylonjs/types";
  37039. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37040. import { Scene } from "babylonjs/scene";
  37041. import { Vector3 } from "babylonjs/Maths/math";
  37042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37043. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37044. /**
  37045. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37046. * an arc rotate version arcFollowCamera are available.
  37047. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37048. */
  37049. export class FollowCamera extends TargetCamera {
  37050. /**
  37051. * Distance the follow camera should follow an object at
  37052. */
  37053. radius: number;
  37054. /**
  37055. * Minimum allowed distance of the camera to the axis of rotation
  37056. * (The camera can not get closer).
  37057. * This can help limiting how the Camera is able to move in the scene.
  37058. */
  37059. lowerRadiusLimit: Nullable<number>;
  37060. /**
  37061. * Maximum allowed distance of the camera to the axis of rotation
  37062. * (The camera can not get further).
  37063. * This can help limiting how the Camera is able to move in the scene.
  37064. */
  37065. upperRadiusLimit: Nullable<number>;
  37066. /**
  37067. * Define a rotation offset between the camera and the object it follows
  37068. */
  37069. rotationOffset: number;
  37070. /**
  37071. * Minimum allowed angle to camera position relative to target object.
  37072. * This can help limiting how the Camera is able to move in the scene.
  37073. */
  37074. lowerRotationOffsetLimit: Nullable<number>;
  37075. /**
  37076. * Maximum allowed angle to camera position relative to target object.
  37077. * This can help limiting how the Camera is able to move in the scene.
  37078. */
  37079. upperRotationOffsetLimit: Nullable<number>;
  37080. /**
  37081. * Define a height offset between the camera and the object it follows.
  37082. * It can help following an object from the top (like a car chaing a plane)
  37083. */
  37084. heightOffset: number;
  37085. /**
  37086. * Minimum allowed height of camera position relative to target object.
  37087. * This can help limiting how the Camera is able to move in the scene.
  37088. */
  37089. lowerHeightOffsetLimit: Nullable<number>;
  37090. /**
  37091. * Maximum allowed height of camera position relative to target object.
  37092. * This can help limiting how the Camera is able to move in the scene.
  37093. */
  37094. upperHeightOffsetLimit: Nullable<number>;
  37095. /**
  37096. * Define how fast the camera can accelerate to follow it s target.
  37097. */
  37098. cameraAcceleration: number;
  37099. /**
  37100. * Define the speed limit of the camera following an object.
  37101. */
  37102. maxCameraSpeed: number;
  37103. /**
  37104. * Define the target of the camera.
  37105. */
  37106. lockedTarget: Nullable<AbstractMesh>;
  37107. /**
  37108. * Defines the input associated with the camera.
  37109. */
  37110. inputs: FollowCameraInputsManager;
  37111. /**
  37112. * Instantiates the follow camera.
  37113. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37114. * @param name Define the name of the camera in the scene
  37115. * @param position Define the position of the camera
  37116. * @param scene Define the scene the camera belong to
  37117. * @param lockedTarget Define the target of the camera
  37118. */
  37119. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37120. private _follow;
  37121. /**
  37122. * Attached controls to the current camera.
  37123. * @param element Defines the element the controls should be listened from
  37124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37125. */
  37126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37127. /**
  37128. * Detach the current controls from the camera.
  37129. * The camera will stop reacting to inputs.
  37130. * @param element Defines the element to stop listening the inputs from
  37131. */
  37132. detachControl(element: HTMLElement): void;
  37133. /** @hidden */
  37134. _checkInputs(): void;
  37135. private _checkLimits;
  37136. /**
  37137. * Gets the camera class name.
  37138. * @returns the class name
  37139. */
  37140. getClassName(): string;
  37141. }
  37142. /**
  37143. * Arc Rotate version of the follow camera.
  37144. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37145. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37146. */
  37147. export class ArcFollowCamera extends TargetCamera {
  37148. /** The longitudinal angle of the camera */
  37149. alpha: number;
  37150. /** The latitudinal angle of the camera */
  37151. beta: number;
  37152. /** The radius of the camera from its target */
  37153. radius: number;
  37154. /** Define the camera target (the messh it should follow) */
  37155. target: Nullable<AbstractMesh>;
  37156. private _cartesianCoordinates;
  37157. /**
  37158. * Instantiates a new ArcFollowCamera
  37159. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37160. * @param name Define the name of the camera
  37161. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37162. * @param beta Define the rotation angle of the camera around the elevation axis
  37163. * @param radius Define the radius of the camera from its target point
  37164. * @param target Define the target of the camera
  37165. * @param scene Define the scene the camera belongs to
  37166. */
  37167. constructor(name: string,
  37168. /** The longitudinal angle of the camera */
  37169. alpha: number,
  37170. /** The latitudinal angle of the camera */
  37171. beta: number,
  37172. /** The radius of the camera from its target */
  37173. radius: number,
  37174. /** Define the camera target (the messh it should follow) */
  37175. target: Nullable<AbstractMesh>, scene: Scene);
  37176. private _follow;
  37177. /** @hidden */
  37178. _checkInputs(): void;
  37179. /**
  37180. * Returns the class name of the object.
  37181. * It is mostly used internally for serialization purposes.
  37182. */
  37183. getClassName(): string;
  37184. }
  37185. }
  37186. declare module "babylonjs/Cameras/universalCamera" {
  37187. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37188. import { Scene } from "babylonjs/scene";
  37189. import { Vector3 } from "babylonjs/Maths/math";
  37190. /**
  37191. * 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,
  37192. * which still works and will still be found in many Playgrounds.
  37193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37194. */
  37195. export class UniversalCamera extends TouchCamera {
  37196. /**
  37197. * Defines the gamepad rotation sensiblity.
  37198. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37199. */
  37200. gamepadAngularSensibility: number;
  37201. /**
  37202. * Defines the gamepad move sensiblity.
  37203. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37204. */
  37205. gamepadMoveSensibility: number;
  37206. /**
  37207. * 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,
  37208. * which still works and will still be found in many Playgrounds.
  37209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37210. * @param name Define the name of the camera in the scene
  37211. * @param position Define the start position of the camera in the scene
  37212. * @param scene Define the scene the camera belongs to
  37213. */
  37214. constructor(name: string, position: Vector3, scene: Scene);
  37215. /**
  37216. * Gets the current object class name.
  37217. * @return the class name
  37218. */
  37219. getClassName(): string;
  37220. }
  37221. }
  37222. declare module "babylonjs/Cameras/gamepadCamera" {
  37223. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37224. import { Scene } from "babylonjs/scene";
  37225. import { Vector3 } from "babylonjs/Maths/math";
  37226. /**
  37227. * This represents a FPS type of camera. This is only here for back compat purpose.
  37228. * Please use the UniversalCamera instead as both are identical.
  37229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37230. */
  37231. export class GamepadCamera extends UniversalCamera {
  37232. /**
  37233. * Instantiates a new Gamepad Camera
  37234. * This represents a FPS type of camera. This is only here for back compat purpose.
  37235. * Please use the UniversalCamera instead as both are identical.
  37236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37237. * @param name Define the name of the camera in the scene
  37238. * @param position Define the start position of the camera in the scene
  37239. * @param scene Define the scene the camera belongs to
  37240. */
  37241. constructor(name: string, position: Vector3, scene: Scene);
  37242. /**
  37243. * Gets the current object class name.
  37244. * @return the class name
  37245. */
  37246. getClassName(): string;
  37247. }
  37248. }
  37249. declare module "babylonjs/Shaders/pass.fragment" {
  37250. /** @hidden */
  37251. export var passPixelShader: {
  37252. name: string;
  37253. shader: string;
  37254. };
  37255. }
  37256. declare module "babylonjs/Shaders/passCube.fragment" {
  37257. /** @hidden */
  37258. export var passCubePixelShader: {
  37259. name: string;
  37260. shader: string;
  37261. };
  37262. }
  37263. declare module "babylonjs/PostProcesses/passPostProcess" {
  37264. import { Nullable } from "babylonjs/types";
  37265. import { Camera } from "babylonjs/Cameras/camera";
  37266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37267. import { Engine } from "babylonjs/Engines/engine";
  37268. import "babylonjs/Shaders/pass.fragment";
  37269. import "babylonjs/Shaders/passCube.fragment";
  37270. /**
  37271. * PassPostProcess which produces an output the same as it's input
  37272. */
  37273. export class PassPostProcess extends PostProcess {
  37274. /**
  37275. * Creates the PassPostProcess
  37276. * @param name The name of the effect.
  37277. * @param options The required width/height ratio to downsize to before computing the render pass.
  37278. * @param camera The camera to apply the render pass to.
  37279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37280. * @param engine The engine which the post process will be applied. (default: current engine)
  37281. * @param reusable If the post process can be reused on the same frame. (default: false)
  37282. * @param textureType The type of texture to be used when performing the post processing.
  37283. * @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)
  37284. */
  37285. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37286. }
  37287. /**
  37288. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37289. */
  37290. export class PassCubePostProcess extends PostProcess {
  37291. private _face;
  37292. /**
  37293. * Gets or sets the cube face to display.
  37294. * * 0 is +X
  37295. * * 1 is -X
  37296. * * 2 is +Y
  37297. * * 3 is -Y
  37298. * * 4 is +Z
  37299. * * 5 is -Z
  37300. */
  37301. face: number;
  37302. /**
  37303. * Creates the PassCubePostProcess
  37304. * @param name The name of the effect.
  37305. * @param options The required width/height ratio to downsize to before computing the render pass.
  37306. * @param camera The camera to apply the render pass to.
  37307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37308. * @param engine The engine which the post process will be applied. (default: current engine)
  37309. * @param reusable If the post process can be reused on the same frame. (default: false)
  37310. * @param textureType The type of texture to be used when performing the post processing.
  37311. * @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)
  37312. */
  37313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37314. }
  37315. }
  37316. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37317. /** @hidden */
  37318. export var anaglyphPixelShader: {
  37319. name: string;
  37320. shader: string;
  37321. };
  37322. }
  37323. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37324. import { Engine } from "babylonjs/Engines/engine";
  37325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37326. import { Camera } from "babylonjs/Cameras/camera";
  37327. import "babylonjs/Shaders/anaglyph.fragment";
  37328. /**
  37329. * Postprocess used to generate anaglyphic rendering
  37330. */
  37331. export class AnaglyphPostProcess extends PostProcess {
  37332. private _passedProcess;
  37333. /**
  37334. * Creates a new AnaglyphPostProcess
  37335. * @param name defines postprocess name
  37336. * @param options defines creation options or target ratio scale
  37337. * @param rigCameras defines cameras using this postprocess
  37338. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37339. * @param engine defines hosting engine
  37340. * @param reusable defines if the postprocess will be reused multiple times per frame
  37341. */
  37342. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37343. }
  37344. }
  37345. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37346. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37348. import { Scene } from "babylonjs/scene";
  37349. import { Vector3 } from "babylonjs/Maths/math";
  37350. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37351. /**
  37352. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37353. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37354. */
  37355. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37356. /**
  37357. * Creates a new AnaglyphArcRotateCamera
  37358. * @param name defines camera name
  37359. * @param alpha defines alpha angle (in radians)
  37360. * @param beta defines beta angle (in radians)
  37361. * @param radius defines radius
  37362. * @param target defines camera target
  37363. * @param interaxialDistance defines distance between each color axis
  37364. * @param scene defines the hosting scene
  37365. */
  37366. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37367. /**
  37368. * Gets camera class name
  37369. * @returns AnaglyphArcRotateCamera
  37370. */
  37371. getClassName(): string;
  37372. }
  37373. }
  37374. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37375. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37376. import { Scene } from "babylonjs/scene";
  37377. import { Vector3 } from "babylonjs/Maths/math";
  37378. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37379. /**
  37380. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37381. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37382. */
  37383. export class AnaglyphFreeCamera extends FreeCamera {
  37384. /**
  37385. * Creates a new AnaglyphFreeCamera
  37386. * @param name defines camera name
  37387. * @param position defines initial position
  37388. * @param interaxialDistance defines distance between each color axis
  37389. * @param scene defines the hosting scene
  37390. */
  37391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37392. /**
  37393. * Gets camera class name
  37394. * @returns AnaglyphFreeCamera
  37395. */
  37396. getClassName(): string;
  37397. }
  37398. }
  37399. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37400. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37401. import { Scene } from "babylonjs/scene";
  37402. import { Vector3 } from "babylonjs/Maths/math";
  37403. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37404. /**
  37405. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37407. */
  37408. export class AnaglyphGamepadCamera extends GamepadCamera {
  37409. /**
  37410. * Creates a new AnaglyphGamepadCamera
  37411. * @param name defines camera name
  37412. * @param position defines initial position
  37413. * @param interaxialDistance defines distance between each color axis
  37414. * @param scene defines the hosting scene
  37415. */
  37416. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37417. /**
  37418. * Gets camera class name
  37419. * @returns AnaglyphGamepadCamera
  37420. */
  37421. getClassName(): string;
  37422. }
  37423. }
  37424. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37425. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37426. import { Scene } from "babylonjs/scene";
  37427. import { Vector3 } from "babylonjs/Maths/math";
  37428. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37429. /**
  37430. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37431. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37432. */
  37433. export class AnaglyphUniversalCamera extends UniversalCamera {
  37434. /**
  37435. * Creates a new AnaglyphUniversalCamera
  37436. * @param name defines camera name
  37437. * @param position defines initial position
  37438. * @param interaxialDistance defines distance between each color axis
  37439. * @param scene defines the hosting scene
  37440. */
  37441. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37442. /**
  37443. * Gets camera class name
  37444. * @returns AnaglyphUniversalCamera
  37445. */
  37446. getClassName(): string;
  37447. }
  37448. }
  37449. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37450. /** @hidden */
  37451. export var stereoscopicInterlacePixelShader: {
  37452. name: string;
  37453. shader: string;
  37454. };
  37455. }
  37456. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37457. import { Camera } from "babylonjs/Cameras/camera";
  37458. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37459. import { Engine } from "babylonjs/Engines/engine";
  37460. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37461. /**
  37462. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37463. */
  37464. export class StereoscopicInterlacePostProcess extends PostProcess {
  37465. private _stepSize;
  37466. private _passedProcess;
  37467. /**
  37468. * Initializes a StereoscopicInterlacePostProcess
  37469. * @param name The name of the effect.
  37470. * @param rigCameras The rig cameras to be appled to the post process
  37471. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37473. * @param engine The engine which the post process will be applied. (default: current engine)
  37474. * @param reusable If the post process can be reused on the same frame. (default: false)
  37475. */
  37476. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37477. }
  37478. }
  37479. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37480. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37481. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37482. import { Scene } from "babylonjs/scene";
  37483. import { Vector3 } from "babylonjs/Maths/math";
  37484. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37485. /**
  37486. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37487. * @see http://doc.babylonjs.com/features/cameras
  37488. */
  37489. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37490. /**
  37491. * Creates a new StereoscopicArcRotateCamera
  37492. * @param name defines camera name
  37493. * @param alpha defines alpha angle (in radians)
  37494. * @param beta defines beta angle (in radians)
  37495. * @param radius defines radius
  37496. * @param target defines camera target
  37497. * @param interaxialDistance defines distance between each color axis
  37498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37499. * @param scene defines the hosting scene
  37500. */
  37501. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37502. /**
  37503. * Gets camera class name
  37504. * @returns StereoscopicArcRotateCamera
  37505. */
  37506. getClassName(): string;
  37507. }
  37508. }
  37509. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37511. import { Scene } from "babylonjs/scene";
  37512. import { Vector3 } from "babylonjs/Maths/math";
  37513. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37514. /**
  37515. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37516. * @see http://doc.babylonjs.com/features/cameras
  37517. */
  37518. export class StereoscopicFreeCamera extends FreeCamera {
  37519. /**
  37520. * Creates a new StereoscopicFreeCamera
  37521. * @param name defines camera name
  37522. * @param position defines initial position
  37523. * @param interaxialDistance defines distance between each color axis
  37524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37525. * @param scene defines the hosting scene
  37526. */
  37527. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37528. /**
  37529. * Gets camera class name
  37530. * @returns StereoscopicFreeCamera
  37531. */
  37532. getClassName(): string;
  37533. }
  37534. }
  37535. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37536. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37537. import { Scene } from "babylonjs/scene";
  37538. import { Vector3 } from "babylonjs/Maths/math";
  37539. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37540. /**
  37541. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37542. * @see http://doc.babylonjs.com/features/cameras
  37543. */
  37544. export class StereoscopicGamepadCamera extends GamepadCamera {
  37545. /**
  37546. * Creates a new StereoscopicGamepadCamera
  37547. * @param name defines camera name
  37548. * @param position defines initial position
  37549. * @param interaxialDistance defines distance between each color axis
  37550. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37551. * @param scene defines the hosting scene
  37552. */
  37553. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37554. /**
  37555. * Gets camera class name
  37556. * @returns StereoscopicGamepadCamera
  37557. */
  37558. getClassName(): string;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37562. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37566. /**
  37567. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37568. * @see http://doc.babylonjs.com/features/cameras
  37569. */
  37570. export class StereoscopicUniversalCamera extends UniversalCamera {
  37571. /**
  37572. * Creates a new StereoscopicUniversalCamera
  37573. * @param name defines camera name
  37574. * @param position defines initial position
  37575. * @param interaxialDistance defines distance between each color axis
  37576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37577. * @param scene defines the hosting scene
  37578. */
  37579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37580. /**
  37581. * Gets camera class name
  37582. * @returns StereoscopicUniversalCamera
  37583. */
  37584. getClassName(): string;
  37585. }
  37586. }
  37587. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37588. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37591. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37592. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37595. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37596. }
  37597. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37598. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37599. import { Scene } from "babylonjs/scene";
  37600. import { Vector3 } from "babylonjs/Maths/math";
  37601. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37602. /**
  37603. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37604. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37605. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37606. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37607. */
  37608. export class VirtualJoysticksCamera extends FreeCamera {
  37609. /**
  37610. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37611. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37612. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37613. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37614. * @param name Define the name of the camera in the scene
  37615. * @param position Define the start position of the camera in the scene
  37616. * @param scene Define the scene the camera belongs to
  37617. */
  37618. constructor(name: string, position: Vector3, scene: Scene);
  37619. /**
  37620. * Gets the current object class name.
  37621. * @return the class name
  37622. */
  37623. getClassName(): string;
  37624. }
  37625. }
  37626. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37627. import { Matrix } from "babylonjs/Maths/math";
  37628. /**
  37629. * This represents all the required metrics to create a VR camera.
  37630. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37631. */
  37632. export class VRCameraMetrics {
  37633. /**
  37634. * Define the horizontal resolution off the screen.
  37635. */
  37636. hResolution: number;
  37637. /**
  37638. * Define the vertical resolution off the screen.
  37639. */
  37640. vResolution: number;
  37641. /**
  37642. * Define the horizontal screen size.
  37643. */
  37644. hScreenSize: number;
  37645. /**
  37646. * Define the vertical screen size.
  37647. */
  37648. vScreenSize: number;
  37649. /**
  37650. * Define the vertical screen center position.
  37651. */
  37652. vScreenCenter: number;
  37653. /**
  37654. * Define the distance of the eyes to the screen.
  37655. */
  37656. eyeToScreenDistance: number;
  37657. /**
  37658. * Define the distance between both lenses
  37659. */
  37660. lensSeparationDistance: number;
  37661. /**
  37662. * Define the distance between both viewer's eyes.
  37663. */
  37664. interpupillaryDistance: number;
  37665. /**
  37666. * Define the distortion factor of the VR postprocess.
  37667. * Please, touch with care.
  37668. */
  37669. distortionK: number[];
  37670. /**
  37671. * Define the chromatic aberration correction factors for the VR post process.
  37672. */
  37673. chromaAbCorrection: number[];
  37674. /**
  37675. * Define the scale factor of the post process.
  37676. * The smaller the better but the slower.
  37677. */
  37678. postProcessScaleFactor: number;
  37679. /**
  37680. * Define an offset for the lens center.
  37681. */
  37682. lensCenterOffset: number;
  37683. /**
  37684. * Define if the current vr camera should compensate the distortion of the lense or not.
  37685. */
  37686. compensateDistortion: boolean;
  37687. /**
  37688. * Gets the rendering aspect ratio based on the provided resolutions.
  37689. */
  37690. readonly aspectRatio: number;
  37691. /**
  37692. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37693. */
  37694. readonly aspectRatioFov: number;
  37695. /**
  37696. * @hidden
  37697. */
  37698. readonly leftHMatrix: Matrix;
  37699. /**
  37700. * @hidden
  37701. */
  37702. readonly rightHMatrix: Matrix;
  37703. /**
  37704. * @hidden
  37705. */
  37706. readonly leftPreViewMatrix: Matrix;
  37707. /**
  37708. * @hidden
  37709. */
  37710. readonly rightPreViewMatrix: Matrix;
  37711. /**
  37712. * Get the default VRMetrics based on the most generic setup.
  37713. * @returns the default vr metrics
  37714. */
  37715. static GetDefault(): VRCameraMetrics;
  37716. }
  37717. }
  37718. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37719. /** @hidden */
  37720. export var vrDistortionCorrectionPixelShader: {
  37721. name: string;
  37722. shader: string;
  37723. };
  37724. }
  37725. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37726. import { Camera } from "babylonjs/Cameras/camera";
  37727. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37729. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37730. /**
  37731. * VRDistortionCorrectionPostProcess used for mobile VR
  37732. */
  37733. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37734. private _isRightEye;
  37735. private _distortionFactors;
  37736. private _postProcessScaleFactor;
  37737. private _lensCenterOffset;
  37738. private _scaleIn;
  37739. private _scaleFactor;
  37740. private _lensCenter;
  37741. /**
  37742. * Initializes the VRDistortionCorrectionPostProcess
  37743. * @param name The name of the effect.
  37744. * @param camera The camera to apply the render pass to.
  37745. * @param isRightEye If this is for the right eye distortion
  37746. * @param vrMetrics All the required metrics for the VR camera
  37747. */
  37748. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37749. }
  37750. }
  37751. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37752. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37754. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37755. import { Scene } from "babylonjs/scene";
  37756. import { Vector3 } from "babylonjs/Maths/math";
  37757. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37758. import "babylonjs/Cameras/RigModes/vrRigMode";
  37759. /**
  37760. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37761. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37762. */
  37763. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37764. /**
  37765. * Creates a new VRDeviceOrientationArcRotateCamera
  37766. * @param name defines camera name
  37767. * @param alpha defines the camera rotation along the logitudinal axis
  37768. * @param beta defines the camera rotation along the latitudinal axis
  37769. * @param radius defines the camera distance from its target
  37770. * @param target defines the camera target
  37771. * @param scene defines the scene the camera belongs to
  37772. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37773. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37774. */
  37775. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37776. /**
  37777. * Gets camera class name
  37778. * @returns VRDeviceOrientationArcRotateCamera
  37779. */
  37780. getClassName(): string;
  37781. }
  37782. }
  37783. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37784. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37785. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37786. import { Scene } from "babylonjs/scene";
  37787. import { Vector3 } from "babylonjs/Maths/math";
  37788. import "babylonjs/Cameras/RigModes/vrRigMode";
  37789. /**
  37790. * Camera used to simulate VR rendering (based on FreeCamera)
  37791. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37792. */
  37793. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37794. /**
  37795. * Creates a new VRDeviceOrientationFreeCamera
  37796. * @param name defines camera name
  37797. * @param position defines the start position of the camera
  37798. * @param scene defines the scene the camera belongs to
  37799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37801. */
  37802. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37803. /**
  37804. * Gets camera class name
  37805. * @returns VRDeviceOrientationFreeCamera
  37806. */
  37807. getClassName(): string;
  37808. }
  37809. }
  37810. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37811. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37812. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37813. import { Scene } from "babylonjs/scene";
  37814. import { Vector3 } from "babylonjs/Maths/math";
  37815. /**
  37816. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37817. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37818. */
  37819. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37820. /**
  37821. * Creates a new VRDeviceOrientationGamepadCamera
  37822. * @param name defines camera name
  37823. * @param position defines the start position of the camera
  37824. * @param scene defines the scene the camera belongs to
  37825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37827. */
  37828. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37829. /**
  37830. * Gets camera class name
  37831. * @returns VRDeviceOrientationGamepadCamera
  37832. */
  37833. getClassName(): string;
  37834. }
  37835. }
  37836. declare module "babylonjs/Gamepads/xboxGamepad" {
  37837. import { Observable } from "babylonjs/Misc/observable";
  37838. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37839. /**
  37840. * Defines supported buttons for XBox360 compatible gamepads
  37841. */
  37842. export enum Xbox360Button {
  37843. /** A */
  37844. A = 0,
  37845. /** B */
  37846. B = 1,
  37847. /** X */
  37848. X = 2,
  37849. /** Y */
  37850. Y = 3,
  37851. /** Start */
  37852. Start = 4,
  37853. /** Back */
  37854. Back = 5,
  37855. /** Left button */
  37856. LB = 6,
  37857. /** Right button */
  37858. RB = 7,
  37859. /** Left stick */
  37860. LeftStick = 8,
  37861. /** Right stick */
  37862. RightStick = 9
  37863. }
  37864. /** Defines values for XBox360 DPad */
  37865. export enum Xbox360Dpad {
  37866. /** Up */
  37867. Up = 0,
  37868. /** Down */
  37869. Down = 1,
  37870. /** Left */
  37871. Left = 2,
  37872. /** Right */
  37873. Right = 3
  37874. }
  37875. /**
  37876. * Defines a XBox360 gamepad
  37877. */
  37878. export class Xbox360Pad extends Gamepad {
  37879. private _leftTrigger;
  37880. private _rightTrigger;
  37881. private _onlefttriggerchanged;
  37882. private _onrighttriggerchanged;
  37883. private _onbuttondown;
  37884. private _onbuttonup;
  37885. private _ondpaddown;
  37886. private _ondpadup;
  37887. /** Observable raised when a button is pressed */
  37888. onButtonDownObservable: Observable<Xbox360Button>;
  37889. /** Observable raised when a button is released */
  37890. onButtonUpObservable: Observable<Xbox360Button>;
  37891. /** Observable raised when a pad is pressed */
  37892. onPadDownObservable: Observable<Xbox360Dpad>;
  37893. /** Observable raised when a pad is released */
  37894. onPadUpObservable: Observable<Xbox360Dpad>;
  37895. private _buttonA;
  37896. private _buttonB;
  37897. private _buttonX;
  37898. private _buttonY;
  37899. private _buttonBack;
  37900. private _buttonStart;
  37901. private _buttonLB;
  37902. private _buttonRB;
  37903. private _buttonLeftStick;
  37904. private _buttonRightStick;
  37905. private _dPadUp;
  37906. private _dPadDown;
  37907. private _dPadLeft;
  37908. private _dPadRight;
  37909. private _isXboxOnePad;
  37910. /**
  37911. * Creates a new XBox360 gamepad object
  37912. * @param id defines the id of this gamepad
  37913. * @param index defines its index
  37914. * @param gamepad defines the internal HTML gamepad object
  37915. * @param xboxOne defines if it is a XBox One gamepad
  37916. */
  37917. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37918. /**
  37919. * Defines the callback to call when left trigger is pressed
  37920. * @param callback defines the callback to use
  37921. */
  37922. onlefttriggerchanged(callback: (value: number) => void): void;
  37923. /**
  37924. * Defines the callback to call when right trigger is pressed
  37925. * @param callback defines the callback to use
  37926. */
  37927. onrighttriggerchanged(callback: (value: number) => void): void;
  37928. /**
  37929. * Gets the left trigger value
  37930. */
  37931. /**
  37932. * Sets the left trigger value
  37933. */
  37934. leftTrigger: number;
  37935. /**
  37936. * Gets the right trigger value
  37937. */
  37938. /**
  37939. * Sets the right trigger value
  37940. */
  37941. rightTrigger: number;
  37942. /**
  37943. * Defines the callback to call when a button is pressed
  37944. * @param callback defines the callback to use
  37945. */
  37946. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37947. /**
  37948. * Defines the callback to call when a button is released
  37949. * @param callback defines the callback to use
  37950. */
  37951. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37952. /**
  37953. * Defines the callback to call when a pad is pressed
  37954. * @param callback defines the callback to use
  37955. */
  37956. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37957. /**
  37958. * Defines the callback to call when a pad is released
  37959. * @param callback defines the callback to use
  37960. */
  37961. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37962. private _setButtonValue;
  37963. private _setDPadValue;
  37964. /**
  37965. * Gets the value of the `A` button
  37966. */
  37967. /**
  37968. * Sets the value of the `A` button
  37969. */
  37970. buttonA: number;
  37971. /**
  37972. * Gets the value of the `B` button
  37973. */
  37974. /**
  37975. * Sets the value of the `B` button
  37976. */
  37977. buttonB: number;
  37978. /**
  37979. * Gets the value of the `X` button
  37980. */
  37981. /**
  37982. * Sets the value of the `X` button
  37983. */
  37984. buttonX: number;
  37985. /**
  37986. * Gets the value of the `Y` button
  37987. */
  37988. /**
  37989. * Sets the value of the `Y` button
  37990. */
  37991. buttonY: number;
  37992. /**
  37993. * Gets the value of the `Start` button
  37994. */
  37995. /**
  37996. * Sets the value of the `Start` button
  37997. */
  37998. buttonStart: number;
  37999. /**
  38000. * Gets the value of the `Back` button
  38001. */
  38002. /**
  38003. * Sets the value of the `Back` button
  38004. */
  38005. buttonBack: number;
  38006. /**
  38007. * Gets the value of the `Left` button
  38008. */
  38009. /**
  38010. * Sets the value of the `Left` button
  38011. */
  38012. buttonLB: number;
  38013. /**
  38014. * Gets the value of the `Right` button
  38015. */
  38016. /**
  38017. * Sets the value of the `Right` button
  38018. */
  38019. buttonRB: number;
  38020. /**
  38021. * Gets the value of the Left joystick
  38022. */
  38023. /**
  38024. * Sets the value of the Left joystick
  38025. */
  38026. buttonLeftStick: number;
  38027. /**
  38028. * Gets the value of the Right joystick
  38029. */
  38030. /**
  38031. * Sets the value of the Right joystick
  38032. */
  38033. buttonRightStick: number;
  38034. /**
  38035. * Gets the value of D-pad up
  38036. */
  38037. /**
  38038. * Sets the value of D-pad up
  38039. */
  38040. dPadUp: number;
  38041. /**
  38042. * Gets the value of D-pad down
  38043. */
  38044. /**
  38045. * Sets the value of D-pad down
  38046. */
  38047. dPadDown: number;
  38048. /**
  38049. * Gets the value of D-pad left
  38050. */
  38051. /**
  38052. * Sets the value of D-pad left
  38053. */
  38054. dPadLeft: number;
  38055. /**
  38056. * Gets the value of D-pad right
  38057. */
  38058. /**
  38059. * Sets the value of D-pad right
  38060. */
  38061. dPadRight: number;
  38062. /**
  38063. * Force the gamepad to synchronize with device values
  38064. */
  38065. update(): void;
  38066. /**
  38067. * Disposes the gamepad
  38068. */
  38069. dispose(): void;
  38070. }
  38071. }
  38072. declare module "babylonjs/Materials/pushMaterial" {
  38073. import { Nullable } from "babylonjs/types";
  38074. import { Scene } from "babylonjs/scene";
  38075. import { Matrix } from "babylonjs/Maths/math";
  38076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38077. import { Mesh } from "babylonjs/Meshes/mesh";
  38078. import { Material } from "babylonjs/Materials/material";
  38079. import { Effect } from "babylonjs/Materials/effect";
  38080. /**
  38081. * Base class of materials working in push mode in babylon JS
  38082. * @hidden
  38083. */
  38084. export class PushMaterial extends Material {
  38085. protected _activeEffect: Effect;
  38086. protected _normalMatrix: Matrix;
  38087. /**
  38088. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38089. * This means that the material can keep using a previous shader while a new one is being compiled.
  38090. * This is mostly used when shader parallel compilation is supported (true by default)
  38091. */
  38092. allowShaderHotSwapping: boolean;
  38093. constructor(name: string, scene: Scene);
  38094. getEffect(): Effect;
  38095. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38096. /**
  38097. * Binds the given world matrix to the active effect
  38098. *
  38099. * @param world the matrix to bind
  38100. */
  38101. bindOnlyWorldMatrix(world: Matrix): void;
  38102. /**
  38103. * Binds the given normal matrix to the active effect
  38104. *
  38105. * @param normalMatrix the matrix to bind
  38106. */
  38107. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38108. bind(world: Matrix, mesh?: Mesh): void;
  38109. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38110. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38111. }
  38112. }
  38113. declare module "babylonjs/Materials/materialFlags" {
  38114. /**
  38115. * This groups all the flags used to control the materials channel.
  38116. */
  38117. export class MaterialFlags {
  38118. private static _DiffuseTextureEnabled;
  38119. /**
  38120. * Are diffuse textures enabled in the application.
  38121. */
  38122. static DiffuseTextureEnabled: boolean;
  38123. private static _AmbientTextureEnabled;
  38124. /**
  38125. * Are ambient textures enabled in the application.
  38126. */
  38127. static AmbientTextureEnabled: boolean;
  38128. private static _OpacityTextureEnabled;
  38129. /**
  38130. * Are opacity textures enabled in the application.
  38131. */
  38132. static OpacityTextureEnabled: boolean;
  38133. private static _ReflectionTextureEnabled;
  38134. /**
  38135. * Are reflection textures enabled in the application.
  38136. */
  38137. static ReflectionTextureEnabled: boolean;
  38138. private static _EmissiveTextureEnabled;
  38139. /**
  38140. * Are emissive textures enabled in the application.
  38141. */
  38142. static EmissiveTextureEnabled: boolean;
  38143. private static _SpecularTextureEnabled;
  38144. /**
  38145. * Are specular textures enabled in the application.
  38146. */
  38147. static SpecularTextureEnabled: boolean;
  38148. private static _BumpTextureEnabled;
  38149. /**
  38150. * Are bump textures enabled in the application.
  38151. */
  38152. static BumpTextureEnabled: boolean;
  38153. private static _LightmapTextureEnabled;
  38154. /**
  38155. * Are lightmap textures enabled in the application.
  38156. */
  38157. static LightmapTextureEnabled: boolean;
  38158. private static _RefractionTextureEnabled;
  38159. /**
  38160. * Are refraction textures enabled in the application.
  38161. */
  38162. static RefractionTextureEnabled: boolean;
  38163. private static _ColorGradingTextureEnabled;
  38164. /**
  38165. * Are color grading textures enabled in the application.
  38166. */
  38167. static ColorGradingTextureEnabled: boolean;
  38168. private static _FresnelEnabled;
  38169. /**
  38170. * Are fresnels enabled in the application.
  38171. */
  38172. static FresnelEnabled: boolean;
  38173. }
  38174. }
  38175. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38176. /** @hidden */
  38177. export var defaultFragmentDeclaration: {
  38178. name: string;
  38179. shader: string;
  38180. };
  38181. }
  38182. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38183. /** @hidden */
  38184. export var defaultUboDeclaration: {
  38185. name: string;
  38186. shader: string;
  38187. };
  38188. }
  38189. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38190. /** @hidden */
  38191. export var lightFragmentDeclaration: {
  38192. name: string;
  38193. shader: string;
  38194. };
  38195. }
  38196. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38197. /** @hidden */
  38198. export var lightUboDeclaration: {
  38199. name: string;
  38200. shader: string;
  38201. };
  38202. }
  38203. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38204. /** @hidden */
  38205. export var lightsFragmentFunctions: {
  38206. name: string;
  38207. shader: string;
  38208. };
  38209. }
  38210. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38211. /** @hidden */
  38212. export var shadowsFragmentFunctions: {
  38213. name: string;
  38214. shader: string;
  38215. };
  38216. }
  38217. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38218. /** @hidden */
  38219. export var fresnelFunction: {
  38220. name: string;
  38221. shader: string;
  38222. };
  38223. }
  38224. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38225. /** @hidden */
  38226. export var reflectionFunction: {
  38227. name: string;
  38228. shader: string;
  38229. };
  38230. }
  38231. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38232. /** @hidden */
  38233. export var bumpFragmentFunctions: {
  38234. name: string;
  38235. shader: string;
  38236. };
  38237. }
  38238. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38239. /** @hidden */
  38240. export var logDepthDeclaration: {
  38241. name: string;
  38242. shader: string;
  38243. };
  38244. }
  38245. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38246. /** @hidden */
  38247. export var bumpFragment: {
  38248. name: string;
  38249. shader: string;
  38250. };
  38251. }
  38252. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38253. /** @hidden */
  38254. export var depthPrePass: {
  38255. name: string;
  38256. shader: string;
  38257. };
  38258. }
  38259. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38260. /** @hidden */
  38261. export var lightFragment: {
  38262. name: string;
  38263. shader: string;
  38264. };
  38265. }
  38266. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38267. /** @hidden */
  38268. export var logDepthFragment: {
  38269. name: string;
  38270. shader: string;
  38271. };
  38272. }
  38273. declare module "babylonjs/Shaders/default.fragment" {
  38274. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38275. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38276. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38277. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38278. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38279. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38280. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38281. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38282. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38284. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38285. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38287. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38288. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38290. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38291. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38292. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38293. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38294. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38295. /** @hidden */
  38296. export var defaultPixelShader: {
  38297. name: string;
  38298. shader: string;
  38299. };
  38300. }
  38301. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38302. /** @hidden */
  38303. export var defaultVertexDeclaration: {
  38304. name: string;
  38305. shader: string;
  38306. };
  38307. }
  38308. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38309. /** @hidden */
  38310. export var bumpVertexDeclaration: {
  38311. name: string;
  38312. shader: string;
  38313. };
  38314. }
  38315. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38316. /** @hidden */
  38317. export var bumpVertex: {
  38318. name: string;
  38319. shader: string;
  38320. };
  38321. }
  38322. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38323. /** @hidden */
  38324. export var fogVertex: {
  38325. name: string;
  38326. shader: string;
  38327. };
  38328. }
  38329. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38330. /** @hidden */
  38331. export var shadowsVertex: {
  38332. name: string;
  38333. shader: string;
  38334. };
  38335. }
  38336. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38337. /** @hidden */
  38338. export var pointCloudVertex: {
  38339. name: string;
  38340. shader: string;
  38341. };
  38342. }
  38343. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38344. /** @hidden */
  38345. export var logDepthVertex: {
  38346. name: string;
  38347. shader: string;
  38348. };
  38349. }
  38350. declare module "babylonjs/Shaders/default.vertex" {
  38351. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38352. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38353. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38354. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38355. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38356. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38358. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38359. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38360. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38363. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38364. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38365. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38366. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38367. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38368. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38369. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38370. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38371. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38372. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38373. /** @hidden */
  38374. export var defaultVertexShader: {
  38375. name: string;
  38376. shader: string;
  38377. };
  38378. }
  38379. declare module "babylonjs/Materials/standardMaterial" {
  38380. import { SmartArray } from "babylonjs/Misc/smartArray";
  38381. import { IAnimatable } from "babylonjs/Misc/tools";
  38382. import { Nullable } from "babylonjs/types";
  38383. import { Scene } from "babylonjs/scene";
  38384. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38387. import { Mesh } from "babylonjs/Meshes/mesh";
  38388. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38389. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38390. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38391. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38392. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38395. import "babylonjs/Shaders/default.fragment";
  38396. import "babylonjs/Shaders/default.vertex";
  38397. /** @hidden */
  38398. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38399. MAINUV1: boolean;
  38400. MAINUV2: boolean;
  38401. DIFFUSE: boolean;
  38402. DIFFUSEDIRECTUV: number;
  38403. AMBIENT: boolean;
  38404. AMBIENTDIRECTUV: number;
  38405. OPACITY: boolean;
  38406. OPACITYDIRECTUV: number;
  38407. OPACITYRGB: boolean;
  38408. REFLECTION: boolean;
  38409. EMISSIVE: boolean;
  38410. EMISSIVEDIRECTUV: number;
  38411. SPECULAR: boolean;
  38412. SPECULARDIRECTUV: number;
  38413. BUMP: boolean;
  38414. BUMPDIRECTUV: number;
  38415. PARALLAX: boolean;
  38416. PARALLAXOCCLUSION: boolean;
  38417. SPECULAROVERALPHA: boolean;
  38418. CLIPPLANE: boolean;
  38419. CLIPPLANE2: boolean;
  38420. CLIPPLANE3: boolean;
  38421. CLIPPLANE4: boolean;
  38422. ALPHATEST: boolean;
  38423. DEPTHPREPASS: boolean;
  38424. ALPHAFROMDIFFUSE: boolean;
  38425. POINTSIZE: boolean;
  38426. FOG: boolean;
  38427. SPECULARTERM: boolean;
  38428. DIFFUSEFRESNEL: boolean;
  38429. OPACITYFRESNEL: boolean;
  38430. REFLECTIONFRESNEL: boolean;
  38431. REFRACTIONFRESNEL: boolean;
  38432. EMISSIVEFRESNEL: boolean;
  38433. FRESNEL: boolean;
  38434. NORMAL: boolean;
  38435. UV1: boolean;
  38436. UV2: boolean;
  38437. VERTEXCOLOR: boolean;
  38438. VERTEXALPHA: boolean;
  38439. NUM_BONE_INFLUENCERS: number;
  38440. BonesPerMesh: number;
  38441. BONETEXTURE: boolean;
  38442. INSTANCES: boolean;
  38443. GLOSSINESS: boolean;
  38444. ROUGHNESS: boolean;
  38445. EMISSIVEASILLUMINATION: boolean;
  38446. LINKEMISSIVEWITHDIFFUSE: boolean;
  38447. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38448. LIGHTMAP: boolean;
  38449. LIGHTMAPDIRECTUV: number;
  38450. OBJECTSPACE_NORMALMAP: boolean;
  38451. USELIGHTMAPASSHADOWMAP: boolean;
  38452. REFLECTIONMAP_3D: boolean;
  38453. REFLECTIONMAP_SPHERICAL: boolean;
  38454. REFLECTIONMAP_PLANAR: boolean;
  38455. REFLECTIONMAP_CUBIC: boolean;
  38456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38457. REFLECTIONMAP_PROJECTION: boolean;
  38458. REFLECTIONMAP_SKYBOX: boolean;
  38459. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38460. REFLECTIONMAP_EXPLICIT: boolean;
  38461. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38462. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38463. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38464. INVERTCUBICMAP: boolean;
  38465. LOGARITHMICDEPTH: boolean;
  38466. REFRACTION: boolean;
  38467. REFRACTIONMAP_3D: boolean;
  38468. REFLECTIONOVERALPHA: boolean;
  38469. TWOSIDEDLIGHTING: boolean;
  38470. SHADOWFLOAT: boolean;
  38471. MORPHTARGETS: boolean;
  38472. MORPHTARGETS_NORMAL: boolean;
  38473. MORPHTARGETS_TANGENT: boolean;
  38474. NUM_MORPH_INFLUENCERS: number;
  38475. NONUNIFORMSCALING: boolean;
  38476. PREMULTIPLYALPHA: boolean;
  38477. IMAGEPROCESSING: boolean;
  38478. VIGNETTE: boolean;
  38479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38480. VIGNETTEBLENDMODEOPAQUE: boolean;
  38481. TONEMAPPING: boolean;
  38482. TONEMAPPING_ACES: boolean;
  38483. CONTRAST: boolean;
  38484. COLORCURVES: boolean;
  38485. COLORGRADING: boolean;
  38486. COLORGRADING3D: boolean;
  38487. SAMPLER3DGREENDEPTH: boolean;
  38488. SAMPLER3DBGRMAP: boolean;
  38489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38490. /**
  38491. * If the reflection texture on this material is in linear color space
  38492. * @hidden
  38493. */
  38494. IS_REFLECTION_LINEAR: boolean;
  38495. /**
  38496. * If the refraction texture on this material is in linear color space
  38497. * @hidden
  38498. */
  38499. IS_REFRACTION_LINEAR: boolean;
  38500. EXPOSURE: boolean;
  38501. constructor();
  38502. setReflectionMode(modeToEnable: string): void;
  38503. }
  38504. /**
  38505. * This is the default material used in Babylon. It is the best trade off between quality
  38506. * and performances.
  38507. * @see http://doc.babylonjs.com/babylon101/materials
  38508. */
  38509. export class StandardMaterial extends PushMaterial {
  38510. private _diffuseTexture;
  38511. /**
  38512. * The basic texture of the material as viewed under a light.
  38513. */
  38514. diffuseTexture: Nullable<BaseTexture>;
  38515. private _ambientTexture;
  38516. /**
  38517. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38518. */
  38519. ambientTexture: Nullable<BaseTexture>;
  38520. private _opacityTexture;
  38521. /**
  38522. * Define the transparency of the material from a texture.
  38523. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38524. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38525. */
  38526. opacityTexture: Nullable<BaseTexture>;
  38527. private _reflectionTexture;
  38528. /**
  38529. * Define the texture used to display the reflection.
  38530. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38531. */
  38532. reflectionTexture: Nullable<BaseTexture>;
  38533. private _emissiveTexture;
  38534. /**
  38535. * Define texture of the material as if self lit.
  38536. * This will be mixed in the final result even in the absence of light.
  38537. */
  38538. emissiveTexture: Nullable<BaseTexture>;
  38539. private _specularTexture;
  38540. /**
  38541. * Define how the color and intensity of the highlight given by the light in the material.
  38542. */
  38543. specularTexture: Nullable<BaseTexture>;
  38544. private _bumpTexture;
  38545. /**
  38546. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38547. * 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.
  38548. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38549. */
  38550. bumpTexture: Nullable<BaseTexture>;
  38551. private _lightmapTexture;
  38552. /**
  38553. * Complex lighting can be computationally expensive to compute at runtime.
  38554. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38555. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38556. */
  38557. lightmapTexture: Nullable<BaseTexture>;
  38558. private _refractionTexture;
  38559. /**
  38560. * Define the texture used to display the refraction.
  38561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38562. */
  38563. refractionTexture: Nullable<BaseTexture>;
  38564. /**
  38565. * The color of the material lit by the environmental background lighting.
  38566. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38567. */
  38568. ambientColor: Color3;
  38569. /**
  38570. * The basic color of the material as viewed under a light.
  38571. */
  38572. diffuseColor: Color3;
  38573. /**
  38574. * Define how the color and intensity of the highlight given by the light in the material.
  38575. */
  38576. specularColor: Color3;
  38577. /**
  38578. * Define the color of the material as if self lit.
  38579. * This will be mixed in the final result even in the absence of light.
  38580. */
  38581. emissiveColor: Color3;
  38582. /**
  38583. * Defines how sharp are the highlights in the material.
  38584. * The bigger the value the sharper giving a more glossy feeling to the result.
  38585. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38586. */
  38587. specularPower: number;
  38588. private _useAlphaFromDiffuseTexture;
  38589. /**
  38590. * Does the transparency come from the diffuse texture alpha channel.
  38591. */
  38592. useAlphaFromDiffuseTexture: boolean;
  38593. private _useEmissiveAsIllumination;
  38594. /**
  38595. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38596. */
  38597. useEmissiveAsIllumination: boolean;
  38598. private _linkEmissiveWithDiffuse;
  38599. /**
  38600. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38601. * the emissive level when the final color is close to one.
  38602. */
  38603. linkEmissiveWithDiffuse: boolean;
  38604. private _useSpecularOverAlpha;
  38605. /**
  38606. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38607. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38608. */
  38609. useSpecularOverAlpha: boolean;
  38610. private _useReflectionOverAlpha;
  38611. /**
  38612. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38613. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38614. */
  38615. useReflectionOverAlpha: boolean;
  38616. private _disableLighting;
  38617. /**
  38618. * Does lights from the scene impacts this material.
  38619. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38620. */
  38621. disableLighting: boolean;
  38622. private _useObjectSpaceNormalMap;
  38623. /**
  38624. * Allows using an object space normal map (instead of tangent space).
  38625. */
  38626. useObjectSpaceNormalMap: boolean;
  38627. private _useParallax;
  38628. /**
  38629. * Is parallax enabled or not.
  38630. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38631. */
  38632. useParallax: boolean;
  38633. private _useParallaxOcclusion;
  38634. /**
  38635. * Is parallax occlusion enabled or not.
  38636. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38637. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38638. */
  38639. useParallaxOcclusion: boolean;
  38640. /**
  38641. * 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.
  38642. */
  38643. parallaxScaleBias: number;
  38644. private _roughness;
  38645. /**
  38646. * Helps to define how blurry the reflections should appears in the material.
  38647. */
  38648. roughness: number;
  38649. /**
  38650. * In case of refraction, define the value of the indice of refraction.
  38651. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38652. */
  38653. indexOfRefraction: number;
  38654. /**
  38655. * Invert the refraction texture alongside the y axis.
  38656. * It can be useful with procedural textures or probe for instance.
  38657. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38658. */
  38659. invertRefractionY: boolean;
  38660. /**
  38661. * Defines the alpha limits in alpha test mode.
  38662. */
  38663. alphaCutOff: number;
  38664. private _useLightmapAsShadowmap;
  38665. /**
  38666. * In case of light mapping, define whether the map contains light or shadow informations.
  38667. */
  38668. useLightmapAsShadowmap: boolean;
  38669. private _diffuseFresnelParameters;
  38670. /**
  38671. * Define the diffuse fresnel parameters of the material.
  38672. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38673. */
  38674. diffuseFresnelParameters: FresnelParameters;
  38675. private _opacityFresnelParameters;
  38676. /**
  38677. * Define the opacity fresnel parameters of the material.
  38678. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38679. */
  38680. opacityFresnelParameters: FresnelParameters;
  38681. private _reflectionFresnelParameters;
  38682. /**
  38683. * Define the reflection fresnel parameters of the material.
  38684. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38685. */
  38686. reflectionFresnelParameters: FresnelParameters;
  38687. private _refractionFresnelParameters;
  38688. /**
  38689. * Define the refraction fresnel parameters of the material.
  38690. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38691. */
  38692. refractionFresnelParameters: FresnelParameters;
  38693. private _emissiveFresnelParameters;
  38694. /**
  38695. * Define the emissive fresnel parameters of the material.
  38696. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38697. */
  38698. emissiveFresnelParameters: FresnelParameters;
  38699. private _useReflectionFresnelFromSpecular;
  38700. /**
  38701. * If true automatically deducts the fresnels values from the material specularity.
  38702. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38703. */
  38704. useReflectionFresnelFromSpecular: boolean;
  38705. private _useGlossinessFromSpecularMapAlpha;
  38706. /**
  38707. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38708. */
  38709. useGlossinessFromSpecularMapAlpha: boolean;
  38710. private _maxSimultaneousLights;
  38711. /**
  38712. * Defines the maximum number of lights that can be used in the material
  38713. */
  38714. maxSimultaneousLights: number;
  38715. private _invertNormalMapX;
  38716. /**
  38717. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38718. */
  38719. invertNormalMapX: boolean;
  38720. private _invertNormalMapY;
  38721. /**
  38722. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38723. */
  38724. invertNormalMapY: boolean;
  38725. private _twoSidedLighting;
  38726. /**
  38727. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38728. */
  38729. twoSidedLighting: boolean;
  38730. /**
  38731. * Default configuration related to image processing available in the standard Material.
  38732. */
  38733. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38734. /**
  38735. * Gets the image processing configuration used either in this material.
  38736. */
  38737. /**
  38738. * Sets the Default image processing configuration used either in the this material.
  38739. *
  38740. * If sets to null, the scene one is in use.
  38741. */
  38742. imageProcessingConfiguration: ImageProcessingConfiguration;
  38743. /**
  38744. * Keep track of the image processing observer to allow dispose and replace.
  38745. */
  38746. private _imageProcessingObserver;
  38747. /**
  38748. * Attaches a new image processing configuration to the Standard Material.
  38749. * @param configuration
  38750. */
  38751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38752. /**
  38753. * Gets wether the color curves effect is enabled.
  38754. */
  38755. /**
  38756. * Sets wether the color curves effect is enabled.
  38757. */
  38758. cameraColorCurvesEnabled: boolean;
  38759. /**
  38760. * Gets wether the color grading effect is enabled.
  38761. */
  38762. /**
  38763. * Gets wether the color grading effect is enabled.
  38764. */
  38765. cameraColorGradingEnabled: boolean;
  38766. /**
  38767. * Gets wether tonemapping is enabled or not.
  38768. */
  38769. /**
  38770. * Sets wether tonemapping is enabled or not
  38771. */
  38772. cameraToneMappingEnabled: boolean;
  38773. /**
  38774. * The camera exposure used on this material.
  38775. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38776. * This corresponds to a photographic exposure.
  38777. */
  38778. /**
  38779. * The camera exposure used on this material.
  38780. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38781. * This corresponds to a photographic exposure.
  38782. */
  38783. cameraExposure: number;
  38784. /**
  38785. * Gets The camera contrast used on this material.
  38786. */
  38787. /**
  38788. * Sets The camera contrast used on this material.
  38789. */
  38790. cameraContrast: number;
  38791. /**
  38792. * Gets the Color Grading 2D Lookup Texture.
  38793. */
  38794. /**
  38795. * Sets the Color Grading 2D Lookup Texture.
  38796. */
  38797. cameraColorGradingTexture: Nullable<BaseTexture>;
  38798. /**
  38799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38801. * 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;
  38802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38803. */
  38804. /**
  38805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38807. * 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;
  38808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38809. */
  38810. cameraColorCurves: Nullable<ColorCurves>;
  38811. /**
  38812. * Custom callback helping to override the default shader used in the material.
  38813. */
  38814. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38815. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38816. protected _worldViewProjectionMatrix: Matrix;
  38817. protected _globalAmbientColor: Color3;
  38818. protected _useLogarithmicDepth: boolean;
  38819. /**
  38820. * Instantiates a new standard material.
  38821. * This is the default material used in Babylon. It is the best trade off between quality
  38822. * and performances.
  38823. * @see http://doc.babylonjs.com/babylon101/materials
  38824. * @param name Define the name of the material in the scene
  38825. * @param scene Define the scene the material belong to
  38826. */
  38827. constructor(name: string, scene: Scene);
  38828. /**
  38829. * Gets a boolean indicating that current material needs to register RTT
  38830. */
  38831. readonly hasRenderTargetTextures: boolean;
  38832. /**
  38833. * Gets the current class name of the material e.g. "StandardMaterial"
  38834. * Mainly use in serialization.
  38835. * @returns the class name
  38836. */
  38837. getClassName(): string;
  38838. /**
  38839. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38840. * You can try switching to logarithmic depth.
  38841. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38842. */
  38843. useLogarithmicDepth: boolean;
  38844. /**
  38845. * Specifies if the material will require alpha blending
  38846. * @returns a boolean specifying if alpha blending is needed
  38847. */
  38848. needAlphaBlending(): boolean;
  38849. /**
  38850. * Specifies if this material should be rendered in alpha test mode
  38851. * @returns a boolean specifying if an alpha test is needed.
  38852. */
  38853. needAlphaTesting(): boolean;
  38854. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38855. /**
  38856. * Get the texture used for alpha test purpose.
  38857. * @returns the diffuse texture in case of the standard material.
  38858. */
  38859. getAlphaTestTexture(): Nullable<BaseTexture>;
  38860. /**
  38861. * Get if the submesh is ready to be used and all its information available.
  38862. * Child classes can use it to update shaders
  38863. * @param mesh defines the mesh to check
  38864. * @param subMesh defines which submesh to check
  38865. * @param useInstances specifies that instances should be used
  38866. * @returns a boolean indicating that the submesh is ready or not
  38867. */
  38868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38869. /**
  38870. * Builds the material UBO layouts.
  38871. * Used internally during the effect preparation.
  38872. */
  38873. buildUniformLayout(): void;
  38874. /**
  38875. * Unbinds the material from the mesh
  38876. */
  38877. unbind(): void;
  38878. /**
  38879. * Binds the submesh to this material by preparing the effect and shader to draw
  38880. * @param world defines the world transformation matrix
  38881. * @param mesh defines the mesh containing the submesh
  38882. * @param subMesh defines the submesh to bind the material to
  38883. */
  38884. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38885. /**
  38886. * Get the list of animatables in the material.
  38887. * @returns the list of animatables object used in the material
  38888. */
  38889. getAnimatables(): IAnimatable[];
  38890. /**
  38891. * Gets the active textures from the material
  38892. * @returns an array of textures
  38893. */
  38894. getActiveTextures(): BaseTexture[];
  38895. /**
  38896. * Specifies if the material uses a texture
  38897. * @param texture defines the texture to check against the material
  38898. * @returns a boolean specifying if the material uses the texture
  38899. */
  38900. hasTexture(texture: BaseTexture): boolean;
  38901. /**
  38902. * Disposes the material
  38903. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38904. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38905. */
  38906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38907. /**
  38908. * Makes a duplicate of the material, and gives it a new name
  38909. * @param name defines the new name for the duplicated material
  38910. * @returns the cloned material
  38911. */
  38912. clone(name: string): StandardMaterial;
  38913. /**
  38914. * Serializes this material in a JSON representation
  38915. * @returns the serialized material object
  38916. */
  38917. serialize(): any;
  38918. /**
  38919. * Creates a standard material from parsed material data
  38920. * @param source defines the JSON representation of the material
  38921. * @param scene defines the hosting scene
  38922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38923. * @returns a new standard material
  38924. */
  38925. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38926. /**
  38927. * Are diffuse textures enabled in the application.
  38928. */
  38929. static DiffuseTextureEnabled: boolean;
  38930. /**
  38931. * Are ambient textures enabled in the application.
  38932. */
  38933. static AmbientTextureEnabled: boolean;
  38934. /**
  38935. * Are opacity textures enabled in the application.
  38936. */
  38937. static OpacityTextureEnabled: boolean;
  38938. /**
  38939. * Are reflection textures enabled in the application.
  38940. */
  38941. static ReflectionTextureEnabled: boolean;
  38942. /**
  38943. * Are emissive textures enabled in the application.
  38944. */
  38945. static EmissiveTextureEnabled: boolean;
  38946. /**
  38947. * Are specular textures enabled in the application.
  38948. */
  38949. static SpecularTextureEnabled: boolean;
  38950. /**
  38951. * Are bump textures enabled in the application.
  38952. */
  38953. static BumpTextureEnabled: boolean;
  38954. /**
  38955. * Are lightmap textures enabled in the application.
  38956. */
  38957. static LightmapTextureEnabled: boolean;
  38958. /**
  38959. * Are refraction textures enabled in the application.
  38960. */
  38961. static RefractionTextureEnabled: boolean;
  38962. /**
  38963. * Are color grading textures enabled in the application.
  38964. */
  38965. static ColorGradingTextureEnabled: boolean;
  38966. /**
  38967. * Are fresnels enabled in the application.
  38968. */
  38969. static FresnelEnabled: boolean;
  38970. }
  38971. }
  38972. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38973. import { Scene } from "babylonjs/scene";
  38974. import { Texture } from "babylonjs/Materials/Textures/texture";
  38975. /**
  38976. * A class extending Texture allowing drawing on a texture
  38977. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38978. */
  38979. export class DynamicTexture extends Texture {
  38980. private _generateMipMaps;
  38981. private _canvas;
  38982. private _context;
  38983. private _engine;
  38984. /**
  38985. * Creates a DynamicTexture
  38986. * @param name defines the name of the texture
  38987. * @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
  38988. * @param scene defines the scene where you want the texture
  38989. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38990. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38991. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38992. */
  38993. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38994. /**
  38995. * Get the current class name of the texture useful for serialization or dynamic coding.
  38996. * @returns "DynamicTexture"
  38997. */
  38998. getClassName(): string;
  38999. /**
  39000. * Gets the current state of canRescale
  39001. */
  39002. readonly canRescale: boolean;
  39003. private _recreate;
  39004. /**
  39005. * Scales the texture
  39006. * @param ratio the scale factor to apply to both width and height
  39007. */
  39008. scale(ratio: number): void;
  39009. /**
  39010. * Resizes the texture
  39011. * @param width the new width
  39012. * @param height the new height
  39013. */
  39014. scaleTo(width: number, height: number): void;
  39015. /**
  39016. * Gets the context of the canvas used by the texture
  39017. * @returns the canvas context of the dynamic texture
  39018. */
  39019. getContext(): CanvasRenderingContext2D;
  39020. /**
  39021. * Clears the texture
  39022. */
  39023. clear(): void;
  39024. /**
  39025. * Updates the texture
  39026. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39027. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39028. */
  39029. update(invertY?: boolean, premulAlpha?: boolean): void;
  39030. /**
  39031. * Draws text onto the texture
  39032. * @param text defines the text to be drawn
  39033. * @param x defines the placement of the text from the left
  39034. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39035. * @param font defines the font to be used with font-style, font-size, font-name
  39036. * @param color defines the color used for the text
  39037. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39038. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39039. * @param update defines whether texture is immediately update (default is true)
  39040. */
  39041. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39042. /**
  39043. * Clones the texture
  39044. * @returns the clone of the texture.
  39045. */
  39046. clone(): DynamicTexture;
  39047. /**
  39048. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39049. * @returns a serialized dynamic texture object
  39050. */
  39051. serialize(): any;
  39052. /** @hidden */
  39053. _rebuild(): void;
  39054. }
  39055. }
  39056. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39057. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39059. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39060. /** @hidden */
  39061. export var imageProcessingPixelShader: {
  39062. name: string;
  39063. shader: string;
  39064. };
  39065. }
  39066. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39067. import { Nullable } from "babylonjs/types";
  39068. import { Color4 } from "babylonjs/Maths/math";
  39069. import { Camera } from "babylonjs/Cameras/camera";
  39070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39071. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39072. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39074. import { Engine } from "babylonjs/Engines/engine";
  39075. import "babylonjs/Shaders/imageProcessing.fragment";
  39076. import "babylonjs/Shaders/postprocess.vertex";
  39077. /**
  39078. * ImageProcessingPostProcess
  39079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39080. */
  39081. export class ImageProcessingPostProcess extends PostProcess {
  39082. /**
  39083. * Default configuration related to image processing available in the PBR Material.
  39084. */
  39085. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39086. /**
  39087. * Gets the image processing configuration used either in this material.
  39088. */
  39089. /**
  39090. * Sets the Default image processing configuration used either in the this material.
  39091. *
  39092. * If sets to null, the scene one is in use.
  39093. */
  39094. imageProcessingConfiguration: ImageProcessingConfiguration;
  39095. /**
  39096. * Keep track of the image processing observer to allow dispose and replace.
  39097. */
  39098. private _imageProcessingObserver;
  39099. /**
  39100. * Attaches a new image processing configuration to the PBR Material.
  39101. * @param configuration
  39102. */
  39103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39104. /**
  39105. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39106. */
  39107. /**
  39108. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39109. */
  39110. colorCurves: Nullable<ColorCurves>;
  39111. /**
  39112. * Gets wether the color curves effect is enabled.
  39113. */
  39114. /**
  39115. * Sets wether the color curves effect is enabled.
  39116. */
  39117. colorCurvesEnabled: boolean;
  39118. /**
  39119. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39120. */
  39121. /**
  39122. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39123. */
  39124. colorGradingTexture: Nullable<BaseTexture>;
  39125. /**
  39126. * Gets wether the color grading effect is enabled.
  39127. */
  39128. /**
  39129. * Gets wether the color grading effect is enabled.
  39130. */
  39131. colorGradingEnabled: boolean;
  39132. /**
  39133. * Gets exposure used in the effect.
  39134. */
  39135. /**
  39136. * Sets exposure used in the effect.
  39137. */
  39138. exposure: number;
  39139. /**
  39140. * Gets wether tonemapping is enabled or not.
  39141. */
  39142. /**
  39143. * Sets wether tonemapping is enabled or not
  39144. */
  39145. toneMappingEnabled: boolean;
  39146. /**
  39147. * Gets contrast used in the effect.
  39148. */
  39149. /**
  39150. * Sets contrast used in the effect.
  39151. */
  39152. contrast: number;
  39153. /**
  39154. * Gets Vignette stretch size.
  39155. */
  39156. /**
  39157. * Sets Vignette stretch size.
  39158. */
  39159. vignetteStretch: number;
  39160. /**
  39161. * Gets Vignette centre X Offset.
  39162. */
  39163. /**
  39164. * Sets Vignette centre X Offset.
  39165. */
  39166. vignetteCentreX: number;
  39167. /**
  39168. * Gets Vignette centre Y Offset.
  39169. */
  39170. /**
  39171. * Sets Vignette centre Y Offset.
  39172. */
  39173. vignetteCentreY: number;
  39174. /**
  39175. * Gets Vignette weight or intensity of the vignette effect.
  39176. */
  39177. /**
  39178. * Sets Vignette weight or intensity of the vignette effect.
  39179. */
  39180. vignetteWeight: number;
  39181. /**
  39182. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39183. * if vignetteEnabled is set to true.
  39184. */
  39185. /**
  39186. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39187. * if vignetteEnabled is set to true.
  39188. */
  39189. vignetteColor: Color4;
  39190. /**
  39191. * Gets Camera field of view used by the Vignette effect.
  39192. */
  39193. /**
  39194. * Sets Camera field of view used by the Vignette effect.
  39195. */
  39196. vignetteCameraFov: number;
  39197. /**
  39198. * Gets the vignette blend mode allowing different kind of effect.
  39199. */
  39200. /**
  39201. * Sets the vignette blend mode allowing different kind of effect.
  39202. */
  39203. vignetteBlendMode: number;
  39204. /**
  39205. * Gets wether the vignette effect is enabled.
  39206. */
  39207. /**
  39208. * Sets wether the vignette effect is enabled.
  39209. */
  39210. vignetteEnabled: boolean;
  39211. private _fromLinearSpace;
  39212. /**
  39213. * Gets wether the input of the processing is in Gamma or Linear Space.
  39214. */
  39215. /**
  39216. * Sets wether the input of the processing is in Gamma or Linear Space.
  39217. */
  39218. fromLinearSpace: boolean;
  39219. /**
  39220. * Defines cache preventing GC.
  39221. */
  39222. private _defines;
  39223. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39224. /**
  39225. * "ImageProcessingPostProcess"
  39226. * @returns "ImageProcessingPostProcess"
  39227. */
  39228. getClassName(): string;
  39229. protected _updateParameters(): void;
  39230. dispose(camera?: Camera): void;
  39231. }
  39232. }
  39233. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39234. import { Scene } from "babylonjs/scene";
  39235. import { Color3 } from "babylonjs/Maths/math";
  39236. import { Mesh } from "babylonjs/Meshes/mesh";
  39237. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39238. /**
  39239. * Class containing static functions to help procedurally build meshes
  39240. */
  39241. export class GroundBuilder {
  39242. /**
  39243. * Creates a ground mesh
  39244. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39245. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39247. * @param name defines the name of the mesh
  39248. * @param options defines the options used to create the mesh
  39249. * @param scene defines the hosting scene
  39250. * @returns the ground mesh
  39251. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39252. */
  39253. static CreateGround(name: string, options: {
  39254. width?: number;
  39255. height?: number;
  39256. subdivisions?: number;
  39257. subdivisionsX?: number;
  39258. subdivisionsY?: number;
  39259. updatable?: boolean;
  39260. }, scene: any): Mesh;
  39261. /**
  39262. * Creates a tiled ground mesh
  39263. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39264. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39265. * * 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
  39266. * * 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
  39267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39268. * @param name defines the name of the mesh
  39269. * @param options defines the options used to create the mesh
  39270. * @param scene defines the hosting scene
  39271. * @returns the tiled ground mesh
  39272. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39273. */
  39274. static CreateTiledGround(name: string, options: {
  39275. xmin: number;
  39276. zmin: number;
  39277. xmax: number;
  39278. zmax: number;
  39279. subdivisions?: {
  39280. w: number;
  39281. h: number;
  39282. };
  39283. precision?: {
  39284. w: number;
  39285. h: number;
  39286. };
  39287. updatable?: boolean;
  39288. }, scene: Scene): Mesh;
  39289. /**
  39290. * Creates a ground mesh from a height map
  39291. * * The parameter `url` sets the URL of the height map image resource.
  39292. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39293. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39294. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39295. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39296. * * 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.
  39297. * * 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).
  39298. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39300. * @param name defines the name of the mesh
  39301. * @param url defines the url to the height map
  39302. * @param options defines the options used to create the mesh
  39303. * @param scene defines the hosting scene
  39304. * @returns the ground mesh
  39305. * @see https://doc.babylonjs.com/babylon101/height_map
  39306. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39307. */
  39308. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39309. width?: number;
  39310. height?: number;
  39311. subdivisions?: number;
  39312. minHeight?: number;
  39313. maxHeight?: number;
  39314. colorFilter?: Color3;
  39315. alphaFilter?: number;
  39316. updatable?: boolean;
  39317. onReady?: (mesh: GroundMesh) => void;
  39318. }, scene: Scene): GroundMesh;
  39319. }
  39320. }
  39321. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39322. import { Vector4 } from "babylonjs/Maths/math";
  39323. import { Mesh } from "babylonjs/Meshes/mesh";
  39324. /**
  39325. * Class containing static functions to help procedurally build meshes
  39326. */
  39327. export class TorusBuilder {
  39328. /**
  39329. * Creates a torus mesh
  39330. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39331. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39332. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39336. * @param name defines the name of the mesh
  39337. * @param options defines the options used to create the mesh
  39338. * @param scene defines the hosting scene
  39339. * @returns the torus mesh
  39340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39341. */
  39342. static CreateTorus(name: string, options: {
  39343. diameter?: number;
  39344. thickness?: number;
  39345. tessellation?: number;
  39346. updatable?: boolean;
  39347. sideOrientation?: number;
  39348. frontUVs?: Vector4;
  39349. backUVs?: Vector4;
  39350. }, scene: any): Mesh;
  39351. }
  39352. }
  39353. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39354. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39355. import { Mesh } from "babylonjs/Meshes/mesh";
  39356. /**
  39357. * Class containing static functions to help procedurally build meshes
  39358. */
  39359. export class CylinderBuilder {
  39360. /**
  39361. * Creates a cylinder or a cone mesh
  39362. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39363. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39364. * * 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.
  39365. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39366. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39367. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39368. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39369. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39370. * * 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).
  39371. * * 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
  39372. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39373. * * 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
  39374. * * 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.
  39375. * * If `enclose` is false, a ring surface is one element.
  39376. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39377. * * 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
  39378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39381. * @param name defines the name of the mesh
  39382. * @param options defines the options used to create the mesh
  39383. * @param scene defines the hosting scene
  39384. * @returns the cylinder mesh
  39385. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39386. */
  39387. static CreateCylinder(name: string, options: {
  39388. height?: number;
  39389. diameterTop?: number;
  39390. diameterBottom?: number;
  39391. diameter?: number;
  39392. tessellation?: number;
  39393. subdivisions?: number;
  39394. arc?: number;
  39395. faceColors?: Color4[];
  39396. faceUV?: Vector4[];
  39397. updatable?: boolean;
  39398. hasRings?: boolean;
  39399. enclose?: boolean;
  39400. sideOrientation?: number;
  39401. frontUVs?: Vector4;
  39402. backUVs?: Vector4;
  39403. }, scene: any): Mesh;
  39404. }
  39405. }
  39406. declare module "babylonjs/Gamepads/gamepadManager" {
  39407. import { Observable } from "babylonjs/Misc/observable";
  39408. import { Nullable } from "babylonjs/types";
  39409. import { Scene } from "babylonjs/scene";
  39410. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39411. /**
  39412. * Manager for handling gamepads
  39413. */
  39414. export class GamepadManager {
  39415. private _scene?;
  39416. private _babylonGamepads;
  39417. private _oneGamepadConnected;
  39418. /** @hidden */
  39419. _isMonitoring: boolean;
  39420. private _gamepadEventSupported;
  39421. private _gamepadSupport;
  39422. /**
  39423. * observable to be triggered when the gamepad controller has been connected
  39424. */
  39425. onGamepadConnectedObservable: Observable<Gamepad>;
  39426. /**
  39427. * observable to be triggered when the gamepad controller has been disconnected
  39428. */
  39429. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39430. private _onGamepadConnectedEvent;
  39431. private _onGamepadDisconnectedEvent;
  39432. /**
  39433. * Initializes the gamepad manager
  39434. * @param _scene BabylonJS scene
  39435. */
  39436. constructor(_scene?: Scene | undefined);
  39437. /**
  39438. * The gamepads in the game pad manager
  39439. */
  39440. readonly gamepads: Gamepad[];
  39441. /**
  39442. * Get the gamepad controllers based on type
  39443. * @param type The type of gamepad controller
  39444. * @returns Nullable gamepad
  39445. */
  39446. getGamepadByType(type?: number): Nullable<Gamepad>;
  39447. /**
  39448. * Disposes the gamepad manager
  39449. */
  39450. dispose(): void;
  39451. private _addNewGamepad;
  39452. private _startMonitoringGamepads;
  39453. private _stopMonitoringGamepads;
  39454. /** @hidden */
  39455. _checkGamepadsStatus(): void;
  39456. private _updateGamepadObjects;
  39457. }
  39458. }
  39459. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39460. import { Nullable } from "babylonjs/types";
  39461. import { Scene } from "babylonjs/scene";
  39462. import { ISceneComponent } from "babylonjs/sceneComponent";
  39463. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39464. module "babylonjs/scene" {
  39465. interface Scene {
  39466. /** @hidden */
  39467. _gamepadManager: Nullable<GamepadManager>;
  39468. /**
  39469. * Gets the gamepad manager associated with the scene
  39470. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39471. */
  39472. gamepadManager: GamepadManager;
  39473. }
  39474. }
  39475. module "babylonjs/Cameras/freeCameraInputsManager" {
  39476. /**
  39477. * Interface representing a free camera inputs manager
  39478. */
  39479. interface FreeCameraInputsManager {
  39480. /**
  39481. * Adds gamepad input support to the FreeCameraInputsManager.
  39482. * @returns the FreeCameraInputsManager
  39483. */
  39484. addGamepad(): FreeCameraInputsManager;
  39485. }
  39486. }
  39487. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39488. /**
  39489. * Interface representing an arc rotate camera inputs manager
  39490. */
  39491. interface ArcRotateCameraInputsManager {
  39492. /**
  39493. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39494. * @returns the camera inputs manager
  39495. */
  39496. addGamepad(): ArcRotateCameraInputsManager;
  39497. }
  39498. }
  39499. /**
  39500. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39501. */
  39502. export class GamepadSystemSceneComponent implements ISceneComponent {
  39503. /**
  39504. * The component name helpfull to identify the component in the list of scene components.
  39505. */
  39506. readonly name: string;
  39507. /**
  39508. * The scene the component belongs to.
  39509. */
  39510. scene: Scene;
  39511. /**
  39512. * Creates a new instance of the component for the given scene
  39513. * @param scene Defines the scene to register the component in
  39514. */
  39515. constructor(scene: Scene);
  39516. /**
  39517. * Registers the component in a given scene
  39518. */
  39519. register(): void;
  39520. /**
  39521. * Rebuilds the elements related to this component in case of
  39522. * context lost for instance.
  39523. */
  39524. rebuild(): void;
  39525. /**
  39526. * Disposes the component and the associated ressources
  39527. */
  39528. dispose(): void;
  39529. private _beforeCameraUpdate;
  39530. }
  39531. }
  39532. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39533. import { Observable } from "babylonjs/Misc/observable";
  39534. import { Nullable } from "babylonjs/types";
  39535. import { Camera } from "babylonjs/Cameras/camera";
  39536. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39537. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39538. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39539. import { Scene } from "babylonjs/scene";
  39540. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39541. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39543. import { Mesh } from "babylonjs/Meshes/mesh";
  39544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39545. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39546. import "babylonjs/Meshes/Builders/groundBuilder";
  39547. import "babylonjs/Meshes/Builders/torusBuilder";
  39548. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39549. import "babylonjs/Gamepads/gamepadSceneComponent";
  39550. import "babylonjs/Animations/animatable";
  39551. /**
  39552. * Options to modify the vr teleportation behavior.
  39553. */
  39554. export interface VRTeleportationOptions {
  39555. /**
  39556. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39557. */
  39558. floorMeshName?: string;
  39559. /**
  39560. * A list of meshes to be used as the teleportation floor. (default: empty)
  39561. */
  39562. floorMeshes?: Mesh[];
  39563. }
  39564. /**
  39565. * Options to modify the vr experience helper's behavior.
  39566. */
  39567. export interface VRExperienceHelperOptions extends WebVROptions {
  39568. /**
  39569. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39570. */
  39571. createDeviceOrientationCamera?: boolean;
  39572. /**
  39573. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39574. */
  39575. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39576. /**
  39577. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39578. */
  39579. laserToggle?: boolean;
  39580. /**
  39581. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39582. */
  39583. floorMeshes?: Mesh[];
  39584. /**
  39585. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39586. */
  39587. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39588. }
  39589. /**
  39590. * Helps to quickly add VR support to an existing scene.
  39591. * See http://doc.babylonjs.com/how_to/webvr_helper
  39592. */
  39593. export class VRExperienceHelper {
  39594. /** Options to modify the vr experience helper's behavior. */
  39595. webVROptions: VRExperienceHelperOptions;
  39596. private _scene;
  39597. private _position;
  39598. private _btnVR;
  39599. private _btnVRDisplayed;
  39600. private _webVRsupported;
  39601. private _webVRready;
  39602. private _webVRrequesting;
  39603. private _webVRpresenting;
  39604. private _hasEnteredVR;
  39605. private _fullscreenVRpresenting;
  39606. private _canvas;
  39607. private _webVRCamera;
  39608. private _vrDeviceOrientationCamera;
  39609. private _deviceOrientationCamera;
  39610. private _existingCamera;
  39611. private _onKeyDown;
  39612. private _onVrDisplayPresentChange;
  39613. private _onVRDisplayChanged;
  39614. private _onVRRequestPresentStart;
  39615. private _onVRRequestPresentComplete;
  39616. /**
  39617. * Observable raised when entering VR.
  39618. */
  39619. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39620. /**
  39621. * Observable raised when exiting VR.
  39622. */
  39623. onExitingVRObservable: Observable<VRExperienceHelper>;
  39624. /**
  39625. * Observable raised when controller mesh is loaded.
  39626. */
  39627. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39628. /** Return this.onEnteringVRObservable
  39629. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39630. */
  39631. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39632. /** Return this.onExitingVRObservable
  39633. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39634. */
  39635. readonly onExitingVR: Observable<VRExperienceHelper>;
  39636. /** Return this.onControllerMeshLoadedObservable
  39637. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39638. */
  39639. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39640. private _rayLength;
  39641. private _useCustomVRButton;
  39642. private _teleportationRequested;
  39643. private _teleportActive;
  39644. private _floorMeshName;
  39645. private _floorMeshesCollection;
  39646. private _rotationAllowed;
  39647. private _teleportBackwardsVector;
  39648. private _teleportationTarget;
  39649. private _isDefaultTeleportationTarget;
  39650. private _postProcessMove;
  39651. private _teleportationFillColor;
  39652. private _teleportationBorderColor;
  39653. private _rotationAngle;
  39654. private _haloCenter;
  39655. private _cameraGazer;
  39656. private _padSensibilityUp;
  39657. private _padSensibilityDown;
  39658. private _leftController;
  39659. private _rightController;
  39660. /**
  39661. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39662. */
  39663. onNewMeshSelected: Observable<AbstractMesh>;
  39664. /**
  39665. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39666. */
  39667. onNewMeshPicked: Observable<PickingInfo>;
  39668. private _circleEase;
  39669. /**
  39670. * Observable raised before camera teleportation
  39671. */
  39672. onBeforeCameraTeleport: Observable<Vector3>;
  39673. /**
  39674. * Observable raised after camera teleportation
  39675. */
  39676. onAfterCameraTeleport: Observable<Vector3>;
  39677. /**
  39678. * Observable raised when current selected mesh gets unselected
  39679. */
  39680. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39681. private _raySelectionPredicate;
  39682. /**
  39683. * To be optionaly changed by user to define custom ray selection
  39684. */
  39685. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39686. /**
  39687. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39688. */
  39689. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39690. /**
  39691. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39692. */
  39693. teleportationEnabled: boolean;
  39694. private _defaultHeight;
  39695. private _teleportationInitialized;
  39696. private _interactionsEnabled;
  39697. private _interactionsRequested;
  39698. private _displayGaze;
  39699. private _displayLaserPointer;
  39700. /**
  39701. * The mesh used to display where the user is going to teleport.
  39702. */
  39703. /**
  39704. * Sets the mesh to be used to display where the user is going to teleport.
  39705. */
  39706. teleportationTarget: Mesh;
  39707. /**
  39708. * 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
  39709. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39710. * See http://doc.babylonjs.com/resources/baking_transformations
  39711. */
  39712. gazeTrackerMesh: Mesh;
  39713. /**
  39714. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39715. */
  39716. updateGazeTrackerScale: boolean;
  39717. /**
  39718. * If the gaze trackers color should be updated when selecting meshes
  39719. */
  39720. updateGazeTrackerColor: boolean;
  39721. /**
  39722. * The gaze tracking mesh corresponding to the left controller
  39723. */
  39724. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39725. /**
  39726. * The gaze tracking mesh corresponding to the right controller
  39727. */
  39728. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39729. /**
  39730. * If the ray of the gaze should be displayed.
  39731. */
  39732. /**
  39733. * Sets if the ray of the gaze should be displayed.
  39734. */
  39735. displayGaze: boolean;
  39736. /**
  39737. * If the ray of the LaserPointer should be displayed.
  39738. */
  39739. /**
  39740. * Sets if the ray of the LaserPointer should be displayed.
  39741. */
  39742. displayLaserPointer: boolean;
  39743. /**
  39744. * The deviceOrientationCamera used as the camera when not in VR.
  39745. */
  39746. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39747. /**
  39748. * Based on the current WebVR support, returns the current VR camera used.
  39749. */
  39750. readonly currentVRCamera: Nullable<Camera>;
  39751. /**
  39752. * The webVRCamera which is used when in VR.
  39753. */
  39754. readonly webVRCamera: WebVRFreeCamera;
  39755. /**
  39756. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39757. */
  39758. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39759. private readonly _teleportationRequestInitiated;
  39760. /**
  39761. * Defines wether or not Pointer lock should be requested when switching to
  39762. * full screen.
  39763. */
  39764. requestPointerLockOnFullScreen: boolean;
  39765. /**
  39766. * Instantiates a VRExperienceHelper.
  39767. * Helps to quickly add VR support to an existing scene.
  39768. * @param scene The scene the VRExperienceHelper belongs to.
  39769. * @param webVROptions Options to modify the vr experience helper's behavior.
  39770. */
  39771. constructor(scene: Scene,
  39772. /** Options to modify the vr experience helper's behavior. */
  39773. webVROptions?: VRExperienceHelperOptions);
  39774. private _onDefaultMeshLoaded;
  39775. private _onResize;
  39776. private _onFullscreenChange;
  39777. /**
  39778. * Gets a value indicating if we are currently in VR mode.
  39779. */
  39780. readonly isInVRMode: boolean;
  39781. private onVrDisplayPresentChange;
  39782. private onVRDisplayChanged;
  39783. private moveButtonToBottomRight;
  39784. private displayVRButton;
  39785. private updateButtonVisibility;
  39786. private _cachedAngularSensibility;
  39787. /**
  39788. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39789. * Otherwise, will use the fullscreen API.
  39790. */
  39791. enterVR(): void;
  39792. /**
  39793. * Attempt to exit VR, or fullscreen.
  39794. */
  39795. exitVR(): void;
  39796. /**
  39797. * The position of the vr experience helper.
  39798. */
  39799. /**
  39800. * Sets the position of the vr experience helper.
  39801. */
  39802. position: Vector3;
  39803. /**
  39804. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39805. */
  39806. enableInteractions(): void;
  39807. private readonly _noControllerIsActive;
  39808. private beforeRender;
  39809. private _isTeleportationFloor;
  39810. /**
  39811. * Adds a floor mesh to be used for teleportation.
  39812. * @param floorMesh the mesh to be used for teleportation.
  39813. */
  39814. addFloorMesh(floorMesh: Mesh): void;
  39815. /**
  39816. * Removes a floor mesh from being used for teleportation.
  39817. * @param floorMesh the mesh to be removed.
  39818. */
  39819. removeFloorMesh(floorMesh: Mesh): void;
  39820. /**
  39821. * Enables interactions and teleportation using the VR controllers and gaze.
  39822. * @param vrTeleportationOptions options to modify teleportation behavior.
  39823. */
  39824. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39825. private _onNewGamepadConnected;
  39826. private _tryEnableInteractionOnController;
  39827. private _onNewGamepadDisconnected;
  39828. private _enableInteractionOnController;
  39829. private _checkTeleportWithRay;
  39830. private _checkRotate;
  39831. private _checkTeleportBackwards;
  39832. private _enableTeleportationOnController;
  39833. private _createTeleportationCircles;
  39834. private _displayTeleportationTarget;
  39835. private _hideTeleportationTarget;
  39836. private _rotateCamera;
  39837. private _moveTeleportationSelectorTo;
  39838. private _workingVector;
  39839. private _workingQuaternion;
  39840. private _workingMatrix;
  39841. /**
  39842. * Teleports the users feet to the desired location
  39843. * @param location The location where the user's feet should be placed
  39844. */
  39845. teleportCamera(location: Vector3): void;
  39846. private _convertNormalToDirectionOfRay;
  39847. private _castRayAndSelectObject;
  39848. private _notifySelectedMeshUnselected;
  39849. /**
  39850. * Sets the color of the laser ray from the vr controllers.
  39851. * @param color new color for the ray.
  39852. */
  39853. changeLaserColor(color: Color3): void;
  39854. /**
  39855. * Sets the color of the ray from the vr headsets gaze.
  39856. * @param color new color for the ray.
  39857. */
  39858. changeGazeColor(color: Color3): void;
  39859. /**
  39860. * Exits VR and disposes of the vr experience helper
  39861. */
  39862. dispose(): void;
  39863. /**
  39864. * Gets the name of the VRExperienceHelper class
  39865. * @returns "VRExperienceHelper"
  39866. */
  39867. getClassName(): string;
  39868. }
  39869. }
  39870. declare module "babylonjs/Cameras/VR/index" {
  39871. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39872. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39873. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39874. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39875. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39876. export * from "babylonjs/Cameras/VR/webVRCamera";
  39877. }
  39878. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39879. import { Observable } from "babylonjs/Misc/observable";
  39880. import { Nullable } from "babylonjs/types";
  39881. import { IDisposable, Scene } from "babylonjs/scene";
  39882. import { Vector3 } from "babylonjs/Maths/math";
  39883. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39884. import { Ray } from "babylonjs/Culling/ray";
  39885. /**
  39886. * Manages an XRSession
  39887. * @see https://doc.babylonjs.com/how_to/webxr
  39888. */
  39889. export class WebXRSessionManager implements IDisposable {
  39890. private scene;
  39891. /**
  39892. * Fires every time a new xrFrame arrives which can be used to update the camera
  39893. */
  39894. onXRFrameObservable: Observable<any>;
  39895. /**
  39896. * Fires when the xr session is ended either by the device or manually done
  39897. */
  39898. onXRSessionEnded: Observable<any>;
  39899. /** @hidden */
  39900. _xrSession: XRSession;
  39901. /** @hidden */
  39902. _frameOfReference: XRFrameOfReference;
  39903. /** @hidden */
  39904. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39905. /** @hidden */
  39906. _currentXRFrame: Nullable<XRFrame>;
  39907. private _xrNavigator;
  39908. private _xrDevice;
  39909. private _tmpMatrix;
  39910. /**
  39911. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39912. * @param scene The scene which the session should be created for
  39913. */
  39914. constructor(scene: Scene);
  39915. /**
  39916. * Initializes the manager
  39917. * After initialization enterXR can be called to start an XR session
  39918. * @returns Promise which resolves after it is initialized
  39919. */
  39920. initializeAsync(): Promise<void>;
  39921. /**
  39922. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39923. * @param sessionCreationOptions xr options to create the session with
  39924. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39925. * @returns Promise which resolves after it enters XR
  39926. */
  39927. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39928. /**
  39929. * Stops the xrSession and restores the renderloop
  39930. * @returns Promise which resolves after it exits XR
  39931. */
  39932. exitXRAsync(): Promise<void>;
  39933. /**
  39934. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39935. * @param ray ray to cast into the environment
  39936. * @returns Promise which resolves with a collision point in the environment if it exists
  39937. */
  39938. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39939. /**
  39940. * Checks if a session would be supported for the creation options specified
  39941. * @param options creation options to check if they are supported
  39942. * @returns true if supported
  39943. */
  39944. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39945. /**
  39946. * @hidden
  39947. * Converts the render layer of xrSession to a render target
  39948. * @param session session to create render target for
  39949. * @param scene scene the new render target should be created for
  39950. */
  39951. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39952. /**
  39953. * Disposes of the session manager
  39954. */
  39955. dispose(): void;
  39956. }
  39957. }
  39958. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39959. import { Scene } from "babylonjs/scene";
  39960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39961. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39962. /**
  39963. * WebXR Camera which holds the views for the xrSession
  39964. * @see https://doc.babylonjs.com/how_to/webxr
  39965. */
  39966. export class WebXRCamera extends FreeCamera {
  39967. private static _TmpMatrix;
  39968. /**
  39969. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39970. * @param name the name of the camera
  39971. * @param scene the scene to add the camera to
  39972. */
  39973. constructor(name: string, scene: Scene);
  39974. private _updateNumberOfRigCameras;
  39975. /** @hidden */
  39976. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39977. /**
  39978. * Updates the cameras position from the current pose information of the XR session
  39979. * @param xrSessionManager the session containing pose information
  39980. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39981. */
  39982. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39983. }
  39984. }
  39985. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  39986. import { Nullable } from "babylonjs/types";
  39987. import { Observable } from "babylonjs/Misc/observable";
  39988. import { IDisposable, Scene } from "babylonjs/scene";
  39989. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  39990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39991. import { Ray } from "babylonjs/Culling/ray";
  39992. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39993. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  39994. /**
  39995. * States of the webXR experience
  39996. */
  39997. export enum WebXRState {
  39998. /**
  39999. * Transitioning to being in XR mode
  40000. */
  40001. ENTERING_XR = 0,
  40002. /**
  40003. * Transitioning to non XR mode
  40004. */
  40005. EXITING_XR = 1,
  40006. /**
  40007. * In XR mode and presenting
  40008. */
  40009. IN_XR = 2,
  40010. /**
  40011. * Not entered XR mode
  40012. */
  40013. NOT_IN_XR = 3
  40014. }
  40015. /**
  40016. * Helper class used to enable XR
  40017. * @see https://doc.babylonjs.com/how_to/webxr
  40018. */
  40019. export class WebXRExperienceHelper implements IDisposable {
  40020. private scene;
  40021. /**
  40022. * 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
  40023. */
  40024. container: AbstractMesh;
  40025. /**
  40026. * Camera used to render xr content
  40027. */
  40028. camera: WebXRCamera;
  40029. /**
  40030. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40031. */
  40032. state: WebXRState;
  40033. private _setState;
  40034. private static _TmpVector;
  40035. /**
  40036. * Fires when the state of the experience helper has changed
  40037. */
  40038. onStateChangedObservable: Observable<WebXRState>;
  40039. /** @hidden */
  40040. _sessionManager: WebXRSessionManager;
  40041. private _nonVRCamera;
  40042. private _originalSceneAutoClear;
  40043. private _supported;
  40044. /**
  40045. * Creates the experience helper
  40046. * @param scene the scene to attach the experience helper to
  40047. * @returns a promise for the experience helper
  40048. */
  40049. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40050. /**
  40051. * Creates a WebXRExperienceHelper
  40052. * @param scene The scene the helper should be created in
  40053. */
  40054. private constructor();
  40055. /**
  40056. * Exits XR mode and returns the scene to its original state
  40057. * @returns promise that resolves after xr mode has exited
  40058. */
  40059. exitXRAsync(): Promise<void>;
  40060. /**
  40061. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40062. * @param sessionCreationOptions options for the XR session
  40063. * @param frameOfReference frame of reference of the XR session
  40064. * @returns promise that resolves after xr mode has entered
  40065. */
  40066. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40067. /**
  40068. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40069. * @param ray ray to cast into the environment
  40070. * @returns Promise which resolves with a collision point in the environment if it exists
  40071. */
  40072. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40073. /**
  40074. * Updates the global position of the camera by moving the camera's container
  40075. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40076. * @param position The desired global position of the camera
  40077. */
  40078. setPositionOfCameraUsingContainer(position: Vector3): void;
  40079. /**
  40080. * Rotates the xr camera by rotating the camera's container around the camera's position
  40081. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40082. * @param rotation the desired quaternion rotation to apply to the camera
  40083. */
  40084. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40085. /**
  40086. * Checks if the creation options are supported by the xr session
  40087. * @param options creation options
  40088. * @returns true if supported
  40089. */
  40090. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40091. /**
  40092. * Disposes of the experience helper
  40093. */
  40094. dispose(): void;
  40095. }
  40096. }
  40097. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40098. import { Nullable } from "babylonjs/types";
  40099. import { Observable } from "babylonjs/Misc/observable";
  40100. import { IDisposable, Scene } from "babylonjs/scene";
  40101. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40102. /**
  40103. * Button which can be used to enter a different mode of XR
  40104. */
  40105. export class WebXREnterExitUIButton {
  40106. /** button element */
  40107. element: HTMLElement;
  40108. /** XR initialization options for the button */
  40109. initializationOptions: XRSessionCreationOptions;
  40110. /**
  40111. * Creates a WebXREnterExitUIButton
  40112. * @param element button element
  40113. * @param initializationOptions XR initialization options for the button
  40114. */
  40115. constructor(
  40116. /** button element */
  40117. element: HTMLElement,
  40118. /** XR initialization options for the button */
  40119. initializationOptions: XRSessionCreationOptions);
  40120. /**
  40121. * Overwritable function which can be used to update the button's visuals when the state changes
  40122. * @param activeButton the current active button in the UI
  40123. */
  40124. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40125. }
  40126. /**
  40127. * Options to create the webXR UI
  40128. */
  40129. export class WebXREnterExitUIOptions {
  40130. /**
  40131. * Context to enter xr with
  40132. */
  40133. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40134. /**
  40135. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40136. */
  40137. customButtons?: Array<WebXREnterExitUIButton>;
  40138. }
  40139. /**
  40140. * UI to allow the user to enter/exit XR mode
  40141. */
  40142. export class WebXREnterExitUI implements IDisposable {
  40143. private scene;
  40144. private _overlay;
  40145. private _buttons;
  40146. private _activeButton;
  40147. /**
  40148. * Fired every time the active button is changed.
  40149. *
  40150. * When xr is entered via a button that launches xr that button will be the callback parameter
  40151. *
  40152. * When exiting xr the callback parameter will be null)
  40153. */
  40154. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40155. /**
  40156. * Creates UI to allow the user to enter/exit XR mode
  40157. * @param scene the scene to add the ui to
  40158. * @param helper the xr experience helper to enter/exit xr with
  40159. * @param options options to configure the UI
  40160. * @returns the created ui
  40161. */
  40162. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40163. private constructor();
  40164. private _updateButtons;
  40165. /**
  40166. * Disposes of the object
  40167. */
  40168. dispose(): void;
  40169. }
  40170. }
  40171. declare module "babylonjs/Cameras/XR/webXRInput" {
  40172. import { IDisposable, Scene } from "babylonjs/scene";
  40173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40174. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40175. /**
  40176. * Represents an XR input
  40177. */
  40178. export class WebXRController {
  40179. /**
  40180. * 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
  40181. */
  40182. grip?: AbstractMesh;
  40183. /**
  40184. * Pointer which can be used to select objects or attach a visible laser to
  40185. */
  40186. pointer: AbstractMesh;
  40187. /**
  40188. * Creates the controller
  40189. * @see https://doc.babylonjs.com/how_to/webxr
  40190. * @param scene the scene which the controller should be associated to
  40191. */
  40192. constructor(scene: Scene);
  40193. /**
  40194. * Disposes of the object
  40195. */
  40196. dispose(): void;
  40197. }
  40198. /**
  40199. * XR input used to track XR inputs such as controllers/rays
  40200. */
  40201. export class WebXRInput implements IDisposable {
  40202. private helper;
  40203. /**
  40204. * XR controllers being tracked
  40205. */
  40206. controllers: Array<WebXRController>;
  40207. private _tmpMatrix;
  40208. private _frameObserver;
  40209. /**
  40210. * Initializes the WebXRInput
  40211. * @param helper experience helper which the input should be created for
  40212. */
  40213. constructor(helper: WebXRExperienceHelper);
  40214. /**
  40215. * Disposes of the object
  40216. */
  40217. dispose(): void;
  40218. }
  40219. }
  40220. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40221. import { Nullable } from "babylonjs/types";
  40222. import { IDisposable } from "babylonjs/scene";
  40223. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40224. /**
  40225. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40226. */
  40227. export class WebXRManagedOutputCanvas implements IDisposable {
  40228. private _canvas;
  40229. /**
  40230. * xrpresent context of the canvas which can be used to display/mirror xr content
  40231. */
  40232. canvasContext: Nullable<WebGLRenderingContext>;
  40233. /**
  40234. * Initializes the canvas to be added/removed upon entering/exiting xr
  40235. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40236. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40237. */
  40238. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40239. /**
  40240. * Disposes of the object
  40241. */
  40242. dispose(): void;
  40243. private _setManagedOutputCanvas;
  40244. private _addCanvas;
  40245. private _removeCanvas;
  40246. }
  40247. }
  40248. declare module "babylonjs/Cameras/XR/index" {
  40249. export * from "babylonjs/Cameras/XR/webXRCamera";
  40250. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40251. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40252. export * from "babylonjs/Cameras/XR/webXRInput";
  40253. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40254. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40255. }
  40256. declare module "babylonjs/Cameras/RigModes/index" {
  40257. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40258. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40259. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40260. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40261. }
  40262. declare module "babylonjs/Cameras/index" {
  40263. export * from "babylonjs/Cameras/Inputs/index";
  40264. export * from "babylonjs/Cameras/cameraInputsManager";
  40265. export * from "babylonjs/Cameras/camera";
  40266. export * from "babylonjs/Cameras/targetCamera";
  40267. export * from "babylonjs/Cameras/freeCamera";
  40268. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40269. export * from "babylonjs/Cameras/touchCamera";
  40270. export * from "babylonjs/Cameras/arcRotateCamera";
  40271. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40272. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40273. export * from "babylonjs/Cameras/flyCamera";
  40274. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40275. export * from "babylonjs/Cameras/followCamera";
  40276. export * from "babylonjs/Cameras/gamepadCamera";
  40277. export * from "babylonjs/Cameras/Stereoscopic/index";
  40278. export * from "babylonjs/Cameras/universalCamera";
  40279. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40280. export * from "babylonjs/Cameras/VR/index";
  40281. export * from "babylonjs/Cameras/XR/index";
  40282. export * from "babylonjs/Cameras/RigModes/index";
  40283. }
  40284. declare module "babylonjs/Collisions/index" {
  40285. export * from "babylonjs/Collisions/collider";
  40286. export * from "babylonjs/Collisions/collisionCoordinator";
  40287. export * from "babylonjs/Collisions/pickingInfo";
  40288. export * from "babylonjs/Collisions/intersectionInfo";
  40289. }
  40290. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40291. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40292. import { Vector3, Plane } from "babylonjs/Maths/math";
  40293. import { Ray } from "babylonjs/Culling/ray";
  40294. /**
  40295. * Contains an array of blocks representing the octree
  40296. */
  40297. export interface IOctreeContainer<T> {
  40298. /**
  40299. * Blocks within the octree
  40300. */
  40301. blocks: Array<OctreeBlock<T>>;
  40302. }
  40303. /**
  40304. * Class used to store a cell in an octree
  40305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40306. */
  40307. export class OctreeBlock<T> {
  40308. /**
  40309. * Gets the content of the current block
  40310. */
  40311. entries: T[];
  40312. /**
  40313. * Gets the list of block children
  40314. */
  40315. blocks: Array<OctreeBlock<T>>;
  40316. private _depth;
  40317. private _maxDepth;
  40318. private _capacity;
  40319. private _minPoint;
  40320. private _maxPoint;
  40321. private _boundingVectors;
  40322. private _creationFunc;
  40323. /**
  40324. * Creates a new block
  40325. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40326. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40327. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40328. * @param depth defines the current depth of this block in the octree
  40329. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40330. * @param creationFunc defines a callback to call when an element is added to the block
  40331. */
  40332. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40333. /**
  40334. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40335. */
  40336. readonly capacity: number;
  40337. /**
  40338. * Gets the minimum vector (in world space) of the block's bounding box
  40339. */
  40340. readonly minPoint: Vector3;
  40341. /**
  40342. * Gets the maximum vector (in world space) of the block's bounding box
  40343. */
  40344. readonly maxPoint: Vector3;
  40345. /**
  40346. * Add a new element to this block
  40347. * @param entry defines the element to add
  40348. */
  40349. addEntry(entry: T): void;
  40350. /**
  40351. * Remove an element from this block
  40352. * @param entry defines the element to remove
  40353. */
  40354. removeEntry(entry: T): void;
  40355. /**
  40356. * Add an array of elements to this block
  40357. * @param entries defines the array of elements to add
  40358. */
  40359. addEntries(entries: T[]): void;
  40360. /**
  40361. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40362. * @param frustumPlanes defines the frustum planes to test
  40363. * @param selection defines the array to store current content if selection is positive
  40364. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40365. */
  40366. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40367. /**
  40368. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40369. * @param sphereCenter defines the bounding sphere center
  40370. * @param sphereRadius defines the bounding sphere radius
  40371. * @param selection defines the array to store current content if selection is positive
  40372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40373. */
  40374. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40375. /**
  40376. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40377. * @param ray defines the ray to test with
  40378. * @param selection defines the array to store current content if selection is positive
  40379. */
  40380. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40381. /**
  40382. * Subdivide the content into child blocks (this block will then be empty)
  40383. */
  40384. createInnerBlocks(): void;
  40385. /**
  40386. * @hidden
  40387. */
  40388. 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;
  40389. }
  40390. }
  40391. declare module "babylonjs/Culling/Octrees/octree" {
  40392. import { SmartArray } from "babylonjs/Misc/smartArray";
  40393. import { Vector3, Plane } from "babylonjs/Maths/math";
  40394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40396. import { Ray } from "babylonjs/Culling/ray";
  40397. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40398. /**
  40399. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40401. */
  40402. export class Octree<T> {
  40403. /** 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.) */
  40404. maxDepth: number;
  40405. /**
  40406. * Blocks within the octree containing objects
  40407. */
  40408. blocks: Array<OctreeBlock<T>>;
  40409. /**
  40410. * Content stored in the octree
  40411. */
  40412. dynamicContent: T[];
  40413. private _maxBlockCapacity;
  40414. private _selectionContent;
  40415. private _creationFunc;
  40416. /**
  40417. * Creates a octree
  40418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40419. * @param creationFunc function to be used to instatiate the octree
  40420. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40421. * @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.)
  40422. */
  40423. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40424. /** 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.) */
  40425. maxDepth?: number);
  40426. /**
  40427. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40428. * @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);
  40429. * @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);
  40430. * @param entries meshes to be added to the octree blocks
  40431. */
  40432. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40433. /**
  40434. * Adds a mesh to the octree
  40435. * @param entry Mesh to add to the octree
  40436. */
  40437. addMesh(entry: T): void;
  40438. /**
  40439. * Remove an element from the octree
  40440. * @param entry defines the element to remove
  40441. */
  40442. removeMesh(entry: T): void;
  40443. /**
  40444. * Selects an array of meshes within the frustum
  40445. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40446. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40447. * @returns array of meshes within the frustum
  40448. */
  40449. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40450. /**
  40451. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40452. * @param sphereCenter defines the bounding sphere center
  40453. * @param sphereRadius defines the bounding sphere radius
  40454. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40455. * @returns an array of objects that intersect the sphere
  40456. */
  40457. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40458. /**
  40459. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40460. * @param ray defines the ray to test with
  40461. * @returns array of intersected objects
  40462. */
  40463. intersectsRay(ray: Ray): SmartArray<T>;
  40464. /**
  40465. * Adds a mesh into the octree block if it intersects the block
  40466. */
  40467. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40468. /**
  40469. * Adds a submesh into the octree block if it intersects the block
  40470. */
  40471. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40472. }
  40473. }
  40474. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40475. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40476. import { Scene } from "babylonjs/scene";
  40477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40479. import { Ray } from "babylonjs/Culling/ray";
  40480. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40481. import { Collider } from "babylonjs/Collisions/collider";
  40482. module "babylonjs/scene" {
  40483. interface Scene {
  40484. /**
  40485. * @hidden
  40486. * Backing Filed
  40487. */
  40488. _selectionOctree: Octree<AbstractMesh>;
  40489. /**
  40490. * Gets the octree used to boost mesh selection (picking)
  40491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40492. */
  40493. selectionOctree: Octree<AbstractMesh>;
  40494. /**
  40495. * Creates or updates the octree used to boost selection (picking)
  40496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40497. * @param maxCapacity defines the maximum capacity per leaf
  40498. * @param maxDepth defines the maximum depth of the octree
  40499. * @returns an octree of AbstractMesh
  40500. */
  40501. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40502. }
  40503. }
  40504. module "babylonjs/Meshes/abstractMesh" {
  40505. interface AbstractMesh {
  40506. /**
  40507. * @hidden
  40508. * Backing Field
  40509. */
  40510. _submeshesOctree: Octree<SubMesh>;
  40511. /**
  40512. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40513. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40514. * @param maxCapacity defines the maximum size of each block (64 by default)
  40515. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40516. * @returns the new octree
  40517. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40519. */
  40520. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40521. }
  40522. }
  40523. /**
  40524. * Defines the octree scene component responsible to manage any octrees
  40525. * in a given scene.
  40526. */
  40527. export class OctreeSceneComponent {
  40528. /**
  40529. * The component name helpfull to identify the component in the list of scene components.
  40530. */
  40531. readonly name: string;
  40532. /**
  40533. * The scene the component belongs to.
  40534. */
  40535. scene: Scene;
  40536. /**
  40537. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40538. */
  40539. readonly checksIsEnabled: boolean;
  40540. /**
  40541. * Creates a new instance of the component for the given scene
  40542. * @param scene Defines the scene to register the component in
  40543. */
  40544. constructor(scene: Scene);
  40545. /**
  40546. * Registers the component in a given scene
  40547. */
  40548. register(): void;
  40549. /**
  40550. * Return the list of active meshes
  40551. * @returns the list of active meshes
  40552. */
  40553. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40554. /**
  40555. * Return the list of active sub meshes
  40556. * @param mesh The mesh to get the candidates sub meshes from
  40557. * @returns the list of active sub meshes
  40558. */
  40559. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40560. private _tempRay;
  40561. /**
  40562. * Return the list of sub meshes intersecting with a given local ray
  40563. * @param mesh defines the mesh to find the submesh for
  40564. * @param localRay defines the ray in local space
  40565. * @returns the list of intersecting sub meshes
  40566. */
  40567. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40568. /**
  40569. * Return the list of sub meshes colliding with a collider
  40570. * @param mesh defines the mesh to find the submesh for
  40571. * @param collider defines the collider to evaluate the collision against
  40572. * @returns the list of colliding sub meshes
  40573. */
  40574. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40575. /**
  40576. * Rebuilds the elements related to this component in case of
  40577. * context lost for instance.
  40578. */
  40579. rebuild(): void;
  40580. /**
  40581. * Disposes the component and the associated ressources.
  40582. */
  40583. dispose(): void;
  40584. }
  40585. }
  40586. declare module "babylonjs/Culling/Octrees/index" {
  40587. export * from "babylonjs/Culling/Octrees/octree";
  40588. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40589. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40590. }
  40591. declare module "babylonjs/Culling/index" {
  40592. export * from "babylonjs/Culling/boundingBox";
  40593. export * from "babylonjs/Culling/boundingInfo";
  40594. export * from "babylonjs/Culling/boundingSphere";
  40595. export * from "babylonjs/Culling/Octrees/index";
  40596. export * from "babylonjs/Culling/ray";
  40597. }
  40598. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40599. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40600. import { Nullable } from "babylonjs/types";
  40601. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40602. import { Scene } from "babylonjs/scene";
  40603. /**
  40604. * Class containing static functions to help procedurally build meshes
  40605. */
  40606. export class LinesBuilder {
  40607. /**
  40608. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40609. * * 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
  40610. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40611. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40612. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40613. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40614. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40615. * * 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
  40616. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40619. * @param name defines the name of the new line system
  40620. * @param options defines the options used to create the line system
  40621. * @param scene defines the hosting scene
  40622. * @returns a new line system mesh
  40623. */
  40624. static CreateLineSystem(name: string, options: {
  40625. lines: Vector3[][];
  40626. updatable?: boolean;
  40627. instance?: Nullable<LinesMesh>;
  40628. colors?: Nullable<Color4[][]>;
  40629. useVertexAlpha?: boolean;
  40630. }, scene: Nullable<Scene>): LinesMesh;
  40631. /**
  40632. * Creates a line mesh
  40633. * 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
  40634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40635. * * The parameter `points` is an array successive Vector3
  40636. * * 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
  40637. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40638. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40639. * * When updating an instance, remember that only point positions can change, not the number of points
  40640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40642. * @param name defines the name of the new line system
  40643. * @param options defines the options used to create the line system
  40644. * @param scene defines the hosting scene
  40645. * @returns a new line mesh
  40646. */
  40647. static CreateLines(name: string, options: {
  40648. points: Vector3[];
  40649. updatable?: boolean;
  40650. instance?: Nullable<LinesMesh>;
  40651. colors?: Color4[];
  40652. useVertexAlpha?: boolean;
  40653. }, scene?: Nullable<Scene>): LinesMesh;
  40654. /**
  40655. * Creates a dashed line mesh
  40656. * * 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
  40657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40658. * * The parameter `points` is an array successive Vector3
  40659. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40660. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40661. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40662. * * 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
  40663. * * When updating an instance, remember that only point positions can change, not the number of points
  40664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40665. * @param name defines the name of the mesh
  40666. * @param options defines the options used to create the mesh
  40667. * @param scene defines the hosting scene
  40668. * @returns the dashed line mesh
  40669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40670. */
  40671. static CreateDashedLines(name: string, options: {
  40672. points: Vector3[];
  40673. dashSize?: number;
  40674. gapSize?: number;
  40675. dashNb?: number;
  40676. updatable?: boolean;
  40677. instance?: LinesMesh;
  40678. }, scene?: Nullable<Scene>): LinesMesh;
  40679. }
  40680. }
  40681. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40682. import { IDisposable, Scene } from "babylonjs/scene";
  40683. import { Nullable } from "babylonjs/types";
  40684. import { Observable } from "babylonjs/Misc/observable";
  40685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40686. /**
  40687. * Renders a layer on top of an existing scene
  40688. */
  40689. export class UtilityLayerRenderer implements IDisposable {
  40690. /** the original scene that will be rendered on top of */
  40691. originalScene: Scene;
  40692. private _pointerCaptures;
  40693. private _lastPointerEvents;
  40694. private static _DefaultUtilityLayer;
  40695. private static _DefaultKeepDepthUtilityLayer;
  40696. /**
  40697. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40698. */
  40699. pickUtilitySceneFirst: boolean;
  40700. /**
  40701. * 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)
  40702. */
  40703. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40704. /**
  40705. * 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)
  40706. */
  40707. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40708. /**
  40709. * The scene that is rendered on top of the original scene
  40710. */
  40711. utilityLayerScene: Scene;
  40712. /**
  40713. * If the utility layer should automatically be rendered on top of existing scene
  40714. */
  40715. shouldRender: boolean;
  40716. /**
  40717. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40718. */
  40719. onlyCheckPointerDownEvents: boolean;
  40720. /**
  40721. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40722. */
  40723. processAllEvents: boolean;
  40724. /**
  40725. * Observable raised when the pointer move from the utility layer scene to the main scene
  40726. */
  40727. onPointerOutObservable: Observable<number>;
  40728. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40729. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40730. private _afterRenderObserver;
  40731. private _sceneDisposeObserver;
  40732. private _originalPointerObserver;
  40733. /**
  40734. * Instantiates a UtilityLayerRenderer
  40735. * @param originalScene the original scene that will be rendered on top of
  40736. * @param handleEvents boolean indicating if the utility layer should handle events
  40737. */
  40738. constructor(
  40739. /** the original scene that will be rendered on top of */
  40740. originalScene: Scene, handleEvents?: boolean);
  40741. private _notifyObservers;
  40742. /**
  40743. * Renders the utility layers scene on top of the original scene
  40744. */
  40745. render(): void;
  40746. /**
  40747. * Disposes of the renderer
  40748. */
  40749. dispose(): void;
  40750. private _updateCamera;
  40751. }
  40752. }
  40753. declare module "babylonjs/Gizmos/gizmo" {
  40754. import { Nullable } from "babylonjs/types";
  40755. import { IDisposable } from "babylonjs/scene";
  40756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40757. import { Mesh } from "babylonjs/Meshes/mesh";
  40758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40759. /**
  40760. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40761. */
  40762. export class Gizmo implements IDisposable {
  40763. /** The utility layer the gizmo will be added to */
  40764. gizmoLayer: UtilityLayerRenderer;
  40765. /**
  40766. * The root mesh of the gizmo
  40767. */
  40768. protected _rootMesh: Mesh;
  40769. private _attachedMesh;
  40770. /**
  40771. * Ratio for the scale of the gizmo (Default: 1)
  40772. */
  40773. scaleRatio: number;
  40774. private _tmpMatrix;
  40775. /**
  40776. * If a custom mesh has been set (Default: false)
  40777. */
  40778. protected _customMeshSet: boolean;
  40779. /**
  40780. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40781. * * When set, interactions will be enabled
  40782. */
  40783. attachedMesh: Nullable<AbstractMesh>;
  40784. /**
  40785. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40786. * @param mesh The mesh to replace the default mesh of the gizmo
  40787. */
  40788. setCustomMesh(mesh: Mesh): void;
  40789. /**
  40790. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40791. */
  40792. updateGizmoRotationToMatchAttachedMesh: boolean;
  40793. /**
  40794. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40795. */
  40796. updateGizmoPositionToMatchAttachedMesh: boolean;
  40797. /**
  40798. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40799. */
  40800. protected _updateScale: boolean;
  40801. protected _interactionsEnabled: boolean;
  40802. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40803. private _beforeRenderObserver;
  40804. /**
  40805. * Creates a gizmo
  40806. * @param gizmoLayer The utility layer the gizmo will be added to
  40807. */
  40808. constructor(
  40809. /** The utility layer the gizmo will be added to */
  40810. gizmoLayer?: UtilityLayerRenderer);
  40811. private _tempVector;
  40812. /**
  40813. * @hidden
  40814. * Updates the gizmo to match the attached mesh's position/rotation
  40815. */
  40816. protected _update(): void;
  40817. /**
  40818. * Disposes of the gizmo
  40819. */
  40820. dispose(): void;
  40821. }
  40822. }
  40823. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40824. import { Observable } from "babylonjs/Misc/observable";
  40825. import { Nullable } from "babylonjs/types";
  40826. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40827. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40829. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40830. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40831. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40832. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40833. import { Scene } from "babylonjs/scene";
  40834. /**
  40835. * Single axis drag gizmo
  40836. */
  40837. export class AxisDragGizmo extends Gizmo {
  40838. /**
  40839. * Drag behavior responsible for the gizmos dragging interactions
  40840. */
  40841. dragBehavior: PointerDragBehavior;
  40842. private _pointerObserver;
  40843. /**
  40844. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40845. */
  40846. snapDistance: number;
  40847. /**
  40848. * Event that fires each time the gizmo snaps to a new location.
  40849. * * snapDistance is the the change in distance
  40850. */
  40851. onSnapObservable: Observable<{
  40852. snapDistance: number;
  40853. }>;
  40854. /** @hidden */
  40855. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40856. /** @hidden */
  40857. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40858. /**
  40859. * Creates an AxisDragGizmo
  40860. * @param gizmoLayer The utility layer the gizmo will be added to
  40861. * @param dragAxis The axis which the gizmo will be able to drag on
  40862. * @param color The color of the gizmo
  40863. */
  40864. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40865. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40866. /**
  40867. * Disposes of the gizmo
  40868. */
  40869. dispose(): void;
  40870. }
  40871. }
  40872. declare module "babylonjs/Debug/axesViewer" {
  40873. import { Vector3 } from "babylonjs/Maths/math";
  40874. import { Nullable } from "babylonjs/types";
  40875. import { Scene } from "babylonjs/scene";
  40876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40877. /**
  40878. * The Axes viewer will show 3 axes in a specific point in space
  40879. */
  40880. export class AxesViewer {
  40881. private _xAxis;
  40882. private _yAxis;
  40883. private _zAxis;
  40884. private _scaleLinesFactor;
  40885. private _instanced;
  40886. /**
  40887. * Gets the hosting scene
  40888. */
  40889. scene: Scene;
  40890. /**
  40891. * Gets or sets a number used to scale line length
  40892. */
  40893. scaleLines: number;
  40894. /** Gets the node hierarchy used to render x-axis */
  40895. readonly xAxis: TransformNode;
  40896. /** Gets the node hierarchy used to render y-axis */
  40897. readonly yAxis: TransformNode;
  40898. /** Gets the node hierarchy used to render z-axis */
  40899. readonly zAxis: TransformNode;
  40900. /**
  40901. * Creates a new AxesViewer
  40902. * @param scene defines the hosting scene
  40903. * @param scaleLines defines a number used to scale line length (1 by default)
  40904. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40905. * @param xAxis defines the node hierarchy used to render the x-axis
  40906. * @param yAxis defines the node hierarchy used to render the y-axis
  40907. * @param zAxis defines the node hierarchy used to render the z-axis
  40908. */
  40909. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40910. /**
  40911. * Force the viewer to update
  40912. * @param position defines the position of the viewer
  40913. * @param xaxis defines the x axis of the viewer
  40914. * @param yaxis defines the y axis of the viewer
  40915. * @param zaxis defines the z axis of the viewer
  40916. */
  40917. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40918. /**
  40919. * Creates an instance of this axes viewer.
  40920. * @returns a new axes viewer with instanced meshes
  40921. */
  40922. createInstance(): AxesViewer;
  40923. /** Releases resources */
  40924. dispose(): void;
  40925. private static _SetRenderingGroupId;
  40926. }
  40927. }
  40928. declare module "babylonjs/Debug/boneAxesViewer" {
  40929. import { Nullable } from "babylonjs/types";
  40930. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40931. import { Vector3 } from "babylonjs/Maths/math";
  40932. import { Mesh } from "babylonjs/Meshes/mesh";
  40933. import { Bone } from "babylonjs/Bones/bone";
  40934. import { Scene } from "babylonjs/scene";
  40935. /**
  40936. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40937. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40938. */
  40939. export class BoneAxesViewer extends AxesViewer {
  40940. /**
  40941. * Gets or sets the target mesh where to display the axes viewer
  40942. */
  40943. mesh: Nullable<Mesh>;
  40944. /**
  40945. * Gets or sets the target bone where to display the axes viewer
  40946. */
  40947. bone: Nullable<Bone>;
  40948. /** Gets current position */
  40949. pos: Vector3;
  40950. /** Gets direction of X axis */
  40951. xaxis: Vector3;
  40952. /** Gets direction of Y axis */
  40953. yaxis: Vector3;
  40954. /** Gets direction of Z axis */
  40955. zaxis: Vector3;
  40956. /**
  40957. * Creates a new BoneAxesViewer
  40958. * @param scene defines the hosting scene
  40959. * @param bone defines the target bone
  40960. * @param mesh defines the target mesh
  40961. * @param scaleLines defines a scaling factor for line length (1 by default)
  40962. */
  40963. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40964. /**
  40965. * Force the viewer to update
  40966. */
  40967. update(): void;
  40968. /** Releases resources */
  40969. dispose(): void;
  40970. }
  40971. }
  40972. declare module "babylonjs/Debug/debugLayer" {
  40973. import { Observable } from "babylonjs/Misc/observable";
  40974. import { Scene } from "babylonjs/scene";
  40975. /**
  40976. * Interface used to define scene explorer extensibility option
  40977. */
  40978. export interface IExplorerExtensibilityOption {
  40979. /**
  40980. * Define the option label
  40981. */
  40982. label: string;
  40983. /**
  40984. * Defines the action to execute on click
  40985. */
  40986. action: (entity: any) => void;
  40987. }
  40988. /**
  40989. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40990. */
  40991. export interface IExplorerExtensibilityGroup {
  40992. /**
  40993. * Defines a predicate to test if a given type mut be extended
  40994. */
  40995. predicate: (entity: any) => boolean;
  40996. /**
  40997. * Gets the list of options added to a type
  40998. */
  40999. entries: IExplorerExtensibilityOption[];
  41000. }
  41001. /**
  41002. * Interface used to define the options to use to create the Inspector
  41003. */
  41004. export interface IInspectorOptions {
  41005. /**
  41006. * Display in overlay mode (default: false)
  41007. */
  41008. overlay?: boolean;
  41009. /**
  41010. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41011. */
  41012. globalRoot?: HTMLElement;
  41013. /**
  41014. * Display the Scene explorer
  41015. */
  41016. showExplorer?: boolean;
  41017. /**
  41018. * Display the property inspector
  41019. */
  41020. showInspector?: boolean;
  41021. /**
  41022. * Display in embed mode (both panes on the right)
  41023. */
  41024. embedMode?: boolean;
  41025. /**
  41026. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41027. */
  41028. handleResize?: boolean;
  41029. /**
  41030. * Allow the panes to popup (default: true)
  41031. */
  41032. enablePopup?: boolean;
  41033. /**
  41034. * Allow the panes to be closed by users (default: true)
  41035. */
  41036. enableClose?: boolean;
  41037. /**
  41038. * Optional list of extensibility entries
  41039. */
  41040. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41041. }
  41042. module "babylonjs/scene" {
  41043. interface Scene {
  41044. /**
  41045. * @hidden
  41046. * Backing field
  41047. */
  41048. _debugLayer: DebugLayer;
  41049. /**
  41050. * Gets the debug layer (aka Inspector) associated with the scene
  41051. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41052. */
  41053. debugLayer: DebugLayer;
  41054. }
  41055. }
  41056. /**
  41057. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41058. * what is happening in your scene
  41059. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41060. */
  41061. export class DebugLayer {
  41062. /**
  41063. * Define the url to get the inspector script from.
  41064. * By default it uses the babylonjs CDN.
  41065. * @ignoreNaming
  41066. */
  41067. static InspectorURL: string;
  41068. private _scene;
  41069. private BJSINSPECTOR;
  41070. /**
  41071. * Observable triggered when a property is changed through the inspector.
  41072. */
  41073. onPropertyChangedObservable: Observable<{
  41074. object: any;
  41075. property: string;
  41076. value: any;
  41077. initialValue: any;
  41078. }>;
  41079. /**
  41080. * Instantiates a new debug layer.
  41081. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41082. * what is happening in your scene
  41083. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41084. * @param scene Defines the scene to inspect
  41085. */
  41086. constructor(scene: Scene);
  41087. /** Creates the inspector window. */
  41088. private _createInspector;
  41089. /** Get the inspector from bundle or global */
  41090. private _getGlobalInspector;
  41091. /**
  41092. * Get if the inspector is visible or not.
  41093. * @returns true if visible otherwise, false
  41094. */
  41095. isVisible(): boolean;
  41096. /**
  41097. * Hide the inspector and close its window.
  41098. */
  41099. hide(): void;
  41100. /**
  41101. * Launch the debugLayer.
  41102. * @param config Define the configuration of the inspector
  41103. */
  41104. show(config?: IInspectorOptions): void;
  41105. }
  41106. }
  41107. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41108. import { Nullable } from "babylonjs/types";
  41109. import { Scene } from "babylonjs/scene";
  41110. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41111. import { Mesh } from "babylonjs/Meshes/mesh";
  41112. /**
  41113. * Class containing static functions to help procedurally build meshes
  41114. */
  41115. export class BoxBuilder {
  41116. /**
  41117. * Creates a box mesh
  41118. * * The parameter `size` sets the size (float) of each box side (default 1)
  41119. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41120. * * 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)
  41121. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41125. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41126. * @param name defines the name of the mesh
  41127. * @param options defines the options used to create the mesh
  41128. * @param scene defines the hosting scene
  41129. * @returns the box mesh
  41130. */
  41131. static CreateBox(name: string, options: {
  41132. size?: number;
  41133. width?: number;
  41134. height?: number;
  41135. depth?: number;
  41136. faceUV?: Vector4[];
  41137. faceColors?: Color4[];
  41138. sideOrientation?: number;
  41139. frontUVs?: Vector4;
  41140. backUVs?: Vector4;
  41141. updatable?: boolean;
  41142. }, scene?: Nullable<Scene>): Mesh;
  41143. }
  41144. }
  41145. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41146. import { Vector4 } from "babylonjs/Maths/math";
  41147. import { Mesh } from "babylonjs/Meshes/mesh";
  41148. /**
  41149. * Class containing static functions to help procedurally build meshes
  41150. */
  41151. export class SphereBuilder {
  41152. /**
  41153. * Creates a sphere mesh
  41154. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41155. * * 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`)
  41156. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41157. * * 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
  41158. * * 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)
  41159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41162. * @param name defines the name of the mesh
  41163. * @param options defines the options used to create the mesh
  41164. * @param scene defines the hosting scene
  41165. * @returns the sphere mesh
  41166. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41167. */
  41168. static CreateSphere(name: string, options: {
  41169. segments?: number;
  41170. diameter?: number;
  41171. diameterX?: number;
  41172. diameterY?: number;
  41173. diameterZ?: number;
  41174. arc?: number;
  41175. slice?: number;
  41176. sideOrientation?: number;
  41177. frontUVs?: Vector4;
  41178. backUVs?: Vector4;
  41179. updatable?: boolean;
  41180. }, scene: any): Mesh;
  41181. }
  41182. }
  41183. declare module "babylonjs/Debug/physicsViewer" {
  41184. import { Nullable } from "babylonjs/types";
  41185. import { Scene } from "babylonjs/scene";
  41186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41187. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41188. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41189. /**
  41190. * Used to show the physics impostor around the specific mesh
  41191. */
  41192. export class PhysicsViewer {
  41193. /** @hidden */
  41194. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41195. /** @hidden */
  41196. protected _meshes: Array<Nullable<AbstractMesh>>;
  41197. /** @hidden */
  41198. protected _scene: Nullable<Scene>;
  41199. /** @hidden */
  41200. protected _numMeshes: number;
  41201. /** @hidden */
  41202. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41203. private _renderFunction;
  41204. private _utilityLayer;
  41205. private _debugBoxMesh;
  41206. private _debugSphereMesh;
  41207. private _debugMaterial;
  41208. /**
  41209. * Creates a new PhysicsViewer
  41210. * @param scene defines the hosting scene
  41211. */
  41212. constructor(scene: Scene);
  41213. /** @hidden */
  41214. protected _updateDebugMeshes(): void;
  41215. /**
  41216. * Renders a specified physic impostor
  41217. * @param impostor defines the impostor to render
  41218. * @returns the new debug mesh used to render the impostor
  41219. */
  41220. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41221. /**
  41222. * Hides a specified physic impostor
  41223. * @param impostor defines the impostor to hide
  41224. */
  41225. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41226. private _getDebugMaterial;
  41227. private _getDebugBoxMesh;
  41228. private _getDebugSphereMesh;
  41229. private _getDebugMesh;
  41230. /** Releases all resources */
  41231. dispose(): void;
  41232. }
  41233. }
  41234. declare module "babylonjs/Debug/rayHelper" {
  41235. import { Nullable } from "babylonjs/types";
  41236. import { Ray } from "babylonjs/Culling/ray";
  41237. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41238. import { Scene } from "babylonjs/scene";
  41239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41240. import "babylonjs/Meshes/Builders/linesBuilder";
  41241. /**
  41242. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41243. * in order to better appreciate the issue one might have.
  41244. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41245. */
  41246. export class RayHelper {
  41247. /**
  41248. * Defines the ray we are currently tryin to visualize.
  41249. */
  41250. ray: Nullable<Ray>;
  41251. private _renderPoints;
  41252. private _renderLine;
  41253. private _renderFunction;
  41254. private _scene;
  41255. private _updateToMeshFunction;
  41256. private _attachedToMesh;
  41257. private _meshSpaceDirection;
  41258. private _meshSpaceOrigin;
  41259. /**
  41260. * Helper function to create a colored helper in a scene in one line.
  41261. * @param ray Defines the ray we are currently tryin to visualize
  41262. * @param scene Defines the scene the ray is used in
  41263. * @param color Defines the color we want to see the ray in
  41264. * @returns The newly created ray helper.
  41265. */
  41266. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41267. /**
  41268. * Instantiate a new ray helper.
  41269. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41270. * in order to better appreciate the issue one might have.
  41271. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41272. * @param ray Defines the ray we are currently tryin to visualize
  41273. */
  41274. constructor(ray: Ray);
  41275. /**
  41276. * Shows the ray we are willing to debug.
  41277. * @param scene Defines the scene the ray needs to be rendered in
  41278. * @param color Defines the color the ray needs to be rendered in
  41279. */
  41280. show(scene: Scene, color?: Color3): void;
  41281. /**
  41282. * Hides the ray we are debugging.
  41283. */
  41284. hide(): void;
  41285. private _render;
  41286. /**
  41287. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41288. * @param mesh Defines the mesh we want the helper attached to
  41289. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41290. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41291. * @param length Defines the length of the ray
  41292. */
  41293. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41294. /**
  41295. * Detach the ray helper from the mesh it has previously been attached to.
  41296. */
  41297. detachFromMesh(): void;
  41298. private _updateToMesh;
  41299. /**
  41300. * Dispose the helper and release its associated resources.
  41301. */
  41302. dispose(): void;
  41303. }
  41304. }
  41305. declare module "babylonjs/Debug/skeletonViewer" {
  41306. import { Color3 } from "babylonjs/Maths/math";
  41307. import { Scene } from "babylonjs/scene";
  41308. import { Nullable } from "babylonjs/types";
  41309. import { Skeleton } from "babylonjs/Bones/skeleton";
  41310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41311. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41312. /**
  41313. * Class used to render a debug view of a given skeleton
  41314. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41315. */
  41316. export class SkeletonViewer {
  41317. /** defines the skeleton to render */
  41318. skeleton: Skeleton;
  41319. /** defines the mesh attached to the skeleton */
  41320. mesh: AbstractMesh;
  41321. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41322. autoUpdateBonesMatrices: boolean;
  41323. /** defines the rendering group id to use with the viewer */
  41324. renderingGroupId: number;
  41325. /** Gets or sets the color used to render the skeleton */
  41326. color: Color3;
  41327. private _scene;
  41328. private _debugLines;
  41329. private _debugMesh;
  41330. private _isEnabled;
  41331. private _renderFunction;
  41332. private _utilityLayer;
  41333. /**
  41334. * Returns the mesh used to render the bones
  41335. */
  41336. readonly debugMesh: Nullable<LinesMesh>;
  41337. /**
  41338. * Creates a new SkeletonViewer
  41339. * @param skeleton defines the skeleton to render
  41340. * @param mesh defines the mesh attached to the skeleton
  41341. * @param scene defines the hosting scene
  41342. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41343. * @param renderingGroupId defines the rendering group id to use with the viewer
  41344. */
  41345. constructor(
  41346. /** defines the skeleton to render */
  41347. skeleton: Skeleton,
  41348. /** defines the mesh attached to the skeleton */
  41349. mesh: AbstractMesh, scene: Scene,
  41350. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41351. autoUpdateBonesMatrices?: boolean,
  41352. /** defines the rendering group id to use with the viewer */
  41353. renderingGroupId?: number);
  41354. /** Gets or sets a boolean indicating if the viewer is enabled */
  41355. isEnabled: boolean;
  41356. private _getBonePosition;
  41357. private _getLinesForBonesWithLength;
  41358. private _getLinesForBonesNoLength;
  41359. /** Update the viewer to sync with current skeleton state */
  41360. update(): void;
  41361. /** Release associated resources */
  41362. dispose(): void;
  41363. }
  41364. }
  41365. declare module "babylonjs/Debug/index" {
  41366. export * from "babylonjs/Debug/axesViewer";
  41367. export * from "babylonjs/Debug/boneAxesViewer";
  41368. export * from "babylonjs/Debug/debugLayer";
  41369. export * from "babylonjs/Debug/physicsViewer";
  41370. export * from "babylonjs/Debug/rayHelper";
  41371. export * from "babylonjs/Debug/skeletonViewer";
  41372. }
  41373. declare module "babylonjs/Engines/nullEngine" {
  41374. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41375. import { Scene } from "babylonjs/scene";
  41376. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41377. import { Engine } from "babylonjs/Engines/engine";
  41378. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41379. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41381. import { Effect } from "babylonjs/Materials/effect";
  41382. /**
  41383. * Options to create the null engine
  41384. */
  41385. export class NullEngineOptions {
  41386. /**
  41387. * Render width (Default: 512)
  41388. */
  41389. renderWidth: number;
  41390. /**
  41391. * Render height (Default: 256)
  41392. */
  41393. renderHeight: number;
  41394. /**
  41395. * Texture size (Default: 512)
  41396. */
  41397. textureSize: number;
  41398. /**
  41399. * If delta time between frames should be constant
  41400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41401. */
  41402. deterministicLockstep: boolean;
  41403. /**
  41404. * Maximum about of steps between frames (Default: 4)
  41405. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41406. */
  41407. lockstepMaxSteps: number;
  41408. }
  41409. /**
  41410. * The null engine class provides support for headless version of babylon.js.
  41411. * This can be used in server side scenario or for testing purposes
  41412. */
  41413. export class NullEngine extends Engine {
  41414. private _options;
  41415. /**
  41416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41417. */
  41418. isDeterministicLockStep(): boolean;
  41419. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41420. getLockstepMaxSteps(): number;
  41421. /**
  41422. * Sets hardware scaling, used to save performance if needed
  41423. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41424. */
  41425. getHardwareScalingLevel(): number;
  41426. constructor(options?: NullEngineOptions);
  41427. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41428. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41429. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41430. getRenderWidth(useScreen?: boolean): number;
  41431. getRenderHeight(useScreen?: boolean): number;
  41432. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41433. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41434. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41435. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41436. bindSamplers(effect: Effect): void;
  41437. enableEffect(effect: Effect): void;
  41438. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41439. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41440. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41441. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41442. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41443. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41444. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41445. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41446. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41447. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41448. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41449. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41450. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41451. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41452. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41453. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41454. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41455. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41456. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41457. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41458. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41459. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41460. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41461. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41462. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41463. bindBuffers(vertexBuffers: {
  41464. [key: string]: VertexBuffer;
  41465. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41466. wipeCaches(bruteForce?: boolean): void;
  41467. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41468. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41469. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41470. /** @hidden */
  41471. _createTexture(): WebGLTexture;
  41472. /** @hidden */
  41473. _releaseTexture(texture: InternalTexture): void;
  41474. 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;
  41475. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41476. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41477. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41479. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41480. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41481. areAllEffectsReady(): boolean;
  41482. /**
  41483. * @hidden
  41484. * Get the current error code of the webGL context
  41485. * @returns the error code
  41486. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41487. */
  41488. getError(): number;
  41489. /** @hidden */
  41490. _getUnpackAlignement(): number;
  41491. /** @hidden */
  41492. _unpackFlipY(value: boolean): void;
  41493. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41494. /**
  41495. * Updates a dynamic vertex buffer.
  41496. * @param vertexBuffer the vertex buffer to update
  41497. * @param data the data used to update the vertex buffer
  41498. * @param byteOffset the byte offset of the data (optional)
  41499. * @param byteLength the byte length of the data (optional)
  41500. */
  41501. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41502. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41503. /** @hidden */
  41504. _bindTexture(channel: number, texture: InternalTexture): void;
  41505. /** @hidden */
  41506. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41507. releaseEffects(): void;
  41508. displayLoadingUI(): void;
  41509. hideLoadingUI(): void;
  41510. /** @hidden */
  41511. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41512. /** @hidden */
  41513. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41514. /** @hidden */
  41515. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41516. /** @hidden */
  41517. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41518. }
  41519. }
  41520. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41521. import { Nullable, int } from "babylonjs/types";
  41522. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41523. /** @hidden */
  41524. export class _OcclusionDataStorage {
  41525. /** @hidden */
  41526. occlusionInternalRetryCounter: number;
  41527. /** @hidden */
  41528. isOcclusionQueryInProgress: boolean;
  41529. /** @hidden */
  41530. isOccluded: boolean;
  41531. /** @hidden */
  41532. occlusionRetryCount: number;
  41533. /** @hidden */
  41534. occlusionType: number;
  41535. /** @hidden */
  41536. occlusionQueryAlgorithmType: number;
  41537. }
  41538. module "babylonjs/Engines/engine" {
  41539. interface Engine {
  41540. /**
  41541. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41542. * @return the new query
  41543. */
  41544. createQuery(): WebGLQuery;
  41545. /**
  41546. * Delete and release a webGL query
  41547. * @param query defines the query to delete
  41548. * @return the current engine
  41549. */
  41550. deleteQuery(query: WebGLQuery): Engine;
  41551. /**
  41552. * Check if a given query has resolved and got its value
  41553. * @param query defines the query to check
  41554. * @returns true if the query got its value
  41555. */
  41556. isQueryResultAvailable(query: WebGLQuery): boolean;
  41557. /**
  41558. * Gets the value of a given query
  41559. * @param query defines the query to check
  41560. * @returns the value of the query
  41561. */
  41562. getQueryResult(query: WebGLQuery): number;
  41563. /**
  41564. * Initiates an occlusion query
  41565. * @param algorithmType defines the algorithm to use
  41566. * @param query defines the query to use
  41567. * @returns the current engine
  41568. * @see http://doc.babylonjs.com/features/occlusionquery
  41569. */
  41570. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41571. /**
  41572. * Ends an occlusion query
  41573. * @see http://doc.babylonjs.com/features/occlusionquery
  41574. * @param algorithmType defines the algorithm to use
  41575. * @returns the current engine
  41576. */
  41577. endOcclusionQuery(algorithmType: number): Engine;
  41578. /**
  41579. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41580. * Please note that only one query can be issued at a time
  41581. * @returns a time token used to track the time span
  41582. */
  41583. startTimeQuery(): Nullable<_TimeToken>;
  41584. /**
  41585. * Ends a time query
  41586. * @param token defines the token used to measure the time span
  41587. * @returns the time spent (in ns)
  41588. */
  41589. endTimeQuery(token: _TimeToken): int;
  41590. /** @hidden */
  41591. _currentNonTimestampToken: Nullable<_TimeToken>;
  41592. /** @hidden */
  41593. _createTimeQuery(): WebGLQuery;
  41594. /** @hidden */
  41595. _deleteTimeQuery(query: WebGLQuery): void;
  41596. /** @hidden */
  41597. _getGlAlgorithmType(algorithmType: number): number;
  41598. /** @hidden */
  41599. _getTimeQueryResult(query: WebGLQuery): any;
  41600. /** @hidden */
  41601. _getTimeQueryAvailability(query: WebGLQuery): any;
  41602. }
  41603. }
  41604. module "babylonjs/Meshes/abstractMesh" {
  41605. interface AbstractMesh {
  41606. /**
  41607. * Backing filed
  41608. * @hidden
  41609. */
  41610. __occlusionDataStorage: _OcclusionDataStorage;
  41611. /**
  41612. * Access property
  41613. * @hidden
  41614. */
  41615. _occlusionDataStorage: _OcclusionDataStorage;
  41616. /**
  41617. * 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.
  41618. * The default value is -1 which means don't break the query and wait till the result
  41619. * @see http://doc.babylonjs.com/features/occlusionquery
  41620. */
  41621. occlusionRetryCount: number;
  41622. /**
  41623. * 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:
  41624. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41625. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41626. * * 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.
  41627. * @see http://doc.babylonjs.com/features/occlusionquery
  41628. */
  41629. occlusionType: number;
  41630. /**
  41631. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41632. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41633. * * 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.
  41634. * @see http://doc.babylonjs.com/features/occlusionquery
  41635. */
  41636. occlusionQueryAlgorithmType: number;
  41637. /**
  41638. * 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
  41639. * @see http://doc.babylonjs.com/features/occlusionquery
  41640. */
  41641. isOccluded: boolean;
  41642. /**
  41643. * Flag to check the progress status of the query
  41644. * @see http://doc.babylonjs.com/features/occlusionquery
  41645. */
  41646. isOcclusionQueryInProgress: boolean;
  41647. }
  41648. }
  41649. }
  41650. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41651. import { Nullable } from "babylonjs/types";
  41652. /** @hidden */
  41653. export var _forceTransformFeedbackToBundle: boolean;
  41654. module "babylonjs/Engines/engine" {
  41655. interface Engine {
  41656. /**
  41657. * Creates a webGL transform feedback object
  41658. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41659. * @returns the webGL transform feedback object
  41660. */
  41661. createTransformFeedback(): WebGLTransformFeedback;
  41662. /**
  41663. * Delete a webGL transform feedback object
  41664. * @param value defines the webGL transform feedback object to delete
  41665. */
  41666. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41667. /**
  41668. * Bind a webGL transform feedback object to the webgl context
  41669. * @param value defines the webGL transform feedback object to bind
  41670. */
  41671. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41672. /**
  41673. * Begins a transform feedback operation
  41674. * @param usePoints defines if points or triangles must be used
  41675. */
  41676. beginTransformFeedback(usePoints: boolean): void;
  41677. /**
  41678. * Ends a transform feedback operation
  41679. */
  41680. endTransformFeedback(): void;
  41681. /**
  41682. * Specify the varyings to use with transform feedback
  41683. * @param program defines the associated webGL program
  41684. * @param value defines the list of strings representing the varying names
  41685. */
  41686. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41687. /**
  41688. * Bind a webGL buffer for a transform feedback operation
  41689. * @param value defines the webGL buffer to bind
  41690. */
  41691. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41692. }
  41693. }
  41694. }
  41695. declare module "babylonjs/Engines/Extensions/index" {
  41696. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41697. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41698. }
  41699. declare module "babylonjs/Engines/index" {
  41700. export * from "babylonjs/Engines/constants";
  41701. export * from "babylonjs/Engines/engine";
  41702. export * from "babylonjs/Engines/engineStore";
  41703. export * from "babylonjs/Engines/nullEngine";
  41704. export * from "babylonjs/Engines/Extensions/index";
  41705. }
  41706. declare module "babylonjs/Events/clipboardEvents" {
  41707. /**
  41708. * Gather the list of clipboard event types as constants.
  41709. */
  41710. export class ClipboardEventTypes {
  41711. /**
  41712. * The clipboard event is fired when a copy command is active (pressed).
  41713. */
  41714. static readonly COPY: number;
  41715. /**
  41716. * The clipboard event is fired when a cut command is active (pressed).
  41717. */
  41718. static readonly CUT: number;
  41719. /**
  41720. * The clipboard event is fired when a paste command is active (pressed).
  41721. */
  41722. static readonly PASTE: number;
  41723. }
  41724. /**
  41725. * This class is used to store clipboard related info for the onClipboardObservable event.
  41726. */
  41727. export class ClipboardInfo {
  41728. /**
  41729. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41730. */
  41731. type: number;
  41732. /**
  41733. * Defines the related dom event
  41734. */
  41735. event: ClipboardEvent;
  41736. /**
  41737. *Creates an instance of ClipboardInfo.
  41738. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41739. * @param event Defines the related dom event
  41740. */
  41741. constructor(
  41742. /**
  41743. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41744. */
  41745. type: number,
  41746. /**
  41747. * Defines the related dom event
  41748. */
  41749. event: ClipboardEvent);
  41750. /**
  41751. * Get the clipboard event's type from the keycode.
  41752. * @param keyCode Defines the keyCode for the current keyboard event.
  41753. * @return {number}
  41754. */
  41755. static GetTypeFromCharacter(keyCode: number): number;
  41756. }
  41757. }
  41758. declare module "babylonjs/Events/index" {
  41759. export * from "babylonjs/Events/keyboardEvents";
  41760. export * from "babylonjs/Events/pointerEvents";
  41761. export * from "babylonjs/Events/clipboardEvents";
  41762. }
  41763. declare module "babylonjs/Loading/sceneLoader" {
  41764. import { Observable } from "babylonjs/Misc/observable";
  41765. import { Nullable } from "babylonjs/types";
  41766. import { Scene } from "babylonjs/scene";
  41767. import { Engine } from "babylonjs/Engines/engine";
  41768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41770. import { AssetContainer } from "babylonjs/assetContainer";
  41771. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41772. import { Skeleton } from "babylonjs/Bones/skeleton";
  41773. /**
  41774. * Class used to represent data loading progression
  41775. */
  41776. export class SceneLoaderProgressEvent {
  41777. /** defines if data length to load can be evaluated */
  41778. readonly lengthComputable: boolean;
  41779. /** defines the loaded data length */
  41780. readonly loaded: number;
  41781. /** defines the data length to load */
  41782. readonly total: number;
  41783. /**
  41784. * Create a new progress event
  41785. * @param lengthComputable defines if data length to load can be evaluated
  41786. * @param loaded defines the loaded data length
  41787. * @param total defines the data length to load
  41788. */
  41789. constructor(
  41790. /** defines if data length to load can be evaluated */
  41791. lengthComputable: boolean,
  41792. /** defines the loaded data length */
  41793. loaded: number,
  41794. /** defines the data length to load */
  41795. total: number);
  41796. /**
  41797. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41798. * @param event defines the source event
  41799. * @returns a new SceneLoaderProgressEvent
  41800. */
  41801. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41802. }
  41803. /**
  41804. * Interface used by SceneLoader plugins to define supported file extensions
  41805. */
  41806. export interface ISceneLoaderPluginExtensions {
  41807. /**
  41808. * Defines the list of supported extensions
  41809. */
  41810. [extension: string]: {
  41811. isBinary: boolean;
  41812. };
  41813. }
  41814. /**
  41815. * Interface used by SceneLoader plugin factory
  41816. */
  41817. export interface ISceneLoaderPluginFactory {
  41818. /**
  41819. * Defines the name of the factory
  41820. */
  41821. name: string;
  41822. /**
  41823. * Function called to create a new plugin
  41824. * @return the new plugin
  41825. */
  41826. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41827. /**
  41828. * Boolean indicating if the plugin can direct load specific data
  41829. */
  41830. canDirectLoad?: (data: string) => boolean;
  41831. }
  41832. /**
  41833. * Interface used to define a SceneLoader plugin
  41834. */
  41835. export interface ISceneLoaderPlugin {
  41836. /**
  41837. * The friendly name of this plugin.
  41838. */
  41839. name: string;
  41840. /**
  41841. * The file extensions supported by this plugin.
  41842. */
  41843. extensions: string | ISceneLoaderPluginExtensions;
  41844. /**
  41845. * Import meshes into a scene.
  41846. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41847. * @param scene The scene to import into
  41848. * @param data The data to import
  41849. * @param rootUrl The root url for scene and resources
  41850. * @param meshes The meshes array to import into
  41851. * @param particleSystems The particle systems array to import into
  41852. * @param skeletons The skeletons array to import into
  41853. * @param onError The callback when import fails
  41854. * @returns True if successful or false otherwise
  41855. */
  41856. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41857. /**
  41858. * Load into a scene.
  41859. * @param scene The scene to load into
  41860. * @param data The data to import
  41861. * @param rootUrl The root url for scene and resources
  41862. * @param onError The callback when import fails
  41863. * @returns true if successful or false otherwise
  41864. */
  41865. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41866. /**
  41867. * The callback that returns true if the data can be directly loaded.
  41868. */
  41869. canDirectLoad?: (data: string) => boolean;
  41870. /**
  41871. * The callback that allows custom handling of the root url based on the response url.
  41872. */
  41873. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41874. /**
  41875. * Load into an asset container.
  41876. * @param scene The scene to load into
  41877. * @param data The data to import
  41878. * @param rootUrl The root url for scene and resources
  41879. * @param onError The callback when import fails
  41880. * @returns The loaded asset container
  41881. */
  41882. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41883. }
  41884. /**
  41885. * Interface used to define an async SceneLoader plugin
  41886. */
  41887. export interface ISceneLoaderPluginAsync {
  41888. /**
  41889. * The friendly name of this plugin.
  41890. */
  41891. name: string;
  41892. /**
  41893. * The file extensions supported by this plugin.
  41894. */
  41895. extensions: string | ISceneLoaderPluginExtensions;
  41896. /**
  41897. * Import meshes into a scene.
  41898. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41899. * @param scene The scene to import into
  41900. * @param data The data to import
  41901. * @param rootUrl The root url for scene and resources
  41902. * @param onProgress The callback when the load progresses
  41903. * @param fileName Defines the name of the file to load
  41904. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41905. */
  41906. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41907. meshes: AbstractMesh[];
  41908. particleSystems: IParticleSystem[];
  41909. skeletons: Skeleton[];
  41910. animationGroups: AnimationGroup[];
  41911. }>;
  41912. /**
  41913. * Load into a scene.
  41914. * @param scene The scene to load into
  41915. * @param data The data to import
  41916. * @param rootUrl The root url for scene and resources
  41917. * @param onProgress The callback when the load progresses
  41918. * @param fileName Defines the name of the file to load
  41919. * @returns Nothing
  41920. */
  41921. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41922. /**
  41923. * The callback that returns true if the data can be directly loaded.
  41924. */
  41925. canDirectLoad?: (data: string) => boolean;
  41926. /**
  41927. * The callback that allows custom handling of the root url based on the response url.
  41928. */
  41929. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41930. /**
  41931. * Load into an asset container.
  41932. * @param scene The scene to load into
  41933. * @param data The data to import
  41934. * @param rootUrl The root url for scene and resources
  41935. * @param onProgress The callback when the load progresses
  41936. * @param fileName Defines the name of the file to load
  41937. * @returns The loaded asset container
  41938. */
  41939. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41940. }
  41941. /**
  41942. * Class used to load scene from various file formats using registered plugins
  41943. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41944. */
  41945. export class SceneLoader {
  41946. /**
  41947. * No logging while loading
  41948. */
  41949. static readonly NO_LOGGING: number;
  41950. /**
  41951. * Minimal logging while loading
  41952. */
  41953. static readonly MINIMAL_LOGGING: number;
  41954. /**
  41955. * Summary logging while loading
  41956. */
  41957. static readonly SUMMARY_LOGGING: number;
  41958. /**
  41959. * Detailled logging while loading
  41960. */
  41961. static readonly DETAILED_LOGGING: number;
  41962. /**
  41963. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41964. */
  41965. static ForceFullSceneLoadingForIncremental: boolean;
  41966. /**
  41967. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41968. */
  41969. static ShowLoadingScreen: boolean;
  41970. /**
  41971. * Defines the current logging level (while loading the scene)
  41972. * @ignorenaming
  41973. */
  41974. static loggingLevel: number;
  41975. /**
  41976. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41977. */
  41978. static CleanBoneMatrixWeights: boolean;
  41979. /**
  41980. * Event raised when a plugin is used to load a scene
  41981. */
  41982. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41983. private static _registeredPlugins;
  41984. private static _getDefaultPlugin;
  41985. private static _getPluginForExtension;
  41986. private static _getPluginForDirectLoad;
  41987. private static _getPluginForFilename;
  41988. private static _getDirectLoad;
  41989. private static _loadData;
  41990. private static _getFileInfo;
  41991. /**
  41992. * Gets a plugin that can load the given extension
  41993. * @param extension defines the extension to load
  41994. * @returns a plugin or null if none works
  41995. */
  41996. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41997. /**
  41998. * Gets a boolean indicating that the given extension can be loaded
  41999. * @param extension defines the extension to load
  42000. * @returns true if the extension is supported
  42001. */
  42002. static IsPluginForExtensionAvailable(extension: string): boolean;
  42003. /**
  42004. * Adds a new plugin to the list of registered plugins
  42005. * @param plugin defines the plugin to add
  42006. */
  42007. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42008. /**
  42009. * Import meshes into a scene
  42010. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42011. * @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)
  42012. * @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)
  42013. * @param scene the instance of BABYLON.Scene to append to
  42014. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42015. * @param onProgress a callback with a progress event for each file being loaded
  42016. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42017. * @param pluginExtension the extension used to determine the plugin
  42018. * @returns The loaded plugin
  42019. */
  42020. 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>;
  42021. /**
  42022. * Import meshes into a scene
  42023. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42024. * @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)
  42025. * @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)
  42026. * @param scene the instance of BABYLON.Scene to append to
  42027. * @param onProgress a callback with a progress event for each file being loaded
  42028. * @param pluginExtension the extension used to determine the plugin
  42029. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42030. */
  42031. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42032. meshes: AbstractMesh[];
  42033. particleSystems: IParticleSystem[];
  42034. skeletons: Skeleton[];
  42035. animationGroups: AnimationGroup[];
  42036. }>;
  42037. /**
  42038. * Load a scene
  42039. * @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)
  42040. * @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)
  42041. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42042. * @param onSuccess a callback with the scene when import succeeds
  42043. * @param onProgress a callback with a progress event for each file being loaded
  42044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42045. * @param pluginExtension the extension used to determine the plugin
  42046. * @returns The loaded plugin
  42047. */
  42048. 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>;
  42049. /**
  42050. * Load a scene
  42051. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42052. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42053. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42054. * @param onProgress a callback with a progress event for each file being loaded
  42055. * @param pluginExtension the extension used to determine the plugin
  42056. * @returns The loaded scene
  42057. */
  42058. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42059. /**
  42060. * Append a scene
  42061. * @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)
  42062. * @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)
  42063. * @param scene is the instance of BABYLON.Scene to append to
  42064. * @param onSuccess a callback with the scene when import succeeds
  42065. * @param onProgress a callback with a progress event for each file being loaded
  42066. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42067. * @param pluginExtension the extension used to determine the plugin
  42068. * @returns The loaded plugin
  42069. */
  42070. 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>;
  42071. /**
  42072. * Append a scene
  42073. * @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)
  42074. * @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)
  42075. * @param scene is the instance of BABYLON.Scene to append to
  42076. * @param onProgress a callback with a progress event for each file being loaded
  42077. * @param pluginExtension the extension used to determine the plugin
  42078. * @returns The given scene
  42079. */
  42080. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42081. /**
  42082. * Load a scene into an asset container
  42083. * @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)
  42084. * @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)
  42085. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42086. * @param onSuccess a callback with the scene when import succeeds
  42087. * @param onProgress a callback with a progress event for each file being loaded
  42088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42089. * @param pluginExtension the extension used to determine the plugin
  42090. * @returns The loaded plugin
  42091. */
  42092. 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>;
  42093. /**
  42094. * Load a scene into an asset container
  42095. * @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)
  42096. * @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)
  42097. * @param scene is the instance of Scene to append to
  42098. * @param onProgress a callback with a progress event for each file being loaded
  42099. * @param pluginExtension the extension used to determine the plugin
  42100. * @returns The loaded asset container
  42101. */
  42102. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42103. }
  42104. }
  42105. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42106. import { Scene } from "babylonjs/scene";
  42107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42108. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42109. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42110. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42111. /**
  42112. * Google Daydream controller
  42113. */
  42114. export class DaydreamController extends WebVRController {
  42115. /**
  42116. * Base Url for the controller model.
  42117. */
  42118. static MODEL_BASE_URL: string;
  42119. /**
  42120. * File name for the controller model.
  42121. */
  42122. static MODEL_FILENAME: string;
  42123. /**
  42124. * Gamepad Id prefix used to identify Daydream Controller.
  42125. */
  42126. static readonly GAMEPAD_ID_PREFIX: string;
  42127. /**
  42128. * Creates a new DaydreamController from a gamepad
  42129. * @param vrGamepad the gamepad that the controller should be created from
  42130. */
  42131. constructor(vrGamepad: any);
  42132. /**
  42133. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42134. * @param scene scene in which to add meshes
  42135. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42136. */
  42137. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42138. /**
  42139. * Called once for each button that changed state since the last frame
  42140. * @param buttonIdx Which button index changed
  42141. * @param state New state of the button
  42142. * @param changes Which properties on the state changed since last frame
  42143. */
  42144. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42145. }
  42146. }
  42147. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42148. import { Scene } from "babylonjs/scene";
  42149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42150. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42151. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42152. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42153. /**
  42154. * Gear VR Controller
  42155. */
  42156. export class GearVRController extends WebVRController {
  42157. /**
  42158. * Base Url for the controller model.
  42159. */
  42160. static MODEL_BASE_URL: string;
  42161. /**
  42162. * File name for the controller model.
  42163. */
  42164. static MODEL_FILENAME: string;
  42165. /**
  42166. * Gamepad Id prefix used to identify this controller.
  42167. */
  42168. static readonly GAMEPAD_ID_PREFIX: string;
  42169. private readonly _buttonIndexToObservableNameMap;
  42170. /**
  42171. * Creates a new GearVRController from a gamepad
  42172. * @param vrGamepad the gamepad that the controller should be created from
  42173. */
  42174. constructor(vrGamepad: any);
  42175. /**
  42176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42177. * @param scene scene in which to add meshes
  42178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42179. */
  42180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42181. /**
  42182. * Called once for each button that changed state since the last frame
  42183. * @param buttonIdx Which button index changed
  42184. * @param state New state of the button
  42185. * @param changes Which properties on the state changed since last frame
  42186. */
  42187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42188. }
  42189. }
  42190. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42191. import { Scene } from "babylonjs/scene";
  42192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42193. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42194. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42195. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42196. /**
  42197. * Generic Controller
  42198. */
  42199. export class GenericController extends WebVRController {
  42200. /**
  42201. * Base Url for the controller model.
  42202. */
  42203. static readonly MODEL_BASE_URL: string;
  42204. /**
  42205. * File name for the controller model.
  42206. */
  42207. static readonly MODEL_FILENAME: string;
  42208. /**
  42209. * Creates a new GenericController from a gamepad
  42210. * @param vrGamepad the gamepad that the controller should be created from
  42211. */
  42212. constructor(vrGamepad: any);
  42213. /**
  42214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42215. * @param scene scene in which to add meshes
  42216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42217. */
  42218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42219. /**
  42220. * Called once for each button that changed state since the last frame
  42221. * @param buttonIdx Which button index changed
  42222. * @param state New state of the button
  42223. * @param changes Which properties on the state changed since last frame
  42224. */
  42225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42226. }
  42227. }
  42228. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42229. import { Observable } from "babylonjs/Misc/observable";
  42230. import { Scene } from "babylonjs/scene";
  42231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42232. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42233. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42234. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42235. /**
  42236. * Oculus Touch Controller
  42237. */
  42238. export class OculusTouchController extends WebVRController {
  42239. /**
  42240. * Base Url for the controller model.
  42241. */
  42242. static MODEL_BASE_URL: string;
  42243. /**
  42244. * File name for the left controller model.
  42245. */
  42246. static MODEL_LEFT_FILENAME: string;
  42247. /**
  42248. * File name for the right controller model.
  42249. */
  42250. static MODEL_RIGHT_FILENAME: string;
  42251. /**
  42252. * Fired when the secondary trigger on this controller is modified
  42253. */
  42254. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the thumb rest on this controller is modified
  42257. */
  42258. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Creates a new OculusTouchController from a gamepad
  42261. * @param vrGamepad the gamepad that the controller should be created from
  42262. */
  42263. constructor(vrGamepad: any);
  42264. /**
  42265. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42266. * @param scene scene in which to add meshes
  42267. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42268. */
  42269. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42270. /**
  42271. * Fired when the A button on this controller is modified
  42272. */
  42273. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42274. /**
  42275. * Fired when the B button on this controller is modified
  42276. */
  42277. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42278. /**
  42279. * Fired when the X button on this controller is modified
  42280. */
  42281. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42282. /**
  42283. * Fired when the Y button on this controller is modified
  42284. */
  42285. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42286. /**
  42287. * Called once for each button that changed state since the last frame
  42288. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42289. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42290. * 2) secondary trigger (same)
  42291. * 3) A (right) X (left), touch, pressed = value
  42292. * 4) B / Y
  42293. * 5) thumb rest
  42294. * @param buttonIdx Which button index changed
  42295. * @param state New state of the button
  42296. * @param changes Which properties on the state changed since last frame
  42297. */
  42298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42299. }
  42300. }
  42301. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42302. import { Scene } from "babylonjs/scene";
  42303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42304. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42305. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42306. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42307. import { Observable } from "babylonjs/Misc/observable";
  42308. /**
  42309. * Vive Controller
  42310. */
  42311. export class ViveController extends WebVRController {
  42312. /**
  42313. * Base Url for the controller model.
  42314. */
  42315. static MODEL_BASE_URL: string;
  42316. /**
  42317. * File name for the controller model.
  42318. */
  42319. static MODEL_FILENAME: string;
  42320. /**
  42321. * Creates a new ViveController from a gamepad
  42322. * @param vrGamepad the gamepad that the controller should be created from
  42323. */
  42324. constructor(vrGamepad: any);
  42325. /**
  42326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42327. * @param scene scene in which to add meshes
  42328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42329. */
  42330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42331. /**
  42332. * Fired when the left button on this controller is modified
  42333. */
  42334. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42335. /**
  42336. * Fired when the right button on this controller is modified
  42337. */
  42338. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42339. /**
  42340. * Fired when the menu button on this controller is modified
  42341. */
  42342. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42343. /**
  42344. * Called once for each button that changed state since the last frame
  42345. * Vive mapping:
  42346. * 0: touchpad
  42347. * 1: trigger
  42348. * 2: left AND right buttons
  42349. * 3: menu button
  42350. * @param buttonIdx Which button index changed
  42351. * @param state New state of the button
  42352. * @param changes Which properties on the state changed since last frame
  42353. */
  42354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42355. }
  42356. }
  42357. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42358. import { Observable } from "babylonjs/Misc/observable";
  42359. import { Scene } from "babylonjs/scene";
  42360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42361. import { Ray } from "babylonjs/Culling/ray";
  42362. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42363. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42364. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42365. /**
  42366. * Defines the WindowsMotionController object that the state of the windows motion controller
  42367. */
  42368. export class WindowsMotionController extends WebVRController {
  42369. /**
  42370. * The base url used to load the left and right controller models
  42371. */
  42372. static MODEL_BASE_URL: string;
  42373. /**
  42374. * The name of the left controller model file
  42375. */
  42376. static MODEL_LEFT_FILENAME: string;
  42377. /**
  42378. * The name of the right controller model file
  42379. */
  42380. static MODEL_RIGHT_FILENAME: string;
  42381. /**
  42382. * The controller name prefix for this controller type
  42383. */
  42384. static readonly GAMEPAD_ID_PREFIX: string;
  42385. /**
  42386. * The controller id pattern for this controller type
  42387. */
  42388. private static readonly GAMEPAD_ID_PATTERN;
  42389. private _loadedMeshInfo;
  42390. private readonly _mapping;
  42391. /**
  42392. * Fired when the trackpad on this controller is clicked
  42393. */
  42394. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42395. /**
  42396. * Fired when the trackpad on this controller is modified
  42397. */
  42398. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42399. /**
  42400. * The current x and y values of this controller's trackpad
  42401. */
  42402. trackpad: StickValues;
  42403. /**
  42404. * Creates a new WindowsMotionController from a gamepad
  42405. * @param vrGamepad the gamepad that the controller should be created from
  42406. */
  42407. constructor(vrGamepad: any);
  42408. /**
  42409. * Fired when the trigger on this controller is modified
  42410. */
  42411. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42412. /**
  42413. * Fired when the menu button on this controller is modified
  42414. */
  42415. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42416. /**
  42417. * Fired when the grip button on this controller is modified
  42418. */
  42419. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42420. /**
  42421. * Fired when the thumbstick button on this controller is modified
  42422. */
  42423. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42424. /**
  42425. * Fired when the touchpad button on this controller is modified
  42426. */
  42427. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42428. /**
  42429. * Fired when the touchpad values on this controller are modified
  42430. */
  42431. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42432. private _updateTrackpad;
  42433. /**
  42434. * Called once per frame by the engine.
  42435. */
  42436. update(): void;
  42437. /**
  42438. * Called once for each button that changed state since the last frame
  42439. * @param buttonIdx Which button index changed
  42440. * @param state New state of the button
  42441. * @param changes Which properties on the state changed since last frame
  42442. */
  42443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42444. /**
  42445. * Moves the buttons on the controller mesh based on their current state
  42446. * @param buttonName the name of the button to move
  42447. * @param buttonValue the value of the button which determines the buttons new position
  42448. */
  42449. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42450. /**
  42451. * Moves the axis on the controller mesh based on its current state
  42452. * @param axis the index of the axis
  42453. * @param axisValue the value of the axis which determines the meshes new position
  42454. * @hidden
  42455. */
  42456. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42457. /**
  42458. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42459. * @param scene scene in which to add meshes
  42460. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42461. */
  42462. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42463. /**
  42464. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42465. * can be transformed by button presses and axes values, based on this._mapping.
  42466. *
  42467. * @param scene scene in which the meshes exist
  42468. * @param meshes list of meshes that make up the controller model to process
  42469. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42470. */
  42471. private processModel;
  42472. private createMeshInfo;
  42473. /**
  42474. * Gets the ray of the controller in the direction the controller is pointing
  42475. * @param length the length the resulting ray should be
  42476. * @returns a ray in the direction the controller is pointing
  42477. */
  42478. getForwardRay(length?: number): Ray;
  42479. /**
  42480. * Disposes of the controller
  42481. */
  42482. dispose(): void;
  42483. }
  42484. }
  42485. declare module "babylonjs/Gamepads/Controllers/index" {
  42486. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42487. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42488. export * from "babylonjs/Gamepads/Controllers/genericController";
  42489. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42490. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42491. export * from "babylonjs/Gamepads/Controllers/viveController";
  42492. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42493. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42494. }
  42495. declare module "babylonjs/Gamepads/index" {
  42496. export * from "babylonjs/Gamepads/Controllers/index";
  42497. export * from "babylonjs/Gamepads/gamepad";
  42498. export * from "babylonjs/Gamepads/gamepadManager";
  42499. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42500. export * from "babylonjs/Gamepads/xboxGamepad";
  42501. }
  42502. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42503. import { Observable } from "babylonjs/Misc/observable";
  42504. import { Nullable } from "babylonjs/types";
  42505. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42507. import { Mesh } from "babylonjs/Meshes/mesh";
  42508. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42509. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42510. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42511. /**
  42512. * Single axis scale gizmo
  42513. */
  42514. export class AxisScaleGizmo extends Gizmo {
  42515. private _coloredMaterial;
  42516. /**
  42517. * Drag behavior responsible for the gizmos dragging interactions
  42518. */
  42519. dragBehavior: PointerDragBehavior;
  42520. private _pointerObserver;
  42521. /**
  42522. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42523. */
  42524. snapDistance: number;
  42525. /**
  42526. * Event that fires each time the gizmo snaps to a new location.
  42527. * * snapDistance is the the change in distance
  42528. */
  42529. onSnapObservable: Observable<{
  42530. snapDistance: number;
  42531. }>;
  42532. /**
  42533. * If the scaling operation should be done on all axis (default: false)
  42534. */
  42535. uniformScaling: boolean;
  42536. /**
  42537. * Creates an AxisScaleGizmo
  42538. * @param gizmoLayer The utility layer the gizmo will be added to
  42539. * @param dragAxis The axis which the gizmo will be able to scale on
  42540. * @param color The color of the gizmo
  42541. */
  42542. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42544. /**
  42545. * Disposes of the gizmo
  42546. */
  42547. dispose(): void;
  42548. /**
  42549. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42550. * @param mesh The mesh to replace the default mesh of the gizmo
  42551. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42552. */
  42553. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42554. }
  42555. }
  42556. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42557. import { Observable } from "babylonjs/Misc/observable";
  42558. import { Nullable } from "babylonjs/types";
  42559. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42561. import { Mesh } from "babylonjs/Meshes/mesh";
  42562. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42563. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42564. import "babylonjs/Meshes/Builders/boxBuilder";
  42565. /**
  42566. * Bounding box gizmo
  42567. */
  42568. export class BoundingBoxGizmo extends Gizmo {
  42569. private _lineBoundingBox;
  42570. private _rotateSpheresParent;
  42571. private _scaleBoxesParent;
  42572. private _boundingDimensions;
  42573. private _renderObserver;
  42574. private _pointerObserver;
  42575. private _scaleDragSpeed;
  42576. private _tmpQuaternion;
  42577. private _tmpVector;
  42578. private _tmpRotationMatrix;
  42579. /**
  42580. * 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)
  42581. */
  42582. ignoreChildren: boolean;
  42583. /**
  42584. * 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)
  42585. */
  42586. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42587. /**
  42588. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42589. */
  42590. rotationSphereSize: number;
  42591. /**
  42592. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42593. */
  42594. scaleBoxSize: number;
  42595. /**
  42596. * 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)
  42597. */
  42598. fixedDragMeshScreenSize: boolean;
  42599. /**
  42600. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42601. */
  42602. fixedDragMeshScreenSizeDistanceFactor: number;
  42603. /**
  42604. * Fired when a rotation sphere or scale box is dragged
  42605. */
  42606. onDragStartObservable: Observable<{}>;
  42607. /**
  42608. * Fired when a scale box is dragged
  42609. */
  42610. onScaleBoxDragObservable: Observable<{}>;
  42611. /**
  42612. * Fired when a scale box drag is ended
  42613. */
  42614. onScaleBoxDragEndObservable: Observable<{}>;
  42615. /**
  42616. * Fired when a rotation sphere is dragged
  42617. */
  42618. onRotationSphereDragObservable: Observable<{}>;
  42619. /**
  42620. * Fired when a rotation sphere drag is ended
  42621. */
  42622. onRotationSphereDragEndObservable: Observable<{}>;
  42623. /**
  42624. * 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)
  42625. */
  42626. scalePivot: Nullable<Vector3>;
  42627. private _anchorMesh;
  42628. private _existingMeshScale;
  42629. private _dragMesh;
  42630. private pointerDragBehavior;
  42631. /**
  42632. * Creates an BoundingBoxGizmo
  42633. * @param gizmoLayer The utility layer the gizmo will be added to
  42634. * @param color The color of the gizmo
  42635. */
  42636. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42637. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42638. private _selectNode;
  42639. /**
  42640. * Updates the bounding box information for the Gizmo
  42641. */
  42642. updateBoundingBox(): void;
  42643. private _updateRotationSpheres;
  42644. private _updateScaleBoxes;
  42645. /**
  42646. * Enables rotation on the specified axis and disables rotation on the others
  42647. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42648. */
  42649. setEnabledRotationAxis(axis: string): void;
  42650. /**
  42651. * Enables/disables scaling
  42652. * @param enable if scaling should be enabled
  42653. */
  42654. setEnabledScaling(enable: boolean): void;
  42655. private _updateDummy;
  42656. /**
  42657. * Enables a pointer drag behavior on the bounding box of the gizmo
  42658. */
  42659. enableDragBehavior(): void;
  42660. /**
  42661. * Disposes of the gizmo
  42662. */
  42663. dispose(): void;
  42664. /**
  42665. * 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)
  42666. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42667. * @returns the bounding box mesh with the passed in mesh as a child
  42668. */
  42669. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42670. /**
  42671. * CustomMeshes are not supported by this gizmo
  42672. * @param mesh The mesh to replace the default mesh of the gizmo
  42673. */
  42674. setCustomMesh(mesh: Mesh): void;
  42675. }
  42676. }
  42677. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42678. import { Observable } from "babylonjs/Misc/observable";
  42679. import { Nullable } from "babylonjs/types";
  42680. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42682. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42683. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42684. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42685. import "babylonjs/Meshes/Builders/linesBuilder";
  42686. /**
  42687. * Single plane rotation gizmo
  42688. */
  42689. export class PlaneRotationGizmo extends Gizmo {
  42690. /**
  42691. * Drag behavior responsible for the gizmos dragging interactions
  42692. */
  42693. dragBehavior: PointerDragBehavior;
  42694. private _pointerObserver;
  42695. /**
  42696. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42697. */
  42698. snapDistance: number;
  42699. /**
  42700. * Event that fires each time the gizmo snaps to a new location.
  42701. * * snapDistance is the the change in distance
  42702. */
  42703. onSnapObservable: Observable<{
  42704. snapDistance: number;
  42705. }>;
  42706. /**
  42707. * Creates a PlaneRotationGizmo
  42708. * @param gizmoLayer The utility layer the gizmo will be added to
  42709. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42710. * @param color The color of the gizmo
  42711. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42712. */
  42713. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42714. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42715. /**
  42716. * Disposes of the gizmo
  42717. */
  42718. dispose(): void;
  42719. }
  42720. }
  42721. declare module "babylonjs/Gizmos/rotationGizmo" {
  42722. import { Observable } from "babylonjs/Misc/observable";
  42723. import { Nullable } from "babylonjs/types";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { Mesh } from "babylonjs/Meshes/mesh";
  42726. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42727. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42728. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42729. /**
  42730. * Gizmo that enables rotating a mesh along 3 axis
  42731. */
  42732. export class RotationGizmo extends Gizmo {
  42733. /**
  42734. * Internal gizmo used for interactions on the x axis
  42735. */
  42736. xGizmo: PlaneRotationGizmo;
  42737. /**
  42738. * Internal gizmo used for interactions on the y axis
  42739. */
  42740. yGizmo: PlaneRotationGizmo;
  42741. /**
  42742. * Internal gizmo used for interactions on the z axis
  42743. */
  42744. zGizmo: PlaneRotationGizmo;
  42745. /** Fires an event when any of it's sub gizmos are dragged */
  42746. onDragStartObservable: Observable<{}>;
  42747. /** Fires an event when any of it's sub gizmos are released from dragging */
  42748. onDragEndObservable: Observable<{}>;
  42749. attachedMesh: Nullable<AbstractMesh>;
  42750. /**
  42751. * Creates a RotationGizmo
  42752. * @param gizmoLayer The utility layer the gizmo will be added to
  42753. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42754. */
  42755. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42756. updateGizmoRotationToMatchAttachedMesh: boolean;
  42757. /**
  42758. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42759. */
  42760. snapDistance: number;
  42761. /**
  42762. * Ratio for the scale of the gizmo (Default: 1)
  42763. */
  42764. scaleRatio: number;
  42765. /**
  42766. * Disposes of the gizmo
  42767. */
  42768. dispose(): void;
  42769. /**
  42770. * CustomMeshes are not supported by this gizmo
  42771. * @param mesh The mesh to replace the default mesh of the gizmo
  42772. */
  42773. setCustomMesh(mesh: Mesh): void;
  42774. }
  42775. }
  42776. declare module "babylonjs/Gizmos/positionGizmo" {
  42777. import { Observable } from "babylonjs/Misc/observable";
  42778. import { Nullable } from "babylonjs/types";
  42779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42780. import { Mesh } from "babylonjs/Meshes/mesh";
  42781. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42782. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42783. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42784. /**
  42785. * Gizmo that enables dragging a mesh along 3 axis
  42786. */
  42787. export class PositionGizmo extends Gizmo {
  42788. /**
  42789. * Internal gizmo used for interactions on the x axis
  42790. */
  42791. xGizmo: AxisDragGizmo;
  42792. /**
  42793. * Internal gizmo used for interactions on the y axis
  42794. */
  42795. yGizmo: AxisDragGizmo;
  42796. /**
  42797. * Internal gizmo used for interactions on the z axis
  42798. */
  42799. zGizmo: AxisDragGizmo;
  42800. /** Fires an event when any of it's sub gizmos are dragged */
  42801. onDragStartObservable: Observable<{}>;
  42802. /** Fires an event when any of it's sub gizmos are released from dragging */
  42803. onDragEndObservable: Observable<{}>;
  42804. attachedMesh: Nullable<AbstractMesh>;
  42805. /**
  42806. * Creates a PositionGizmo
  42807. * @param gizmoLayer The utility layer the gizmo will be added to
  42808. */
  42809. constructor(gizmoLayer?: UtilityLayerRenderer);
  42810. updateGizmoRotationToMatchAttachedMesh: boolean;
  42811. /**
  42812. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42813. */
  42814. snapDistance: number;
  42815. /**
  42816. * Ratio for the scale of the gizmo (Default: 1)
  42817. */
  42818. scaleRatio: number;
  42819. /**
  42820. * Disposes of the gizmo
  42821. */
  42822. dispose(): void;
  42823. /**
  42824. * CustomMeshes are not supported by this gizmo
  42825. * @param mesh The mesh to replace the default mesh of the gizmo
  42826. */
  42827. setCustomMesh(mesh: Mesh): void;
  42828. }
  42829. }
  42830. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42831. import { Scene } from "babylonjs/scene";
  42832. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42833. import { Mesh } from "babylonjs/Meshes/mesh";
  42834. /**
  42835. * Class containing static functions to help procedurally build meshes
  42836. */
  42837. export class PolyhedronBuilder {
  42838. /**
  42839. * Creates a polyhedron mesh
  42840. * * 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
  42841. * * The parameter `size` (positive float, default 1) sets the polygon size
  42842. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42843. * * 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`
  42844. * * 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
  42845. * * 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)`)
  42846. * * 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
  42847. * * 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
  42848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42851. * @param name defines the name of the mesh
  42852. * @param options defines the options used to create the mesh
  42853. * @param scene defines the hosting scene
  42854. * @returns the polyhedron mesh
  42855. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42856. */
  42857. static CreatePolyhedron(name: string, options: {
  42858. type?: number;
  42859. size?: number;
  42860. sizeX?: number;
  42861. sizeY?: number;
  42862. sizeZ?: number;
  42863. custom?: any;
  42864. faceUV?: Vector4[];
  42865. faceColors?: Color4[];
  42866. flat?: boolean;
  42867. updatable?: boolean;
  42868. sideOrientation?: number;
  42869. frontUVs?: Vector4;
  42870. backUVs?: Vector4;
  42871. }, scene: Scene): Mesh;
  42872. }
  42873. }
  42874. declare module "babylonjs/Gizmos/scaleGizmo" {
  42875. import { Observable } from "babylonjs/Misc/observable";
  42876. import { Nullable } from "babylonjs/types";
  42877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42878. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42879. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42880. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42881. /**
  42882. * Gizmo that enables scaling a mesh along 3 axis
  42883. */
  42884. export class ScaleGizmo extends Gizmo {
  42885. /**
  42886. * Internal gizmo used for interactions on the x axis
  42887. */
  42888. xGizmo: AxisScaleGizmo;
  42889. /**
  42890. * Internal gizmo used for interactions on the y axis
  42891. */
  42892. yGizmo: AxisScaleGizmo;
  42893. /**
  42894. * Internal gizmo used for interactions on the z axis
  42895. */
  42896. zGizmo: AxisScaleGizmo;
  42897. /**
  42898. * Internal gizmo used to scale all axis equally
  42899. */
  42900. uniformScaleGizmo: AxisScaleGizmo;
  42901. /** Fires an event when any of it's sub gizmos are dragged */
  42902. onDragStartObservable: Observable<{}>;
  42903. /** Fires an event when any of it's sub gizmos are released from dragging */
  42904. onDragEndObservable: Observable<{}>;
  42905. attachedMesh: Nullable<AbstractMesh>;
  42906. /**
  42907. * Creates a ScaleGizmo
  42908. * @param gizmoLayer The utility layer the gizmo will be added to
  42909. */
  42910. constructor(gizmoLayer?: UtilityLayerRenderer);
  42911. updateGizmoRotationToMatchAttachedMesh: boolean;
  42912. /**
  42913. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42914. */
  42915. snapDistance: number;
  42916. /**
  42917. * Ratio for the scale of the gizmo (Default: 1)
  42918. */
  42919. scaleRatio: number;
  42920. /**
  42921. * Disposes of the gizmo
  42922. */
  42923. dispose(): void;
  42924. }
  42925. }
  42926. declare module "babylonjs/Gizmos/gizmoManager" {
  42927. import { Observable } from "babylonjs/Misc/observable";
  42928. import { Nullable } from "babylonjs/types";
  42929. import { Scene, IDisposable } from "babylonjs/scene";
  42930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42931. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42932. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42933. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42934. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42935. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42936. /**
  42937. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42938. */
  42939. export class GizmoManager implements IDisposable {
  42940. private scene;
  42941. /**
  42942. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42943. */
  42944. gizmos: {
  42945. positionGizmo: Nullable<PositionGizmo>;
  42946. rotationGizmo: Nullable<RotationGizmo>;
  42947. scaleGizmo: Nullable<ScaleGizmo>;
  42948. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42949. };
  42950. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42951. clearGizmoOnEmptyPointerEvent: boolean;
  42952. /** Fires an event when the manager is attached to a mesh */
  42953. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42954. private _gizmosEnabled;
  42955. private _pointerObserver;
  42956. private _attachedMesh;
  42957. private _boundingBoxColor;
  42958. private _defaultUtilityLayer;
  42959. private _defaultKeepDepthUtilityLayer;
  42960. /**
  42961. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42962. */
  42963. boundingBoxDragBehavior: SixDofDragBehavior;
  42964. /**
  42965. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42966. */
  42967. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42968. /**
  42969. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42970. */
  42971. usePointerToAttachGizmos: boolean;
  42972. /**
  42973. * Instatiates a gizmo manager
  42974. * @param scene the scene to overlay the gizmos on top of
  42975. */
  42976. constructor(scene: Scene);
  42977. /**
  42978. * Attaches a set of gizmos to the specified mesh
  42979. * @param mesh The mesh the gizmo's should be attached to
  42980. */
  42981. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42982. /**
  42983. * If the position gizmo is enabled
  42984. */
  42985. positionGizmoEnabled: boolean;
  42986. /**
  42987. * If the rotation gizmo is enabled
  42988. */
  42989. rotationGizmoEnabled: boolean;
  42990. /**
  42991. * If the scale gizmo is enabled
  42992. */
  42993. scaleGizmoEnabled: boolean;
  42994. /**
  42995. * If the boundingBox gizmo is enabled
  42996. */
  42997. boundingBoxGizmoEnabled: boolean;
  42998. /**
  42999. * Disposes of the gizmo manager
  43000. */
  43001. dispose(): void;
  43002. }
  43003. }
  43004. declare module "babylonjs/Gizmos/index" {
  43005. export * from "babylonjs/Gizmos/axisDragGizmo";
  43006. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43007. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43008. export * from "babylonjs/Gizmos/gizmo";
  43009. export * from "babylonjs/Gizmos/gizmoManager";
  43010. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43011. export * from "babylonjs/Gizmos/positionGizmo";
  43012. export * from "babylonjs/Gizmos/rotationGizmo";
  43013. export * from "babylonjs/Gizmos/scaleGizmo";
  43014. }
  43015. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43016. /** @hidden */
  43017. export var backgroundFragmentDeclaration: {
  43018. name: string;
  43019. shader: string;
  43020. };
  43021. }
  43022. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43023. /** @hidden */
  43024. export var backgroundUboDeclaration: {
  43025. name: string;
  43026. shader: string;
  43027. };
  43028. }
  43029. declare module "babylonjs/Shaders/background.fragment" {
  43030. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43031. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43032. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43033. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43034. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43035. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43037. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43038. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43039. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43041. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43042. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43043. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43044. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43045. /** @hidden */
  43046. export var backgroundPixelShader: {
  43047. name: string;
  43048. shader: string;
  43049. };
  43050. }
  43051. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43052. /** @hidden */
  43053. export var backgroundVertexDeclaration: {
  43054. name: string;
  43055. shader: string;
  43056. };
  43057. }
  43058. declare module "babylonjs/Shaders/background.vertex" {
  43059. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43060. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43062. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43063. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43065. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43068. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43069. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43070. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43071. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43072. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43073. /** @hidden */
  43074. export var backgroundVertexShader: {
  43075. name: string;
  43076. shader: string;
  43077. };
  43078. }
  43079. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43080. import { Nullable, int, float } from "babylonjs/types";
  43081. import { Scene } from "babylonjs/scene";
  43082. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43085. import { Mesh } from "babylonjs/Meshes/mesh";
  43086. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43087. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43088. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43089. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43090. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43091. import "babylonjs/Shaders/background.fragment";
  43092. import "babylonjs/Shaders/background.vertex";
  43093. /**
  43094. * Background material used to create an efficient environement around your scene.
  43095. */
  43096. export class BackgroundMaterial extends PushMaterial {
  43097. /**
  43098. * Standard reflectance value at parallel view angle.
  43099. */
  43100. static StandardReflectance0: number;
  43101. /**
  43102. * Standard reflectance value at grazing angle.
  43103. */
  43104. static StandardReflectance90: number;
  43105. protected _primaryColor: Color3;
  43106. /**
  43107. * Key light Color (multiply against the environement texture)
  43108. */
  43109. primaryColor: Color3;
  43110. protected __perceptualColor: Nullable<Color3>;
  43111. /**
  43112. * Experimental Internal Use Only.
  43113. *
  43114. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43115. * This acts as a helper to set the primary color to a more "human friendly" value.
  43116. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43117. * output color as close as possible from the chosen value.
  43118. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43119. * part of lighting setup.)
  43120. */
  43121. _perceptualColor: Nullable<Color3>;
  43122. protected _primaryColorShadowLevel: float;
  43123. /**
  43124. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43125. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43126. */
  43127. primaryColorShadowLevel: float;
  43128. protected _primaryColorHighlightLevel: float;
  43129. /**
  43130. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43131. * The primary color is used at the level chosen to define what the white area would look.
  43132. */
  43133. primaryColorHighlightLevel: float;
  43134. protected _reflectionTexture: Nullable<BaseTexture>;
  43135. /**
  43136. * Reflection Texture used in the material.
  43137. * Should be author in a specific way for the best result (refer to the documentation).
  43138. */
  43139. reflectionTexture: Nullable<BaseTexture>;
  43140. protected _reflectionBlur: float;
  43141. /**
  43142. * Reflection Texture level of blur.
  43143. *
  43144. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43145. * texture twice.
  43146. */
  43147. reflectionBlur: float;
  43148. protected _diffuseTexture: Nullable<BaseTexture>;
  43149. /**
  43150. * Diffuse Texture used in the material.
  43151. * Should be author in a specific way for the best result (refer to the documentation).
  43152. */
  43153. diffuseTexture: Nullable<BaseTexture>;
  43154. protected _shadowLights: Nullable<IShadowLight[]>;
  43155. /**
  43156. * Specify the list of lights casting shadow on the material.
  43157. * All scene shadow lights will be included if null.
  43158. */
  43159. shadowLights: Nullable<IShadowLight[]>;
  43160. protected _shadowLevel: float;
  43161. /**
  43162. * Helps adjusting the shadow to a softer level if required.
  43163. * 0 means black shadows and 1 means no shadows.
  43164. */
  43165. shadowLevel: float;
  43166. protected _sceneCenter: Vector3;
  43167. /**
  43168. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43169. * It is usually zero but might be interesting to modify according to your setup.
  43170. */
  43171. sceneCenter: Vector3;
  43172. protected _opacityFresnel: boolean;
  43173. /**
  43174. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43175. * This helps ensuring a nice transition when the camera goes under the ground.
  43176. */
  43177. opacityFresnel: boolean;
  43178. protected _reflectionFresnel: boolean;
  43179. /**
  43180. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43181. * This helps adding a mirror texture on the ground.
  43182. */
  43183. reflectionFresnel: boolean;
  43184. protected _reflectionFalloffDistance: number;
  43185. /**
  43186. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43187. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43188. */
  43189. reflectionFalloffDistance: number;
  43190. protected _reflectionAmount: number;
  43191. /**
  43192. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43193. */
  43194. reflectionAmount: number;
  43195. protected _reflectionReflectance0: number;
  43196. /**
  43197. * This specifies the weight of the reflection at grazing angle.
  43198. */
  43199. reflectionReflectance0: number;
  43200. protected _reflectionReflectance90: number;
  43201. /**
  43202. * This specifies the weight of the reflection at a perpendicular point of view.
  43203. */
  43204. reflectionReflectance90: number;
  43205. /**
  43206. * Sets the reflection reflectance fresnel values according to the default standard
  43207. * empirically know to work well :-)
  43208. */
  43209. reflectionStandardFresnelWeight: number;
  43210. protected _useRGBColor: boolean;
  43211. /**
  43212. * Helps to directly use the maps channels instead of their level.
  43213. */
  43214. useRGBColor: boolean;
  43215. protected _enableNoise: boolean;
  43216. /**
  43217. * This helps reducing the banding effect that could occur on the background.
  43218. */
  43219. enableNoise: boolean;
  43220. /**
  43221. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43222. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43223. * Recommended to be keep at 1.0 except for special cases.
  43224. */
  43225. fovMultiplier: number;
  43226. private _fovMultiplier;
  43227. /**
  43228. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43229. */
  43230. useEquirectangularFOV: boolean;
  43231. private _maxSimultaneousLights;
  43232. /**
  43233. * Number of Simultaneous lights allowed on the material.
  43234. */
  43235. maxSimultaneousLights: int;
  43236. /**
  43237. * Default configuration related to image processing available in the Background Material.
  43238. */
  43239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43240. /**
  43241. * Keep track of the image processing observer to allow dispose and replace.
  43242. */
  43243. private _imageProcessingObserver;
  43244. /**
  43245. * Attaches a new image processing configuration to the PBR Material.
  43246. * @param configuration (if null the scene configuration will be use)
  43247. */
  43248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43249. /**
  43250. * Gets the image processing configuration used either in this material.
  43251. */
  43252. /**
  43253. * Sets the Default image processing configuration used either in the this material.
  43254. *
  43255. * If sets to null, the scene one is in use.
  43256. */
  43257. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43258. /**
  43259. * Gets wether the color curves effect is enabled.
  43260. */
  43261. /**
  43262. * Sets wether the color curves effect is enabled.
  43263. */
  43264. cameraColorCurvesEnabled: boolean;
  43265. /**
  43266. * Gets wether the color grading effect is enabled.
  43267. */
  43268. /**
  43269. * Gets wether the color grading effect is enabled.
  43270. */
  43271. cameraColorGradingEnabled: boolean;
  43272. /**
  43273. * Gets wether tonemapping is enabled or not.
  43274. */
  43275. /**
  43276. * Sets wether tonemapping is enabled or not
  43277. */
  43278. cameraToneMappingEnabled: boolean;
  43279. /**
  43280. * The camera exposure used on this material.
  43281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43282. * This corresponds to a photographic exposure.
  43283. */
  43284. /**
  43285. * The camera exposure used on this material.
  43286. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43287. * This corresponds to a photographic exposure.
  43288. */
  43289. cameraExposure: float;
  43290. /**
  43291. * Gets The camera contrast used on this material.
  43292. */
  43293. /**
  43294. * Sets The camera contrast used on this material.
  43295. */
  43296. cameraContrast: float;
  43297. /**
  43298. * Gets the Color Grading 2D Lookup Texture.
  43299. */
  43300. /**
  43301. * Sets the Color Grading 2D Lookup Texture.
  43302. */
  43303. cameraColorGradingTexture: Nullable<BaseTexture>;
  43304. /**
  43305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43307. * 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;
  43308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43309. */
  43310. /**
  43311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43313. * 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;
  43314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43315. */
  43316. cameraColorCurves: Nullable<ColorCurves>;
  43317. /**
  43318. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43319. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43320. */
  43321. switchToBGR: boolean;
  43322. private _renderTargets;
  43323. private _reflectionControls;
  43324. private _white;
  43325. private _primaryShadowColor;
  43326. private _primaryHighlightColor;
  43327. /**
  43328. * Instantiates a Background Material in the given scene
  43329. * @param name The friendly name of the material
  43330. * @param scene The scene to add the material to
  43331. */
  43332. constructor(name: string, scene: Scene);
  43333. /**
  43334. * Gets a boolean indicating that current material needs to register RTT
  43335. */
  43336. readonly hasRenderTargetTextures: boolean;
  43337. /**
  43338. * The entire material has been created in order to prevent overdraw.
  43339. * @returns false
  43340. */
  43341. needAlphaTesting(): boolean;
  43342. /**
  43343. * The entire material has been created in order to prevent overdraw.
  43344. * @returns true if blending is enable
  43345. */
  43346. needAlphaBlending(): boolean;
  43347. /**
  43348. * Checks wether the material is ready to be rendered for a given mesh.
  43349. * @param mesh The mesh to render
  43350. * @param subMesh The submesh to check against
  43351. * @param useInstances Specify wether or not the material is used with instances
  43352. * @returns true if all the dependencies are ready (Textures, Effects...)
  43353. */
  43354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43355. /**
  43356. * Compute the primary color according to the chosen perceptual color.
  43357. */
  43358. private _computePrimaryColorFromPerceptualColor;
  43359. /**
  43360. * Compute the highlights and shadow colors according to their chosen levels.
  43361. */
  43362. private _computePrimaryColors;
  43363. /**
  43364. * Build the uniform buffer used in the material.
  43365. */
  43366. buildUniformLayout(): void;
  43367. /**
  43368. * Unbind the material.
  43369. */
  43370. unbind(): void;
  43371. /**
  43372. * Bind only the world matrix to the material.
  43373. * @param world The world matrix to bind.
  43374. */
  43375. bindOnlyWorldMatrix(world: Matrix): void;
  43376. /**
  43377. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43378. * @param world The world matrix to bind.
  43379. * @param subMesh The submesh to bind for.
  43380. */
  43381. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43382. /**
  43383. * Dispose the material.
  43384. * @param forceDisposeEffect Force disposal of the associated effect.
  43385. * @param forceDisposeTextures Force disposal of the associated textures.
  43386. */
  43387. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43388. /**
  43389. * Clones the material.
  43390. * @param name The cloned name.
  43391. * @returns The cloned material.
  43392. */
  43393. clone(name: string): BackgroundMaterial;
  43394. /**
  43395. * Serializes the current material to its JSON representation.
  43396. * @returns The JSON representation.
  43397. */
  43398. serialize(): any;
  43399. /**
  43400. * Gets the class name of the material
  43401. * @returns "BackgroundMaterial"
  43402. */
  43403. getClassName(): string;
  43404. /**
  43405. * Parse a JSON input to create back a background material.
  43406. * @param source The JSON data to parse
  43407. * @param scene The scene to create the parsed material in
  43408. * @param rootUrl The root url of the assets the material depends upon
  43409. * @returns the instantiated BackgroundMaterial.
  43410. */
  43411. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43412. }
  43413. }
  43414. declare module "babylonjs/Helpers/environmentHelper" {
  43415. import { Observable } from "babylonjs/Misc/observable";
  43416. import { Nullable } from "babylonjs/types";
  43417. import { Scene } from "babylonjs/scene";
  43418. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43420. import { Mesh } from "babylonjs/Meshes/mesh";
  43421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43422. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43423. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43424. import "babylonjs/Meshes/Builders/planeBuilder";
  43425. import "babylonjs/Meshes/Builders/boxBuilder";
  43426. /**
  43427. * Represents the different options available during the creation of
  43428. * a Environment helper.
  43429. *
  43430. * This can control the default ground, skybox and image processing setup of your scene.
  43431. */
  43432. export interface IEnvironmentHelperOptions {
  43433. /**
  43434. * Specifies wether or not to create a ground.
  43435. * True by default.
  43436. */
  43437. createGround: boolean;
  43438. /**
  43439. * Specifies the ground size.
  43440. * 15 by default.
  43441. */
  43442. groundSize: number;
  43443. /**
  43444. * The texture used on the ground for the main color.
  43445. * Comes from the BabylonJS CDN by default.
  43446. *
  43447. * Remarks: Can be either a texture or a url.
  43448. */
  43449. groundTexture: string | BaseTexture;
  43450. /**
  43451. * The color mixed in the ground texture by default.
  43452. * BabylonJS clearColor by default.
  43453. */
  43454. groundColor: Color3;
  43455. /**
  43456. * Specifies the ground opacity.
  43457. * 1 by default.
  43458. */
  43459. groundOpacity: number;
  43460. /**
  43461. * Enables the ground to receive shadows.
  43462. * True by default.
  43463. */
  43464. enableGroundShadow: boolean;
  43465. /**
  43466. * Helps preventing the shadow to be fully black on the ground.
  43467. * 0.5 by default.
  43468. */
  43469. groundShadowLevel: number;
  43470. /**
  43471. * Creates a mirror texture attach to the ground.
  43472. * false by default.
  43473. */
  43474. enableGroundMirror: boolean;
  43475. /**
  43476. * Specifies the ground mirror size ratio.
  43477. * 0.3 by default as the default kernel is 64.
  43478. */
  43479. groundMirrorSizeRatio: number;
  43480. /**
  43481. * Specifies the ground mirror blur kernel size.
  43482. * 64 by default.
  43483. */
  43484. groundMirrorBlurKernel: number;
  43485. /**
  43486. * Specifies the ground mirror visibility amount.
  43487. * 1 by default
  43488. */
  43489. groundMirrorAmount: number;
  43490. /**
  43491. * Specifies the ground mirror reflectance weight.
  43492. * This uses the standard weight of the background material to setup the fresnel effect
  43493. * of the mirror.
  43494. * 1 by default.
  43495. */
  43496. groundMirrorFresnelWeight: number;
  43497. /**
  43498. * Specifies the ground mirror Falloff distance.
  43499. * This can helps reducing the size of the reflection.
  43500. * 0 by Default.
  43501. */
  43502. groundMirrorFallOffDistance: number;
  43503. /**
  43504. * Specifies the ground mirror texture type.
  43505. * Unsigned Int by Default.
  43506. */
  43507. groundMirrorTextureType: number;
  43508. /**
  43509. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43510. * the shown objects.
  43511. */
  43512. groundYBias: number;
  43513. /**
  43514. * Specifies wether or not to create a skybox.
  43515. * True by default.
  43516. */
  43517. createSkybox: boolean;
  43518. /**
  43519. * Specifies the skybox size.
  43520. * 20 by default.
  43521. */
  43522. skyboxSize: number;
  43523. /**
  43524. * The texture used on the skybox for the main color.
  43525. * Comes from the BabylonJS CDN by default.
  43526. *
  43527. * Remarks: Can be either a texture or a url.
  43528. */
  43529. skyboxTexture: string | BaseTexture;
  43530. /**
  43531. * The color mixed in the skybox texture by default.
  43532. * BabylonJS clearColor by default.
  43533. */
  43534. skyboxColor: Color3;
  43535. /**
  43536. * The background rotation around the Y axis of the scene.
  43537. * This helps aligning the key lights of your scene with the background.
  43538. * 0 by default.
  43539. */
  43540. backgroundYRotation: number;
  43541. /**
  43542. * Compute automatically the size of the elements to best fit with the scene.
  43543. */
  43544. sizeAuto: boolean;
  43545. /**
  43546. * Default position of the rootMesh if autoSize is not true.
  43547. */
  43548. rootPosition: Vector3;
  43549. /**
  43550. * Sets up the image processing in the scene.
  43551. * true by default.
  43552. */
  43553. setupImageProcessing: boolean;
  43554. /**
  43555. * The texture used as your environment texture in the scene.
  43556. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43557. *
  43558. * Remarks: Can be either a texture or a url.
  43559. */
  43560. environmentTexture: string | BaseTexture;
  43561. /**
  43562. * The value of the exposure to apply to the scene.
  43563. * 0.6 by default if setupImageProcessing is true.
  43564. */
  43565. cameraExposure: number;
  43566. /**
  43567. * The value of the contrast to apply to the scene.
  43568. * 1.6 by default if setupImageProcessing is true.
  43569. */
  43570. cameraContrast: number;
  43571. /**
  43572. * Specifies wether or not tonemapping should be enabled in the scene.
  43573. * true by default if setupImageProcessing is true.
  43574. */
  43575. toneMappingEnabled: boolean;
  43576. }
  43577. /**
  43578. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43579. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43580. * It also helps with the default setup of your imageProcessing configuration.
  43581. */
  43582. export class EnvironmentHelper {
  43583. /**
  43584. * Default ground texture URL.
  43585. */
  43586. private static _groundTextureCDNUrl;
  43587. /**
  43588. * Default skybox texture URL.
  43589. */
  43590. private static _skyboxTextureCDNUrl;
  43591. /**
  43592. * Default environment texture URL.
  43593. */
  43594. private static _environmentTextureCDNUrl;
  43595. /**
  43596. * Creates the default options for the helper.
  43597. */
  43598. private static _getDefaultOptions;
  43599. private _rootMesh;
  43600. /**
  43601. * Gets the root mesh created by the helper.
  43602. */
  43603. readonly rootMesh: Mesh;
  43604. private _skybox;
  43605. /**
  43606. * Gets the skybox created by the helper.
  43607. */
  43608. readonly skybox: Nullable<Mesh>;
  43609. private _skyboxTexture;
  43610. /**
  43611. * Gets the skybox texture created by the helper.
  43612. */
  43613. readonly skyboxTexture: Nullable<BaseTexture>;
  43614. private _skyboxMaterial;
  43615. /**
  43616. * Gets the skybox material created by the helper.
  43617. */
  43618. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43619. private _ground;
  43620. /**
  43621. * Gets the ground mesh created by the helper.
  43622. */
  43623. readonly ground: Nullable<Mesh>;
  43624. private _groundTexture;
  43625. /**
  43626. * Gets the ground texture created by the helper.
  43627. */
  43628. readonly groundTexture: Nullable<BaseTexture>;
  43629. private _groundMirror;
  43630. /**
  43631. * Gets the ground mirror created by the helper.
  43632. */
  43633. readonly groundMirror: Nullable<MirrorTexture>;
  43634. /**
  43635. * Gets the ground mirror render list to helps pushing the meshes
  43636. * you wish in the ground reflection.
  43637. */
  43638. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43639. private _groundMaterial;
  43640. /**
  43641. * Gets the ground material created by the helper.
  43642. */
  43643. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43644. /**
  43645. * Stores the creation options.
  43646. */
  43647. private readonly _scene;
  43648. private _options;
  43649. /**
  43650. * This observable will be notified with any error during the creation of the environment,
  43651. * mainly texture creation errors.
  43652. */
  43653. onErrorObservable: Observable<{
  43654. message?: string;
  43655. exception?: any;
  43656. }>;
  43657. /**
  43658. * constructor
  43659. * @param options Defines the options we want to customize the helper
  43660. * @param scene The scene to add the material to
  43661. */
  43662. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43663. /**
  43664. * Updates the background according to the new options
  43665. * @param options
  43666. */
  43667. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43668. /**
  43669. * Sets the primary color of all the available elements.
  43670. * @param color the main color to affect to the ground and the background
  43671. */
  43672. setMainColor(color: Color3): void;
  43673. /**
  43674. * Setup the image processing according to the specified options.
  43675. */
  43676. private _setupImageProcessing;
  43677. /**
  43678. * Setup the environment texture according to the specified options.
  43679. */
  43680. private _setupEnvironmentTexture;
  43681. /**
  43682. * Setup the background according to the specified options.
  43683. */
  43684. private _setupBackground;
  43685. /**
  43686. * Get the scene sizes according to the setup.
  43687. */
  43688. private _getSceneSize;
  43689. /**
  43690. * Setup the ground according to the specified options.
  43691. */
  43692. private _setupGround;
  43693. /**
  43694. * Setup the ground material according to the specified options.
  43695. */
  43696. private _setupGroundMaterial;
  43697. /**
  43698. * Setup the ground diffuse texture according to the specified options.
  43699. */
  43700. private _setupGroundDiffuseTexture;
  43701. /**
  43702. * Setup the ground mirror texture according to the specified options.
  43703. */
  43704. private _setupGroundMirrorTexture;
  43705. /**
  43706. * Setup the ground to receive the mirror texture.
  43707. */
  43708. private _setupMirrorInGroundMaterial;
  43709. /**
  43710. * Setup the skybox according to the specified options.
  43711. */
  43712. private _setupSkybox;
  43713. /**
  43714. * Setup the skybox material according to the specified options.
  43715. */
  43716. private _setupSkyboxMaterial;
  43717. /**
  43718. * Setup the skybox reflection texture according to the specified options.
  43719. */
  43720. private _setupSkyboxReflectionTexture;
  43721. private _errorHandler;
  43722. /**
  43723. * Dispose all the elements created by the Helper.
  43724. */
  43725. dispose(): void;
  43726. }
  43727. }
  43728. declare module "babylonjs/Helpers/photoDome" {
  43729. import { Observable } from "babylonjs/Misc/observable";
  43730. import { Nullable } from "babylonjs/types";
  43731. import { Scene } from "babylonjs/scene";
  43732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43733. import { Mesh } from "babylonjs/Meshes/mesh";
  43734. import { Texture } from "babylonjs/Materials/Textures/texture";
  43735. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43736. import "babylonjs/Meshes/Builders/sphereBuilder";
  43737. /**
  43738. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43739. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43740. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43741. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43742. */
  43743. export class PhotoDome extends TransformNode {
  43744. private _useDirectMapping;
  43745. /**
  43746. * The texture being displayed on the sphere
  43747. */
  43748. protected _photoTexture: Texture;
  43749. /**
  43750. * Gets or sets the texture being displayed on the sphere
  43751. */
  43752. photoTexture: Texture;
  43753. /**
  43754. * Observable raised when an error occured while loading the 360 image
  43755. */
  43756. onLoadErrorObservable: Observable<string>;
  43757. /**
  43758. * The skybox material
  43759. */
  43760. protected _material: BackgroundMaterial;
  43761. /**
  43762. * The surface used for the skybox
  43763. */
  43764. protected _mesh: Mesh;
  43765. /**
  43766. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43767. * Also see the options.resolution property.
  43768. */
  43769. fovMultiplier: number;
  43770. /**
  43771. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43772. * @param name Element's name, child elements will append suffixes for their own names.
  43773. * @param urlsOfPhoto defines the url of the photo to display
  43774. * @param options defines an object containing optional or exposed sub element properties
  43775. * @param onError defines a callback called when an error occured while loading the texture
  43776. */
  43777. constructor(name: string, urlOfPhoto: string, options: {
  43778. resolution?: number;
  43779. size?: number;
  43780. useDirectMapping?: boolean;
  43781. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43782. /**
  43783. * Releases resources associated with this node.
  43784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43786. */
  43787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43788. }
  43789. }
  43790. declare module "babylonjs/Misc/textureTools" {
  43791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43792. import { Texture } from "babylonjs/Materials/Textures/texture";
  43793. import { Scene } from "babylonjs/scene";
  43794. /**
  43795. * Class used to host texture specific utilities
  43796. */
  43797. export class TextureTools {
  43798. /**
  43799. * Uses the GPU to create a copy texture rescaled at a given size
  43800. * @param texture Texture to copy from
  43801. * @param width defines the desired width
  43802. * @param height defines the desired height
  43803. * @param useBilinearMode defines if bilinear mode has to be used
  43804. * @return the generated texture
  43805. */
  43806. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43807. /**
  43808. * Gets an environment BRDF texture for a given scene
  43809. * @param scene defines the hosting scene
  43810. * @returns the environment BRDF texture
  43811. */
  43812. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43813. private static _environmentBRDFBase64Texture;
  43814. }
  43815. }
  43816. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43817. /** @hidden */
  43818. export var pbrFragmentDeclaration: {
  43819. name: string;
  43820. shader: string;
  43821. };
  43822. }
  43823. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43824. /** @hidden */
  43825. export var pbrUboDeclaration: {
  43826. name: string;
  43827. shader: string;
  43828. };
  43829. }
  43830. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43831. /** @hidden */
  43832. export var pbrFunctions: {
  43833. name: string;
  43834. shader: string;
  43835. };
  43836. }
  43837. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43838. /** @hidden */
  43839. export var harmonicsFunctions: {
  43840. name: string;
  43841. shader: string;
  43842. };
  43843. }
  43844. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43845. /** @hidden */
  43846. export var pbrLightFunctions: {
  43847. name: string;
  43848. shader: string;
  43849. };
  43850. }
  43851. declare module "babylonjs/Shaders/pbr.fragment" {
  43852. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43853. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43856. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43857. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43858. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43859. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43860. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43861. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43862. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43863. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43864. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43865. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43867. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43868. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43869. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43870. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43871. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43872. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43873. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43874. /** @hidden */
  43875. export var pbrPixelShader: {
  43876. name: string;
  43877. shader: string;
  43878. };
  43879. }
  43880. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43881. /** @hidden */
  43882. export var pbrVertexDeclaration: {
  43883. name: string;
  43884. shader: string;
  43885. };
  43886. }
  43887. declare module "babylonjs/Shaders/pbr.vertex" {
  43888. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43889. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43890. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43891. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43893. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43894. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43895. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43896. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43897. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43898. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43900. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43901. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43903. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43904. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43905. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43906. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43907. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43908. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43909. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43910. /** @hidden */
  43911. export var pbrVertexShader: {
  43912. name: string;
  43913. shader: string;
  43914. };
  43915. }
  43916. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43917. import { IAnimatable } from "babylonjs/Misc/tools";
  43918. import { Nullable } from "babylonjs/types";
  43919. import { Scene } from "babylonjs/scene";
  43920. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43923. import { Mesh } from "babylonjs/Meshes/mesh";
  43924. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43925. import { Material } from "babylonjs/Materials/material";
  43926. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43928. import "babylonjs/Shaders/pbr.fragment";
  43929. import "babylonjs/Shaders/pbr.vertex";
  43930. /**
  43931. * The Physically based material base class of BJS.
  43932. *
  43933. * This offers the main features of a standard PBR material.
  43934. * For more information, please refer to the documentation :
  43935. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43936. */
  43937. export abstract class PBRBaseMaterial extends PushMaterial {
  43938. /**
  43939. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43940. */
  43941. static readonly PBRMATERIAL_OPAQUE: number;
  43942. /**
  43943. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43944. */
  43945. static readonly PBRMATERIAL_ALPHATEST: number;
  43946. /**
  43947. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43948. */
  43949. static readonly PBRMATERIAL_ALPHABLEND: number;
  43950. /**
  43951. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43952. * They are also discarded below the alpha cutoff threshold to improve performances.
  43953. */
  43954. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43955. /**
  43956. * Defines the default value of how much AO map is occluding the analytical lights
  43957. * (point spot...).
  43958. */
  43959. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43960. /**
  43961. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43962. */
  43963. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43964. /**
  43965. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43966. * to enhance interoperability with other engines.
  43967. */
  43968. static readonly LIGHTFALLOFF_GLTF: number;
  43969. /**
  43970. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43971. * to enhance interoperability with other materials.
  43972. */
  43973. static readonly LIGHTFALLOFF_STANDARD: number;
  43974. /**
  43975. * Intensity of the direct lights e.g. the four lights available in your scene.
  43976. * This impacts both the direct diffuse and specular highlights.
  43977. */
  43978. protected _directIntensity: number;
  43979. /**
  43980. * Intensity of the emissive part of the material.
  43981. * This helps controlling the emissive effect without modifying the emissive color.
  43982. */
  43983. protected _emissiveIntensity: number;
  43984. /**
  43985. * Intensity of the environment e.g. how much the environment will light the object
  43986. * either through harmonics for rough material or through the refelction for shiny ones.
  43987. */
  43988. protected _environmentIntensity: number;
  43989. /**
  43990. * This is a special control allowing the reduction of the specular highlights coming from the
  43991. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43992. */
  43993. protected _specularIntensity: number;
  43994. /**
  43995. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43996. */
  43997. private _lightingInfos;
  43998. /**
  43999. * Debug Control allowing disabling the bump map on this material.
  44000. */
  44001. protected _disableBumpMap: boolean;
  44002. /**
  44003. * AKA Diffuse Texture in standard nomenclature.
  44004. */
  44005. protected _albedoTexture: BaseTexture;
  44006. /**
  44007. * AKA Occlusion Texture in other nomenclature.
  44008. */
  44009. protected _ambientTexture: BaseTexture;
  44010. /**
  44011. * AKA Occlusion Texture Intensity in other nomenclature.
  44012. */
  44013. protected _ambientTextureStrength: number;
  44014. /**
  44015. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44016. * 1 means it completely occludes it
  44017. * 0 mean it has no impact
  44018. */
  44019. protected _ambientTextureImpactOnAnalyticalLights: number;
  44020. /**
  44021. * Stores the alpha values in a texture.
  44022. */
  44023. protected _opacityTexture: BaseTexture;
  44024. /**
  44025. * Stores the reflection values in a texture.
  44026. */
  44027. protected _reflectionTexture: BaseTexture;
  44028. /**
  44029. * Stores the refraction values in a texture.
  44030. */
  44031. protected _refractionTexture: BaseTexture;
  44032. /**
  44033. * Stores the emissive values in a texture.
  44034. */
  44035. protected _emissiveTexture: BaseTexture;
  44036. /**
  44037. * AKA Specular texture in other nomenclature.
  44038. */
  44039. protected _reflectivityTexture: BaseTexture;
  44040. /**
  44041. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44042. */
  44043. protected _metallicTexture: BaseTexture;
  44044. /**
  44045. * Specifies the metallic scalar of the metallic/roughness workflow.
  44046. * Can also be used to scale the metalness values of the metallic texture.
  44047. */
  44048. protected _metallic: Nullable<number>;
  44049. /**
  44050. * Specifies the roughness scalar of the metallic/roughness workflow.
  44051. * Can also be used to scale the roughness values of the metallic texture.
  44052. */
  44053. protected _roughness: Nullable<number>;
  44054. /**
  44055. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44056. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44057. */
  44058. protected _microSurfaceTexture: BaseTexture;
  44059. /**
  44060. * Stores surface normal data used to displace a mesh in a texture.
  44061. */
  44062. protected _bumpTexture: BaseTexture;
  44063. /**
  44064. * Stores the pre-calculated light information of a mesh in a texture.
  44065. */
  44066. protected _lightmapTexture: BaseTexture;
  44067. /**
  44068. * The color of a material in ambient lighting.
  44069. */
  44070. protected _ambientColor: Color3;
  44071. /**
  44072. * AKA Diffuse Color in other nomenclature.
  44073. */
  44074. protected _albedoColor: Color3;
  44075. /**
  44076. * AKA Specular Color in other nomenclature.
  44077. */
  44078. protected _reflectivityColor: Color3;
  44079. /**
  44080. * The color applied when light is reflected from a material.
  44081. */
  44082. protected _reflectionColor: Color3;
  44083. /**
  44084. * The color applied when light is emitted from a material.
  44085. */
  44086. protected _emissiveColor: Color3;
  44087. /**
  44088. * AKA Glossiness in other nomenclature.
  44089. */
  44090. protected _microSurface: number;
  44091. /**
  44092. * source material index of refraction (IOR)' / 'destination material IOR.
  44093. */
  44094. protected _indexOfRefraction: number;
  44095. /**
  44096. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44097. */
  44098. protected _invertRefractionY: boolean;
  44099. /**
  44100. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44101. * Materials half opaque for instance using refraction could benefit from this control.
  44102. */
  44103. protected _linkRefractionWithTransparency: boolean;
  44104. /**
  44105. * Specifies that the material will use the light map as a show map.
  44106. */
  44107. protected _useLightmapAsShadowmap: boolean;
  44108. /**
  44109. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44110. * makes the reflect vector face the model (under horizon).
  44111. */
  44112. protected _useHorizonOcclusion: boolean;
  44113. /**
  44114. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44115. * too much the area relying on ambient texture to define their ambient occlusion.
  44116. */
  44117. protected _useRadianceOcclusion: boolean;
  44118. /**
  44119. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44120. */
  44121. protected _useAlphaFromAlbedoTexture: boolean;
  44122. /**
  44123. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44124. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44125. */
  44126. protected _useSpecularOverAlpha: boolean;
  44127. /**
  44128. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44129. */
  44130. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44131. /**
  44132. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44133. */
  44134. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44135. /**
  44136. * Specifies if the metallic texture contains the roughness information in its green channel.
  44137. */
  44138. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44139. /**
  44140. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44141. */
  44142. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44143. /**
  44144. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44145. */
  44146. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44147. /**
  44148. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44149. */
  44150. protected _useAmbientInGrayScale: boolean;
  44151. /**
  44152. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44153. * The material will try to infer what glossiness each pixel should be.
  44154. */
  44155. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44156. /**
  44157. * Defines the falloff type used in this material.
  44158. * It by default is Physical.
  44159. */
  44160. protected _lightFalloff: number;
  44161. /**
  44162. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44163. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44164. */
  44165. protected _useRadianceOverAlpha: boolean;
  44166. /**
  44167. * Allows using an object space normal map (instead of tangent space).
  44168. */
  44169. protected _useObjectSpaceNormalMap: boolean;
  44170. /**
  44171. * Allows using the bump map in parallax mode.
  44172. */
  44173. protected _useParallax: boolean;
  44174. /**
  44175. * Allows using the bump map in parallax occlusion mode.
  44176. */
  44177. protected _useParallaxOcclusion: boolean;
  44178. /**
  44179. * Controls the scale bias of the parallax mode.
  44180. */
  44181. protected _parallaxScaleBias: number;
  44182. /**
  44183. * If sets to true, disables all the lights affecting the material.
  44184. */
  44185. protected _disableLighting: boolean;
  44186. /**
  44187. * Number of Simultaneous lights allowed on the material.
  44188. */
  44189. protected _maxSimultaneousLights: number;
  44190. /**
  44191. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44192. */
  44193. protected _invertNormalMapX: boolean;
  44194. /**
  44195. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44196. */
  44197. protected _invertNormalMapY: boolean;
  44198. /**
  44199. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44200. */
  44201. protected _twoSidedLighting: boolean;
  44202. /**
  44203. * Defines the alpha limits in alpha test mode.
  44204. */
  44205. protected _alphaCutOff: number;
  44206. /**
  44207. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44208. */
  44209. protected _forceAlphaTest: boolean;
  44210. /**
  44211. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44212. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44213. */
  44214. protected _useAlphaFresnel: boolean;
  44215. /**
  44216. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44217. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44218. */
  44219. protected _useLinearAlphaFresnel: boolean;
  44220. /**
  44221. * The transparency mode of the material.
  44222. */
  44223. protected _transparencyMode: Nullable<number>;
  44224. /**
  44225. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44226. * from cos thetav and roughness:
  44227. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44228. */
  44229. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44230. /**
  44231. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44232. */
  44233. protected _forceIrradianceInFragment: boolean;
  44234. /**
  44235. * Force normal to face away from face.
  44236. */
  44237. protected _forceNormalForward: boolean;
  44238. /**
  44239. * Enables specular anti aliasing in the PBR shader.
  44240. * It will both interacts on the Geometry for analytical and IBL lighting.
  44241. * It also prefilter the roughness map based on the bump values.
  44242. */
  44243. protected _enableSpecularAntiAliasing: boolean;
  44244. /**
  44245. * Default configuration related to image processing available in the PBR Material.
  44246. */
  44247. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44248. /**
  44249. * Keep track of the image processing observer to allow dispose and replace.
  44250. */
  44251. private _imageProcessingObserver;
  44252. /**
  44253. * Attaches a new image processing configuration to the PBR Material.
  44254. * @param configuration
  44255. */
  44256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44257. /**
  44258. * Stores the available render targets.
  44259. */
  44260. private _renderTargets;
  44261. /**
  44262. * Sets the global ambient color for the material used in lighting calculations.
  44263. */
  44264. private _globalAmbientColor;
  44265. /**
  44266. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44267. */
  44268. private _useLogarithmicDepth;
  44269. /**
  44270. * If set to true, no lighting calculations will be applied.
  44271. */
  44272. private _unlit;
  44273. /**
  44274. * Instantiates a new PBRMaterial instance.
  44275. *
  44276. * @param name The material name
  44277. * @param scene The scene the material will be use in.
  44278. */
  44279. constructor(name: string, scene: Scene);
  44280. /**
  44281. * Gets a boolean indicating that current material needs to register RTT
  44282. */
  44283. readonly hasRenderTargetTextures: boolean;
  44284. /**
  44285. * Gets the name of the material class.
  44286. */
  44287. getClassName(): string;
  44288. /**
  44289. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44290. */
  44291. /**
  44292. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44293. */
  44294. useLogarithmicDepth: boolean;
  44295. /**
  44296. * Gets the current transparency mode.
  44297. */
  44298. /**
  44299. * Sets the transparency mode of the material.
  44300. *
  44301. * | Value | Type | Description |
  44302. * | ----- | ----------------------------------- | ----------- |
  44303. * | 0 | OPAQUE | |
  44304. * | 1 | ALPHATEST | |
  44305. * | 2 | ALPHABLEND | |
  44306. * | 3 | ALPHATESTANDBLEND | |
  44307. *
  44308. */
  44309. transparencyMode: Nullable<number>;
  44310. /**
  44311. * Returns true if alpha blending should be disabled.
  44312. */
  44313. private readonly _disableAlphaBlending;
  44314. /**
  44315. * Specifies whether or not this material should be rendered in alpha blend mode.
  44316. */
  44317. needAlphaBlending(): boolean;
  44318. /**
  44319. * Specifies if the mesh will require alpha blending.
  44320. * @param mesh - BJS mesh.
  44321. */
  44322. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44323. /**
  44324. * Specifies whether or not this material should be rendered in alpha test mode.
  44325. */
  44326. needAlphaTesting(): boolean;
  44327. /**
  44328. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44329. */
  44330. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44331. /**
  44332. * Gets the texture used for the alpha test.
  44333. */
  44334. getAlphaTestTexture(): BaseTexture;
  44335. /**
  44336. * Specifies that the submesh is ready to be used.
  44337. * @param mesh - BJS mesh.
  44338. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44339. * @param useInstances - Specifies that instances should be used.
  44340. * @returns - boolean indicating that the submesh is ready or not.
  44341. */
  44342. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44343. /**
  44344. * Specifies if the material uses metallic roughness workflow.
  44345. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44346. */
  44347. isMetallicWorkflow(): boolean;
  44348. private _prepareEffect;
  44349. private _prepareDefines;
  44350. /**
  44351. * Force shader compilation
  44352. */
  44353. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44354. clipPlane: boolean;
  44355. }>): void;
  44356. /**
  44357. * Initializes the uniform buffer layout for the shader.
  44358. */
  44359. buildUniformLayout(): void;
  44360. /**
  44361. * Unbinds the textures.
  44362. */
  44363. unbind(): void;
  44364. /**
  44365. * Binds the submesh data.
  44366. * @param world - The world matrix.
  44367. * @param mesh - The BJS mesh.
  44368. * @param subMesh - A submesh of the BJS mesh.
  44369. */
  44370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44371. /**
  44372. * Returns the animatable textures.
  44373. * @returns - Array of animatable textures.
  44374. */
  44375. getAnimatables(): IAnimatable[];
  44376. /**
  44377. * Returns the texture used for reflections.
  44378. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44379. */
  44380. private _getReflectionTexture;
  44381. /**
  44382. * Returns the texture used for refraction or null if none is used.
  44383. * @returns - Refection texture if present. If no refraction texture and refraction
  44384. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44385. */
  44386. private _getRefractionTexture;
  44387. /**
  44388. * Disposes the resources of the material.
  44389. * @param forceDisposeEffect - Forces the disposal of effects.
  44390. * @param forceDisposeTextures - Forces the disposal of all textures.
  44391. */
  44392. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44393. }
  44394. }
  44395. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44396. import { Nullable } from "babylonjs/types";
  44397. import { Scene } from "babylonjs/scene";
  44398. import { Color3 } from "babylonjs/Maths/math";
  44399. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44400. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44402. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44403. /**
  44404. * The Physically based material of BJS.
  44405. *
  44406. * This offers the main features of a standard PBR material.
  44407. * For more information, please refer to the documentation :
  44408. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44409. */
  44410. export class PBRMaterial extends PBRBaseMaterial {
  44411. /**
  44412. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44413. */
  44414. static readonly PBRMATERIAL_OPAQUE: number;
  44415. /**
  44416. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44417. */
  44418. static readonly PBRMATERIAL_ALPHATEST: number;
  44419. /**
  44420. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44421. */
  44422. static readonly PBRMATERIAL_ALPHABLEND: number;
  44423. /**
  44424. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44425. * They are also discarded below the alpha cutoff threshold to improve performances.
  44426. */
  44427. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44428. /**
  44429. * Defines the default value of how much AO map is occluding the analytical lights
  44430. * (point spot...).
  44431. */
  44432. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44433. /**
  44434. * Intensity of the direct lights e.g. the four lights available in your scene.
  44435. * This impacts both the direct diffuse and specular highlights.
  44436. */
  44437. directIntensity: number;
  44438. /**
  44439. * Intensity of the emissive part of the material.
  44440. * This helps controlling the emissive effect without modifying the emissive color.
  44441. */
  44442. emissiveIntensity: number;
  44443. /**
  44444. * Intensity of the environment e.g. how much the environment will light the object
  44445. * either through harmonics for rough material or through the refelction for shiny ones.
  44446. */
  44447. environmentIntensity: number;
  44448. /**
  44449. * This is a special control allowing the reduction of the specular highlights coming from the
  44450. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44451. */
  44452. specularIntensity: number;
  44453. /**
  44454. * Debug Control allowing disabling the bump map on this material.
  44455. */
  44456. disableBumpMap: boolean;
  44457. /**
  44458. * AKA Diffuse Texture in standard nomenclature.
  44459. */
  44460. albedoTexture: BaseTexture;
  44461. /**
  44462. * AKA Occlusion Texture in other nomenclature.
  44463. */
  44464. ambientTexture: BaseTexture;
  44465. /**
  44466. * AKA Occlusion Texture Intensity in other nomenclature.
  44467. */
  44468. ambientTextureStrength: number;
  44469. /**
  44470. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44471. * 1 means it completely occludes it
  44472. * 0 mean it has no impact
  44473. */
  44474. ambientTextureImpactOnAnalyticalLights: number;
  44475. /**
  44476. * Stores the alpha values in a texture.
  44477. */
  44478. opacityTexture: BaseTexture;
  44479. /**
  44480. * Stores the reflection values in a texture.
  44481. */
  44482. reflectionTexture: Nullable<BaseTexture>;
  44483. /**
  44484. * Stores the emissive values in a texture.
  44485. */
  44486. emissiveTexture: BaseTexture;
  44487. /**
  44488. * AKA Specular texture in other nomenclature.
  44489. */
  44490. reflectivityTexture: BaseTexture;
  44491. /**
  44492. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44493. */
  44494. metallicTexture: BaseTexture;
  44495. /**
  44496. * Specifies the metallic scalar of the metallic/roughness workflow.
  44497. * Can also be used to scale the metalness values of the metallic texture.
  44498. */
  44499. metallic: Nullable<number>;
  44500. /**
  44501. * Specifies the roughness scalar of the metallic/roughness workflow.
  44502. * Can also be used to scale the roughness values of the metallic texture.
  44503. */
  44504. roughness: Nullable<number>;
  44505. /**
  44506. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44507. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44508. */
  44509. microSurfaceTexture: BaseTexture;
  44510. /**
  44511. * Stores surface normal data used to displace a mesh in a texture.
  44512. */
  44513. bumpTexture: BaseTexture;
  44514. /**
  44515. * Stores the pre-calculated light information of a mesh in a texture.
  44516. */
  44517. lightmapTexture: BaseTexture;
  44518. /**
  44519. * Stores the refracted light information in a texture.
  44520. */
  44521. refractionTexture: BaseTexture;
  44522. /**
  44523. * The color of a material in ambient lighting.
  44524. */
  44525. ambientColor: Color3;
  44526. /**
  44527. * AKA Diffuse Color in other nomenclature.
  44528. */
  44529. albedoColor: Color3;
  44530. /**
  44531. * AKA Specular Color in other nomenclature.
  44532. */
  44533. reflectivityColor: Color3;
  44534. /**
  44535. * The color reflected from the material.
  44536. */
  44537. reflectionColor: Color3;
  44538. /**
  44539. * The color emitted from the material.
  44540. */
  44541. emissiveColor: Color3;
  44542. /**
  44543. * AKA Glossiness in other nomenclature.
  44544. */
  44545. microSurface: number;
  44546. /**
  44547. * source material index of refraction (IOR)' / 'destination material IOR.
  44548. */
  44549. indexOfRefraction: number;
  44550. /**
  44551. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44552. */
  44553. invertRefractionY: boolean;
  44554. /**
  44555. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44556. * Materials half opaque for instance using refraction could benefit from this control.
  44557. */
  44558. linkRefractionWithTransparency: boolean;
  44559. /**
  44560. * If true, the light map contains occlusion information instead of lighting info.
  44561. */
  44562. useLightmapAsShadowmap: boolean;
  44563. /**
  44564. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44565. */
  44566. useAlphaFromAlbedoTexture: boolean;
  44567. /**
  44568. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44569. */
  44570. forceAlphaTest: boolean;
  44571. /**
  44572. * Defines the alpha limits in alpha test mode.
  44573. */
  44574. alphaCutOff: number;
  44575. /**
  44576. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44577. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44578. */
  44579. useSpecularOverAlpha: boolean;
  44580. /**
  44581. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44582. */
  44583. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44584. /**
  44585. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44586. */
  44587. useRoughnessFromMetallicTextureAlpha: boolean;
  44588. /**
  44589. * Specifies if the metallic texture contains the roughness information in its green channel.
  44590. */
  44591. useRoughnessFromMetallicTextureGreen: boolean;
  44592. /**
  44593. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44594. */
  44595. useMetallnessFromMetallicTextureBlue: boolean;
  44596. /**
  44597. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44598. */
  44599. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44600. /**
  44601. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44602. */
  44603. useAmbientInGrayScale: boolean;
  44604. /**
  44605. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44606. * The material will try to infer what glossiness each pixel should be.
  44607. */
  44608. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44609. /**
  44610. * BJS is using an harcoded light falloff based on a manually sets up range.
  44611. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44612. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44613. */
  44614. /**
  44615. * BJS is using an harcoded light falloff based on a manually sets up range.
  44616. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44617. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44618. */
  44619. usePhysicalLightFalloff: boolean;
  44620. /**
  44621. * In order to support the falloff compatibility with gltf, a special mode has been added
  44622. * to reproduce the gltf light falloff.
  44623. */
  44624. /**
  44625. * In order to support the falloff compatibility with gltf, a special mode has been added
  44626. * to reproduce the gltf light falloff.
  44627. */
  44628. useGLTFLightFalloff: boolean;
  44629. /**
  44630. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44631. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44632. */
  44633. useRadianceOverAlpha: boolean;
  44634. /**
  44635. * Allows using an object space normal map (instead of tangent space).
  44636. */
  44637. useObjectSpaceNormalMap: boolean;
  44638. /**
  44639. * Allows using the bump map in parallax mode.
  44640. */
  44641. useParallax: boolean;
  44642. /**
  44643. * Allows using the bump map in parallax occlusion mode.
  44644. */
  44645. useParallaxOcclusion: boolean;
  44646. /**
  44647. * Controls the scale bias of the parallax mode.
  44648. */
  44649. parallaxScaleBias: number;
  44650. /**
  44651. * If sets to true, disables all the lights affecting the material.
  44652. */
  44653. disableLighting: boolean;
  44654. /**
  44655. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44656. */
  44657. forceIrradianceInFragment: boolean;
  44658. /**
  44659. * Number of Simultaneous lights allowed on the material.
  44660. */
  44661. maxSimultaneousLights: number;
  44662. /**
  44663. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44664. */
  44665. invertNormalMapX: boolean;
  44666. /**
  44667. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44668. */
  44669. invertNormalMapY: boolean;
  44670. /**
  44671. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44672. */
  44673. twoSidedLighting: boolean;
  44674. /**
  44675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44676. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44677. */
  44678. useAlphaFresnel: boolean;
  44679. /**
  44680. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44681. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44682. */
  44683. useLinearAlphaFresnel: boolean;
  44684. /**
  44685. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44686. * And/Or occlude the blended part.
  44687. */
  44688. environmentBRDFTexture: Nullable<BaseTexture>;
  44689. /**
  44690. * Force normal to face away from face.
  44691. */
  44692. forceNormalForward: boolean;
  44693. /**
  44694. * Enables specular anti aliasing in the PBR shader.
  44695. * It will both interacts on the Geometry for analytical and IBL lighting.
  44696. * It also prefilter the roughness map based on the bump values.
  44697. */
  44698. enableSpecularAntiAliasing: boolean;
  44699. /**
  44700. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44701. * makes the reflect vector face the model (under horizon).
  44702. */
  44703. useHorizonOcclusion: boolean;
  44704. /**
  44705. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44706. * too much the area relying on ambient texture to define their ambient occlusion.
  44707. */
  44708. useRadianceOcclusion: boolean;
  44709. /**
  44710. * If set to true, no lighting calculations will be applied.
  44711. */
  44712. unlit: boolean;
  44713. /**
  44714. * Gets the image processing configuration used either in this material.
  44715. */
  44716. /**
  44717. * Sets the Default image processing configuration used either in the this material.
  44718. *
  44719. * If sets to null, the scene one is in use.
  44720. */
  44721. imageProcessingConfiguration: ImageProcessingConfiguration;
  44722. /**
  44723. * Gets wether the color curves effect is enabled.
  44724. */
  44725. /**
  44726. * Sets wether the color curves effect is enabled.
  44727. */
  44728. cameraColorCurvesEnabled: boolean;
  44729. /**
  44730. * Gets wether the color grading effect is enabled.
  44731. */
  44732. /**
  44733. * Gets wether the color grading effect is enabled.
  44734. */
  44735. cameraColorGradingEnabled: boolean;
  44736. /**
  44737. * Gets wether tonemapping is enabled or not.
  44738. */
  44739. /**
  44740. * Sets wether tonemapping is enabled or not
  44741. */
  44742. cameraToneMappingEnabled: boolean;
  44743. /**
  44744. * The camera exposure used on this material.
  44745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44746. * This corresponds to a photographic exposure.
  44747. */
  44748. /**
  44749. * The camera exposure used on this material.
  44750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44751. * This corresponds to a photographic exposure.
  44752. */
  44753. cameraExposure: number;
  44754. /**
  44755. * Gets The camera contrast used on this material.
  44756. */
  44757. /**
  44758. * Sets The camera contrast used on this material.
  44759. */
  44760. cameraContrast: number;
  44761. /**
  44762. * Gets the Color Grading 2D Lookup Texture.
  44763. */
  44764. /**
  44765. * Sets the Color Grading 2D Lookup Texture.
  44766. */
  44767. cameraColorGradingTexture: Nullable<BaseTexture>;
  44768. /**
  44769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44771. * 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;
  44772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44773. */
  44774. /**
  44775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44777. * 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;
  44778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44779. */
  44780. cameraColorCurves: Nullable<ColorCurves>;
  44781. /**
  44782. * Instantiates a new PBRMaterial instance.
  44783. *
  44784. * @param name The material name
  44785. * @param scene The scene the material will be use in.
  44786. */
  44787. constructor(name: string, scene: Scene);
  44788. /**
  44789. * Returns the name of this material class.
  44790. */
  44791. getClassName(): string;
  44792. /**
  44793. * Returns an array of the actively used textures.
  44794. * @returns - Array of BaseTextures
  44795. */
  44796. getActiveTextures(): BaseTexture[];
  44797. /**
  44798. * Checks to see if a texture is used in the material.
  44799. * @param texture - Base texture to use.
  44800. * @returns - Boolean specifying if a texture is used in the material.
  44801. */
  44802. hasTexture(texture: BaseTexture): boolean;
  44803. /**
  44804. * Makes a duplicate of the current material.
  44805. * @param name - name to use for the new material.
  44806. */
  44807. clone(name: string): PBRMaterial;
  44808. /**
  44809. * Serializes this PBR Material.
  44810. * @returns - An object with the serialized material.
  44811. */
  44812. serialize(): any;
  44813. /**
  44814. * Parses a PBR Material from a serialized object.
  44815. * @param source - Serialized object.
  44816. * @param scene - BJS scene instance.
  44817. * @param rootUrl - url for the scene object
  44818. * @returns - PBRMaterial
  44819. */
  44820. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44821. }
  44822. }
  44823. declare module "babylonjs/Helpers/sceneHelpers" {
  44824. import { Nullable } from "babylonjs/types";
  44825. import { Mesh } from "babylonjs/Meshes/mesh";
  44826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44827. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44828. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44829. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44830. import "babylonjs/Meshes/Builders/boxBuilder";
  44831. /** @hidden */
  44832. export var _forceSceneHelpersToBundle: boolean;
  44833. module "babylonjs/scene" {
  44834. interface Scene {
  44835. /**
  44836. * Creates a default light for the scene.
  44837. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44838. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44839. */
  44840. createDefaultLight(replace?: boolean): void;
  44841. /**
  44842. * Creates a default camera for the scene.
  44843. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44844. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44845. * @param replace has default false, when true replaces the active camera in the scene
  44846. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44847. */
  44848. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44849. /**
  44850. * Creates a default camera and a default light.
  44851. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44852. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44853. * @param replace has the default false, when true replaces the active camera/light in the scene
  44854. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44855. */
  44856. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44857. /**
  44858. * Creates a new sky box
  44859. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44860. * @param environmentTexture defines the texture to use as environment texture
  44861. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44862. * @param scale defines the overall scale of the skybox
  44863. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44864. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44865. * @returns a new mesh holding the sky box
  44866. */
  44867. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44868. /**
  44869. * Creates a new environment
  44870. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44871. * @param options defines the options you can use to configure the environment
  44872. * @returns the new EnvironmentHelper
  44873. */
  44874. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44875. /**
  44876. * Creates a new VREXperienceHelper
  44877. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44878. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44879. * @returns a new VREXperienceHelper
  44880. */
  44881. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44882. /**
  44883. * Creates a new XREXperienceHelper
  44884. * @see http://doc.babylonjs.com/how_to/webxr
  44885. * @returns a promise for a new XREXperienceHelper
  44886. */
  44887. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44888. }
  44889. }
  44890. }
  44891. declare module "babylonjs/Helpers/videoDome" {
  44892. import { Scene } from "babylonjs/scene";
  44893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44894. import { Mesh } from "babylonjs/Meshes/mesh";
  44895. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44896. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44897. import "babylonjs/Meshes/Builders/sphereBuilder";
  44898. /**
  44899. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44900. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44901. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44902. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44903. */
  44904. export class VideoDome extends TransformNode {
  44905. private _useDirectMapping;
  44906. /**
  44907. * The video texture being displayed on the sphere
  44908. */
  44909. protected _videoTexture: VideoTexture;
  44910. /**
  44911. * Gets the video texture being displayed on the sphere
  44912. */
  44913. readonly videoTexture: VideoTexture;
  44914. /**
  44915. * The skybox material
  44916. */
  44917. protected _material: BackgroundMaterial;
  44918. /**
  44919. * The surface used for the skybox
  44920. */
  44921. protected _mesh: Mesh;
  44922. /**
  44923. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44924. * Also see the options.resolution property.
  44925. */
  44926. fovMultiplier: number;
  44927. /**
  44928. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44929. * @param name Element's name, child elements will append suffixes for their own names.
  44930. * @param urlsOrVideo defines the url(s) or the video element to use
  44931. * @param options An object containing optional or exposed sub element properties
  44932. */
  44933. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44934. resolution?: number;
  44935. clickToPlay?: boolean;
  44936. autoPlay?: boolean;
  44937. loop?: boolean;
  44938. size?: number;
  44939. poster?: string;
  44940. useDirectMapping?: boolean;
  44941. }, scene: Scene);
  44942. /**
  44943. * Releases resources associated with this node.
  44944. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44945. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44946. */
  44947. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44948. }
  44949. }
  44950. declare module "babylonjs/Helpers/index" {
  44951. export * from "babylonjs/Helpers/environmentHelper";
  44952. export * from "babylonjs/Helpers/photoDome";
  44953. export * from "babylonjs/Helpers/sceneHelpers";
  44954. export * from "babylonjs/Helpers/videoDome";
  44955. }
  44956. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  44957. import { PerfCounter } from "babylonjs/Misc/tools";
  44958. import { IDisposable } from "babylonjs/scene";
  44959. import { Engine } from "babylonjs/Engines/engine";
  44960. /**
  44961. * This class can be used to get instrumentation data from a Babylon engine
  44962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44963. */
  44964. export class EngineInstrumentation implements IDisposable {
  44965. /**
  44966. * Define the instrumented engine.
  44967. */
  44968. engine: Engine;
  44969. private _captureGPUFrameTime;
  44970. private _gpuFrameTimeToken;
  44971. private _gpuFrameTime;
  44972. private _captureShaderCompilationTime;
  44973. private _shaderCompilationTime;
  44974. private _onBeginFrameObserver;
  44975. private _onEndFrameObserver;
  44976. private _onBeforeShaderCompilationObserver;
  44977. private _onAfterShaderCompilationObserver;
  44978. /**
  44979. * Gets the perf counter used for GPU frame time
  44980. */
  44981. readonly gpuFrameTimeCounter: PerfCounter;
  44982. /**
  44983. * Gets the GPU frame time capture status
  44984. */
  44985. /**
  44986. * Enable or disable the GPU frame time capture
  44987. */
  44988. captureGPUFrameTime: boolean;
  44989. /**
  44990. * Gets the perf counter used for shader compilation time
  44991. */
  44992. readonly shaderCompilationTimeCounter: PerfCounter;
  44993. /**
  44994. * Gets the shader compilation time capture status
  44995. */
  44996. /**
  44997. * Enable or disable the shader compilation time capture
  44998. */
  44999. captureShaderCompilationTime: boolean;
  45000. /**
  45001. * Instantiates a new engine instrumentation.
  45002. * This class can be used to get instrumentation data from a Babylon engine
  45003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45004. * @param engine Defines the engine to instrument
  45005. */
  45006. constructor(
  45007. /**
  45008. * Define the instrumented engine.
  45009. */
  45010. engine: Engine);
  45011. /**
  45012. * Dispose and release associated resources.
  45013. */
  45014. dispose(): void;
  45015. }
  45016. }
  45017. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45018. import { PerfCounter } from "babylonjs/Misc/tools";
  45019. import { Scene, IDisposable } from "babylonjs/scene";
  45020. /**
  45021. * This class can be used to get instrumentation data from a Babylon engine
  45022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45023. */
  45024. export class SceneInstrumentation implements IDisposable {
  45025. /**
  45026. * Defines the scene to instrument
  45027. */
  45028. scene: Scene;
  45029. private _captureActiveMeshesEvaluationTime;
  45030. private _activeMeshesEvaluationTime;
  45031. private _captureRenderTargetsRenderTime;
  45032. private _renderTargetsRenderTime;
  45033. private _captureFrameTime;
  45034. private _frameTime;
  45035. private _captureRenderTime;
  45036. private _renderTime;
  45037. private _captureInterFrameTime;
  45038. private _interFrameTime;
  45039. private _captureParticlesRenderTime;
  45040. private _particlesRenderTime;
  45041. private _captureSpritesRenderTime;
  45042. private _spritesRenderTime;
  45043. private _capturePhysicsTime;
  45044. private _physicsTime;
  45045. private _captureAnimationsTime;
  45046. private _animationsTime;
  45047. private _captureCameraRenderTime;
  45048. private _cameraRenderTime;
  45049. private _onBeforeActiveMeshesEvaluationObserver;
  45050. private _onAfterActiveMeshesEvaluationObserver;
  45051. private _onBeforeRenderTargetsRenderObserver;
  45052. private _onAfterRenderTargetsRenderObserver;
  45053. private _onAfterRenderObserver;
  45054. private _onBeforeDrawPhaseObserver;
  45055. private _onAfterDrawPhaseObserver;
  45056. private _onBeforeAnimationsObserver;
  45057. private _onBeforeParticlesRenderingObserver;
  45058. private _onAfterParticlesRenderingObserver;
  45059. private _onBeforeSpritesRenderingObserver;
  45060. private _onAfterSpritesRenderingObserver;
  45061. private _onBeforePhysicsObserver;
  45062. private _onAfterPhysicsObserver;
  45063. private _onAfterAnimationsObserver;
  45064. private _onBeforeCameraRenderObserver;
  45065. private _onAfterCameraRenderObserver;
  45066. /**
  45067. * Gets the perf counter used for active meshes evaluation time
  45068. */
  45069. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45070. /**
  45071. * Gets the active meshes evaluation time capture status
  45072. */
  45073. /**
  45074. * Enable or disable the active meshes evaluation time capture
  45075. */
  45076. captureActiveMeshesEvaluationTime: boolean;
  45077. /**
  45078. * Gets the perf counter used for render targets render time
  45079. */
  45080. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45081. /**
  45082. * Gets the render targets render time capture status
  45083. */
  45084. /**
  45085. * Enable or disable the render targets render time capture
  45086. */
  45087. captureRenderTargetsRenderTime: boolean;
  45088. /**
  45089. * Gets the perf counter used for particles render time
  45090. */
  45091. readonly particlesRenderTimeCounter: PerfCounter;
  45092. /**
  45093. * Gets the particles render time capture status
  45094. */
  45095. /**
  45096. * Enable or disable the particles render time capture
  45097. */
  45098. captureParticlesRenderTime: boolean;
  45099. /**
  45100. * Gets the perf counter used for sprites render time
  45101. */
  45102. readonly spritesRenderTimeCounter: PerfCounter;
  45103. /**
  45104. * Gets the sprites render time capture status
  45105. */
  45106. /**
  45107. * Enable or disable the sprites render time capture
  45108. */
  45109. captureSpritesRenderTime: boolean;
  45110. /**
  45111. * Gets the perf counter used for physics time
  45112. */
  45113. readonly physicsTimeCounter: PerfCounter;
  45114. /**
  45115. * Gets the physics time capture status
  45116. */
  45117. /**
  45118. * Enable or disable the physics time capture
  45119. */
  45120. capturePhysicsTime: boolean;
  45121. /**
  45122. * Gets the perf counter used for animations time
  45123. */
  45124. readonly animationsTimeCounter: PerfCounter;
  45125. /**
  45126. * Gets the animations time capture status
  45127. */
  45128. /**
  45129. * Enable or disable the animations time capture
  45130. */
  45131. captureAnimationsTime: boolean;
  45132. /**
  45133. * Gets the perf counter used for frame time capture
  45134. */
  45135. readonly frameTimeCounter: PerfCounter;
  45136. /**
  45137. * Gets the frame time capture status
  45138. */
  45139. /**
  45140. * Enable or disable the frame time capture
  45141. */
  45142. captureFrameTime: boolean;
  45143. /**
  45144. * Gets the perf counter used for inter-frames time capture
  45145. */
  45146. readonly interFrameTimeCounter: PerfCounter;
  45147. /**
  45148. * Gets the inter-frames time capture status
  45149. */
  45150. /**
  45151. * Enable or disable the inter-frames time capture
  45152. */
  45153. captureInterFrameTime: boolean;
  45154. /**
  45155. * Gets the perf counter used for render time capture
  45156. */
  45157. readonly renderTimeCounter: PerfCounter;
  45158. /**
  45159. * Gets the render time capture status
  45160. */
  45161. /**
  45162. * Enable or disable the render time capture
  45163. */
  45164. captureRenderTime: boolean;
  45165. /**
  45166. * Gets the perf counter used for camera render time capture
  45167. */
  45168. readonly cameraRenderTimeCounter: PerfCounter;
  45169. /**
  45170. * Gets the camera render time capture status
  45171. */
  45172. /**
  45173. * Enable or disable the camera render time capture
  45174. */
  45175. captureCameraRenderTime: boolean;
  45176. /**
  45177. * Gets the perf counter used for draw calls
  45178. */
  45179. readonly drawCallsCounter: PerfCounter;
  45180. /**
  45181. * Gets the perf counter used for texture collisions
  45182. */
  45183. readonly textureCollisionsCounter: PerfCounter;
  45184. /**
  45185. * Instantiates a new scene instrumentation.
  45186. * This class can be used to get instrumentation data from a Babylon engine
  45187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45188. * @param scene Defines the scene to instrument
  45189. */
  45190. constructor(
  45191. /**
  45192. * Defines the scene to instrument
  45193. */
  45194. scene: Scene);
  45195. /**
  45196. * Dispose and release associated resources.
  45197. */
  45198. dispose(): void;
  45199. }
  45200. }
  45201. declare module "babylonjs/Instrumentation/index" {
  45202. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45203. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45204. export * from "babylonjs/Instrumentation/timeToken";
  45205. }
  45206. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45207. /** @hidden */
  45208. export var glowMapGenerationPixelShader: {
  45209. name: string;
  45210. shader: string;
  45211. };
  45212. }
  45213. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45214. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45215. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45217. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45219. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45220. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45221. /** @hidden */
  45222. export var glowMapGenerationVertexShader: {
  45223. name: string;
  45224. shader: string;
  45225. };
  45226. }
  45227. declare module "babylonjs/Layers/effectLayer" {
  45228. import { Observable } from "babylonjs/Misc/observable";
  45229. import { Nullable } from "babylonjs/types";
  45230. import { Camera } from "babylonjs/Cameras/camera";
  45231. import { Scene } from "babylonjs/scene";
  45232. import { Color4, ISize } from "babylonjs/Maths/math";
  45233. import { Engine } from "babylonjs/Engines/engine";
  45234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45236. import { Mesh } from "babylonjs/Meshes/mesh";
  45237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45240. import { Effect } from "babylonjs/Materials/effect";
  45241. import { Material } from "babylonjs/Materials/material";
  45242. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45243. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45244. /**
  45245. * Effect layer options. This helps customizing the behaviour
  45246. * of the effect layer.
  45247. */
  45248. export interface IEffectLayerOptions {
  45249. /**
  45250. * Multiplication factor apply to the canvas size to compute the render target size
  45251. * used to generated the objects (the smaller the faster).
  45252. */
  45253. mainTextureRatio: number;
  45254. /**
  45255. * Enforces a fixed size texture to ensure effect stability across devices.
  45256. */
  45257. mainTextureFixedSize?: number;
  45258. /**
  45259. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45260. */
  45261. alphaBlendingMode: number;
  45262. /**
  45263. * The camera attached to the layer.
  45264. */
  45265. camera: Nullable<Camera>;
  45266. /**
  45267. * The rendering group to draw the layer in.
  45268. */
  45269. renderingGroupId: number;
  45270. }
  45271. /**
  45272. * The effect layer Helps adding post process effect blended with the main pass.
  45273. *
  45274. * This can be for instance use to generate glow or higlight effects on the scene.
  45275. *
  45276. * The effect layer class can not be used directly and is intented to inherited from to be
  45277. * customized per effects.
  45278. */
  45279. export abstract class EffectLayer {
  45280. private _vertexBuffers;
  45281. private _indexBuffer;
  45282. private _cachedDefines;
  45283. private _effectLayerMapGenerationEffect;
  45284. private _effectLayerOptions;
  45285. private _mergeEffect;
  45286. protected _scene: Scene;
  45287. protected _engine: Engine;
  45288. protected _maxSize: number;
  45289. protected _mainTextureDesiredSize: ISize;
  45290. protected _mainTexture: RenderTargetTexture;
  45291. protected _shouldRender: boolean;
  45292. protected _postProcesses: PostProcess[];
  45293. protected _textures: BaseTexture[];
  45294. protected _emissiveTextureAndColor: {
  45295. texture: Nullable<BaseTexture>;
  45296. color: Color4;
  45297. };
  45298. /**
  45299. * The name of the layer
  45300. */
  45301. name: string;
  45302. /**
  45303. * The clear color of the texture used to generate the glow map.
  45304. */
  45305. neutralColor: Color4;
  45306. /**
  45307. * Specifies wether the highlight layer is enabled or not.
  45308. */
  45309. isEnabled: boolean;
  45310. /**
  45311. * Gets the camera attached to the layer.
  45312. */
  45313. readonly camera: Nullable<Camera>;
  45314. /**
  45315. * Gets the rendering group id the layer should render in.
  45316. */
  45317. readonly renderingGroupId: number;
  45318. /**
  45319. * An event triggered when the effect layer has been disposed.
  45320. */
  45321. onDisposeObservable: Observable<EffectLayer>;
  45322. /**
  45323. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45324. */
  45325. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45326. /**
  45327. * An event triggered when the generated texture is being merged in the scene.
  45328. */
  45329. onBeforeComposeObservable: Observable<EffectLayer>;
  45330. /**
  45331. * An event triggered when the generated texture has been merged in the scene.
  45332. */
  45333. onAfterComposeObservable: Observable<EffectLayer>;
  45334. /**
  45335. * An event triggered when the efffect layer changes its size.
  45336. */
  45337. onSizeChangedObservable: Observable<EffectLayer>;
  45338. /** @hidden */
  45339. static _SceneComponentInitialization: (scene: Scene) => void;
  45340. /**
  45341. * Instantiates a new effect Layer and references it in the scene.
  45342. * @param name The name of the layer
  45343. * @param scene The scene to use the layer in
  45344. */
  45345. constructor(
  45346. /** The Friendly of the effect in the scene */
  45347. name: string, scene: Scene);
  45348. /**
  45349. * Get the effect name of the layer.
  45350. * @return The effect name
  45351. */
  45352. abstract getEffectName(): string;
  45353. /**
  45354. * Checks for the readiness of the element composing the layer.
  45355. * @param subMesh the mesh to check for
  45356. * @param useInstances specify wether or not to use instances to render the mesh
  45357. * @return true if ready otherwise, false
  45358. */
  45359. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45360. /**
  45361. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45362. * @returns true if the effect requires stencil during the main canvas render pass.
  45363. */
  45364. abstract needStencil(): boolean;
  45365. /**
  45366. * Create the merge effect. This is the shader use to blit the information back
  45367. * to the main canvas at the end of the scene rendering.
  45368. * @returns The effect containing the shader used to merge the effect on the main canvas
  45369. */
  45370. protected abstract _createMergeEffect(): Effect;
  45371. /**
  45372. * Creates the render target textures and post processes used in the effect layer.
  45373. */
  45374. protected abstract _createTextureAndPostProcesses(): void;
  45375. /**
  45376. * Implementation specific of rendering the generating effect on the main canvas.
  45377. * @param effect The effect used to render through
  45378. */
  45379. protected abstract _internalRender(effect: Effect): void;
  45380. /**
  45381. * Sets the required values for both the emissive texture and and the main color.
  45382. */
  45383. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45384. /**
  45385. * Free any resources and references associated to a mesh.
  45386. * Internal use
  45387. * @param mesh The mesh to free.
  45388. */
  45389. abstract _disposeMesh(mesh: Mesh): void;
  45390. /**
  45391. * Serializes this layer (Glow or Highlight for example)
  45392. * @returns a serialized layer object
  45393. */
  45394. abstract serialize?(): any;
  45395. /**
  45396. * Initializes the effect layer with the required options.
  45397. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45398. */
  45399. protected _init(options: Partial<IEffectLayerOptions>): void;
  45400. /**
  45401. * Generates the index buffer of the full screen quad blending to the main canvas.
  45402. */
  45403. private _generateIndexBuffer;
  45404. /**
  45405. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45406. */
  45407. private _genrateVertexBuffer;
  45408. /**
  45409. * Sets the main texture desired size which is the closest power of two
  45410. * of the engine canvas size.
  45411. */
  45412. private _setMainTextureSize;
  45413. /**
  45414. * Creates the main texture for the effect layer.
  45415. */
  45416. protected _createMainTexture(): void;
  45417. /**
  45418. * Adds specific effects defines.
  45419. * @param defines The defines to add specifics to.
  45420. */
  45421. protected _addCustomEffectDefines(defines: string[]): void;
  45422. /**
  45423. * Checks for the readiness of the element composing the layer.
  45424. * @param subMesh the mesh to check for
  45425. * @param useInstances specify wether or not to use instances to render the mesh
  45426. * @param emissiveTexture the associated emissive texture used to generate the glow
  45427. * @return true if ready otherwise, false
  45428. */
  45429. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45430. /**
  45431. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45432. */
  45433. render(): void;
  45434. /**
  45435. * Determine if a given mesh will be used in the current effect.
  45436. * @param mesh mesh to test
  45437. * @returns true if the mesh will be used
  45438. */
  45439. hasMesh(mesh: AbstractMesh): boolean;
  45440. /**
  45441. * Returns true if the layer contains information to display, otherwise false.
  45442. * @returns true if the glow layer should be rendered
  45443. */
  45444. shouldRender(): boolean;
  45445. /**
  45446. * Returns true if the mesh should render, otherwise false.
  45447. * @param mesh The mesh to render
  45448. * @returns true if it should render otherwise false
  45449. */
  45450. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45451. /**
  45452. * Returns true if the mesh can be rendered, otherwise false.
  45453. * @param mesh The mesh to render
  45454. * @param material The material used on the mesh
  45455. * @returns true if it can be rendered otherwise false
  45456. */
  45457. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45458. /**
  45459. * Returns true if the mesh should render, otherwise false.
  45460. * @param mesh The mesh to render
  45461. * @returns true if it should render otherwise false
  45462. */
  45463. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45464. /**
  45465. * Renders the submesh passed in parameter to the generation map.
  45466. */
  45467. protected _renderSubMesh(subMesh: SubMesh): void;
  45468. /**
  45469. * Rebuild the required buffers.
  45470. * @hidden Internal use only.
  45471. */
  45472. _rebuild(): void;
  45473. /**
  45474. * Dispose only the render target textures and post process.
  45475. */
  45476. private _disposeTextureAndPostProcesses;
  45477. /**
  45478. * Dispose the highlight layer and free resources.
  45479. */
  45480. dispose(): void;
  45481. /**
  45482. * Gets the class name of the effect layer
  45483. * @returns the string with the class name of the effect layer
  45484. */
  45485. getClassName(): string;
  45486. /**
  45487. * Creates an effect layer from parsed effect layer data
  45488. * @param parsedEffectLayer defines effect layer data
  45489. * @param scene defines the current scene
  45490. * @param rootUrl defines the root URL containing the effect layer information
  45491. * @returns a parsed effect Layer
  45492. */
  45493. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45494. }
  45495. }
  45496. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45497. import { Scene } from "babylonjs/scene";
  45498. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45499. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45500. import { AbstractScene } from "babylonjs/abstractScene";
  45501. module "babylonjs/abstractScene" {
  45502. interface AbstractScene {
  45503. /**
  45504. * The list of effect layers (highlights/glow) added to the scene
  45505. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45506. * @see http://doc.babylonjs.com/how_to/glow_layer
  45507. */
  45508. effectLayers: Array<EffectLayer>;
  45509. /**
  45510. * Removes the given effect layer from this scene.
  45511. * @param toRemove defines the effect layer to remove
  45512. * @returns the index of the removed effect layer
  45513. */
  45514. removeEffectLayer(toRemove: EffectLayer): number;
  45515. /**
  45516. * Adds the given effect layer to this scene
  45517. * @param newEffectLayer defines the effect layer to add
  45518. */
  45519. addEffectLayer(newEffectLayer: EffectLayer): void;
  45520. }
  45521. }
  45522. /**
  45523. * Defines the layer scene component responsible to manage any effect layers
  45524. * in a given scene.
  45525. */
  45526. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45527. /**
  45528. * The component name helpfull to identify the component in the list of scene components.
  45529. */
  45530. readonly name: string;
  45531. /**
  45532. * The scene the component belongs to.
  45533. */
  45534. scene: Scene;
  45535. private _engine;
  45536. private _renderEffects;
  45537. private _needStencil;
  45538. private _previousStencilState;
  45539. /**
  45540. * Creates a new instance of the component for the given scene
  45541. * @param scene Defines the scene to register the component in
  45542. */
  45543. constructor(scene: Scene);
  45544. /**
  45545. * Registers the component in a given scene
  45546. */
  45547. register(): void;
  45548. /**
  45549. * Rebuilds the elements related to this component in case of
  45550. * context lost for instance.
  45551. */
  45552. rebuild(): void;
  45553. /**
  45554. * Serializes the component data to the specified json object
  45555. * @param serializationObject The object to serialize to
  45556. */
  45557. serialize(serializationObject: any): void;
  45558. /**
  45559. * Adds all the element from the container to the scene
  45560. * @param container the container holding the elements
  45561. */
  45562. addFromContainer(container: AbstractScene): void;
  45563. /**
  45564. * Removes all the elements in the container from the scene
  45565. * @param container contains the elements to remove
  45566. */
  45567. removeFromContainer(container: AbstractScene): void;
  45568. /**
  45569. * Disposes the component and the associated ressources.
  45570. */
  45571. dispose(): void;
  45572. private _isReadyForMesh;
  45573. private _renderMainTexture;
  45574. private _setStencil;
  45575. private _setStencilBack;
  45576. private _draw;
  45577. private _drawCamera;
  45578. private _drawRenderingGroup;
  45579. }
  45580. }
  45581. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45582. /** @hidden */
  45583. export var glowMapMergePixelShader: {
  45584. name: string;
  45585. shader: string;
  45586. };
  45587. }
  45588. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45589. /** @hidden */
  45590. export var glowMapMergeVertexShader: {
  45591. name: string;
  45592. shader: string;
  45593. };
  45594. }
  45595. declare module "babylonjs/Layers/glowLayer" {
  45596. import { Nullable } from "babylonjs/types";
  45597. import { Camera } from "babylonjs/Cameras/camera";
  45598. import { Scene } from "babylonjs/scene";
  45599. import { Color4 } from "babylonjs/Maths/math";
  45600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45602. import { Mesh } from "babylonjs/Meshes/mesh";
  45603. import { Texture } from "babylonjs/Materials/Textures/texture";
  45604. import { Effect } from "babylonjs/Materials/effect";
  45605. import { Material } from "babylonjs/Materials/material";
  45606. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45607. import "babylonjs/Shaders/glowMapMerge.fragment";
  45608. import "babylonjs/Shaders/glowMapMerge.vertex";
  45609. module "babylonjs/abstractScene" {
  45610. interface AbstractScene {
  45611. /**
  45612. * Return a the first highlight layer of the scene with a given name.
  45613. * @param name The name of the highlight layer to look for.
  45614. * @return The highlight layer if found otherwise null.
  45615. */
  45616. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45617. }
  45618. }
  45619. /**
  45620. * Glow layer options. This helps customizing the behaviour
  45621. * of the glow layer.
  45622. */
  45623. export interface IGlowLayerOptions {
  45624. /**
  45625. * Multiplication factor apply to the canvas size to compute the render target size
  45626. * used to generated the glowing objects (the smaller the faster).
  45627. */
  45628. mainTextureRatio: number;
  45629. /**
  45630. * Enforces a fixed size texture to ensure resize independant blur.
  45631. */
  45632. mainTextureFixedSize?: number;
  45633. /**
  45634. * How big is the kernel of the blur texture.
  45635. */
  45636. blurKernelSize: number;
  45637. /**
  45638. * The camera attached to the layer.
  45639. */
  45640. camera: Nullable<Camera>;
  45641. /**
  45642. * Enable MSAA by chosing the number of samples.
  45643. */
  45644. mainTextureSamples?: number;
  45645. /**
  45646. * The rendering group to draw the layer in.
  45647. */
  45648. renderingGroupId: number;
  45649. }
  45650. /**
  45651. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45652. *
  45653. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45654. * glowy meshes to your scene.
  45655. *
  45656. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45657. */
  45658. export class GlowLayer extends EffectLayer {
  45659. /**
  45660. * Effect Name of the layer.
  45661. */
  45662. static readonly EffectName: string;
  45663. /**
  45664. * The default blur kernel size used for the glow.
  45665. */
  45666. static DefaultBlurKernelSize: number;
  45667. /**
  45668. * The default texture size ratio used for the glow.
  45669. */
  45670. static DefaultTextureRatio: number;
  45671. /**
  45672. * Sets the kernel size of the blur.
  45673. */
  45674. /**
  45675. * Gets the kernel size of the blur.
  45676. */
  45677. blurKernelSize: number;
  45678. /**
  45679. * Sets the glow intensity.
  45680. */
  45681. /**
  45682. * Gets the glow intensity.
  45683. */
  45684. intensity: number;
  45685. private _options;
  45686. private _intensity;
  45687. private _horizontalBlurPostprocess1;
  45688. private _verticalBlurPostprocess1;
  45689. private _horizontalBlurPostprocess2;
  45690. private _verticalBlurPostprocess2;
  45691. private _blurTexture1;
  45692. private _blurTexture2;
  45693. private _postProcesses1;
  45694. private _postProcesses2;
  45695. private _includedOnlyMeshes;
  45696. private _excludedMeshes;
  45697. /**
  45698. * Callback used to let the user override the color selection on a per mesh basis
  45699. */
  45700. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45701. /**
  45702. * Callback used to let the user override the texture selection on a per mesh basis
  45703. */
  45704. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45705. /**
  45706. * Instantiates a new glow Layer and references it to the scene.
  45707. * @param name The name of the layer
  45708. * @param scene The scene to use the layer in
  45709. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45710. */
  45711. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45712. /**
  45713. * Get the effect name of the layer.
  45714. * @return The effect name
  45715. */
  45716. getEffectName(): string;
  45717. /**
  45718. * Create the merge effect. This is the shader use to blit the information back
  45719. * to the main canvas at the end of the scene rendering.
  45720. */
  45721. protected _createMergeEffect(): Effect;
  45722. /**
  45723. * Creates the render target textures and post processes used in the glow layer.
  45724. */
  45725. protected _createTextureAndPostProcesses(): void;
  45726. /**
  45727. * Checks for the readiness of the element composing the layer.
  45728. * @param subMesh the mesh to check for
  45729. * @param useInstances specify wether or not to use instances to render the mesh
  45730. * @param emissiveTexture the associated emissive texture used to generate the glow
  45731. * @return true if ready otherwise, false
  45732. */
  45733. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45734. /**
  45735. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45736. */
  45737. needStencil(): boolean;
  45738. /**
  45739. * Returns true if the mesh can be rendered, otherwise false.
  45740. * @param mesh The mesh to render
  45741. * @param material The material used on the mesh
  45742. * @returns true if it can be rendered otherwise false
  45743. */
  45744. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45745. /**
  45746. * Implementation specific of rendering the generating effect on the main canvas.
  45747. * @param effect The effect used to render through
  45748. */
  45749. protected _internalRender(effect: Effect): void;
  45750. /**
  45751. * Sets the required values for both the emissive texture and and the main color.
  45752. */
  45753. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45754. /**
  45755. * Returns true if the mesh should render, otherwise false.
  45756. * @param mesh The mesh to render
  45757. * @returns true if it should render otherwise false
  45758. */
  45759. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45760. /**
  45761. * Adds specific effects defines.
  45762. * @param defines The defines to add specifics to.
  45763. */
  45764. protected _addCustomEffectDefines(defines: string[]): void;
  45765. /**
  45766. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45767. * @param mesh The mesh to exclude from the glow layer
  45768. */
  45769. addExcludedMesh(mesh: Mesh): void;
  45770. /**
  45771. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45772. * @param mesh The mesh to remove
  45773. */
  45774. removeExcludedMesh(mesh: Mesh): void;
  45775. /**
  45776. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45777. * @param mesh The mesh to include in the glow layer
  45778. */
  45779. addIncludedOnlyMesh(mesh: Mesh): void;
  45780. /**
  45781. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45782. * @param mesh The mesh to remove
  45783. */
  45784. removeIncludedOnlyMesh(mesh: Mesh): void;
  45785. /**
  45786. * Determine if a given mesh will be used in the glow layer
  45787. * @param mesh The mesh to test
  45788. * @returns true if the mesh will be highlighted by the current glow layer
  45789. */
  45790. hasMesh(mesh: AbstractMesh): boolean;
  45791. /**
  45792. * Free any resources and references associated to a mesh.
  45793. * Internal use
  45794. * @param mesh The mesh to free.
  45795. * @hidden
  45796. */
  45797. _disposeMesh(mesh: Mesh): void;
  45798. /**
  45799. * Gets the class name of the effect layer
  45800. * @returns the string with the class name of the effect layer
  45801. */
  45802. getClassName(): string;
  45803. /**
  45804. * Serializes this glow layer
  45805. * @returns a serialized glow layer object
  45806. */
  45807. serialize(): any;
  45808. /**
  45809. * Creates a Glow Layer from parsed glow layer data
  45810. * @param parsedGlowLayer defines glow layer data
  45811. * @param scene defines the current scene
  45812. * @param rootUrl defines the root URL containing the glow layer information
  45813. * @returns a parsed Glow Layer
  45814. */
  45815. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45816. }
  45817. }
  45818. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45819. /** @hidden */
  45820. export var glowBlurPostProcessPixelShader: {
  45821. name: string;
  45822. shader: string;
  45823. };
  45824. }
  45825. declare module "babylonjs/Layers/highlightLayer" {
  45826. import { Observable } from "babylonjs/Misc/observable";
  45827. import { Nullable } from "babylonjs/types";
  45828. import { Camera } from "babylonjs/Cameras/camera";
  45829. import { Scene } from "babylonjs/scene";
  45830. import { Color3, Color4 } from "babylonjs/Maths/math";
  45831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45833. import { Mesh } from "babylonjs/Meshes/mesh";
  45834. import { Effect } from "babylonjs/Materials/effect";
  45835. import { Material } from "babylonjs/Materials/material";
  45836. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45837. import "babylonjs/Shaders/glowMapMerge.fragment";
  45838. import "babylonjs/Shaders/glowMapMerge.vertex";
  45839. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45840. module "babylonjs/abstractScene" {
  45841. interface AbstractScene {
  45842. /**
  45843. * Return a the first highlight layer of the scene with a given name.
  45844. * @param name The name of the highlight layer to look for.
  45845. * @return The highlight layer if found otherwise null.
  45846. */
  45847. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45848. }
  45849. }
  45850. /**
  45851. * Highlight layer options. This helps customizing the behaviour
  45852. * of the highlight layer.
  45853. */
  45854. export interface IHighlightLayerOptions {
  45855. /**
  45856. * Multiplication factor apply to the canvas size to compute the render target size
  45857. * used to generated the glowing objects (the smaller the faster).
  45858. */
  45859. mainTextureRatio: number;
  45860. /**
  45861. * Enforces a fixed size texture to ensure resize independant blur.
  45862. */
  45863. mainTextureFixedSize?: number;
  45864. /**
  45865. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45866. * of the picture to blur (the smaller the faster).
  45867. */
  45868. blurTextureSizeRatio: number;
  45869. /**
  45870. * How big in texel of the blur texture is the vertical blur.
  45871. */
  45872. blurVerticalSize: number;
  45873. /**
  45874. * How big in texel of the blur texture is the horizontal blur.
  45875. */
  45876. blurHorizontalSize: number;
  45877. /**
  45878. * Alpha blending mode used to apply the blur. Default is combine.
  45879. */
  45880. alphaBlendingMode: number;
  45881. /**
  45882. * The camera attached to the layer.
  45883. */
  45884. camera: Nullable<Camera>;
  45885. /**
  45886. * Should we display highlight as a solid stroke?
  45887. */
  45888. isStroke?: boolean;
  45889. /**
  45890. * The rendering group to draw the layer in.
  45891. */
  45892. renderingGroupId: number;
  45893. }
  45894. /**
  45895. * The highlight layer Helps adding a glow effect around a mesh.
  45896. *
  45897. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45898. * glowy meshes to your scene.
  45899. *
  45900. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45901. */
  45902. export class HighlightLayer extends EffectLayer {
  45903. name: string;
  45904. /**
  45905. * Effect Name of the highlight layer.
  45906. */
  45907. static readonly EffectName: string;
  45908. /**
  45909. * The neutral color used during the preparation of the glow effect.
  45910. * This is black by default as the blend operation is a blend operation.
  45911. */
  45912. static NeutralColor: Color4;
  45913. /**
  45914. * Stencil value used for glowing meshes.
  45915. */
  45916. static GlowingMeshStencilReference: number;
  45917. /**
  45918. * Stencil value used for the other meshes in the scene.
  45919. */
  45920. static NormalMeshStencilReference: number;
  45921. /**
  45922. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45923. */
  45924. innerGlow: boolean;
  45925. /**
  45926. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45927. */
  45928. outerGlow: boolean;
  45929. /**
  45930. * Specifies the horizontal size of the blur.
  45931. */
  45932. /**
  45933. * Gets the horizontal size of the blur.
  45934. */
  45935. blurHorizontalSize: number;
  45936. /**
  45937. * Specifies the vertical size of the blur.
  45938. */
  45939. /**
  45940. * Gets the vertical size of the blur.
  45941. */
  45942. blurVerticalSize: number;
  45943. /**
  45944. * An event triggered when the highlight layer is being blurred.
  45945. */
  45946. onBeforeBlurObservable: Observable<HighlightLayer>;
  45947. /**
  45948. * An event triggered when the highlight layer has been blurred.
  45949. */
  45950. onAfterBlurObservable: Observable<HighlightLayer>;
  45951. private _instanceGlowingMeshStencilReference;
  45952. private _options;
  45953. private _downSamplePostprocess;
  45954. private _horizontalBlurPostprocess;
  45955. private _verticalBlurPostprocess;
  45956. private _blurTexture;
  45957. private _meshes;
  45958. private _excludedMeshes;
  45959. /**
  45960. * Instantiates a new highlight Layer and references it to the scene..
  45961. * @param name The name of the layer
  45962. * @param scene The scene to use the layer in
  45963. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  45964. */
  45965. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  45966. /**
  45967. * Get the effect name of the layer.
  45968. * @return The effect name
  45969. */
  45970. getEffectName(): string;
  45971. /**
  45972. * Create the merge effect. This is the shader use to blit the information back
  45973. * to the main canvas at the end of the scene rendering.
  45974. */
  45975. protected _createMergeEffect(): Effect;
  45976. /**
  45977. * Creates the render target textures and post processes used in the highlight layer.
  45978. */
  45979. protected _createTextureAndPostProcesses(): void;
  45980. /**
  45981. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45982. */
  45983. needStencil(): boolean;
  45984. /**
  45985. * Checks for the readiness of the element composing the layer.
  45986. * @param subMesh the mesh to check for
  45987. * @param useInstances specify wether or not to use instances to render the mesh
  45988. * @param emissiveTexture the associated emissive texture used to generate the glow
  45989. * @return true if ready otherwise, false
  45990. */
  45991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45992. /**
  45993. * Implementation specific of rendering the generating effect on the main canvas.
  45994. * @param effect The effect used to render through
  45995. */
  45996. protected _internalRender(effect: Effect): void;
  45997. /**
  45998. * Returns true if the layer contains information to display, otherwise false.
  45999. */
  46000. shouldRender(): boolean;
  46001. /**
  46002. * Returns true if the mesh should render, otherwise false.
  46003. * @param mesh The mesh to render
  46004. * @returns true if it should render otherwise false
  46005. */
  46006. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46007. /**
  46008. * Sets the required values for both the emissive texture and and the main color.
  46009. */
  46010. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46011. /**
  46012. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46013. * @param mesh The mesh to exclude from the highlight layer
  46014. */
  46015. addExcludedMesh(mesh: Mesh): void;
  46016. /**
  46017. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46018. * @param mesh The mesh to highlight
  46019. */
  46020. removeExcludedMesh(mesh: Mesh): void;
  46021. /**
  46022. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46023. * @param mesh mesh to test
  46024. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46025. */
  46026. hasMesh(mesh: AbstractMesh): boolean;
  46027. /**
  46028. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46029. * @param mesh The mesh to highlight
  46030. * @param color The color of the highlight
  46031. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46032. */
  46033. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46034. /**
  46035. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46036. * @param mesh The mesh to highlight
  46037. */
  46038. removeMesh(mesh: Mesh): void;
  46039. /**
  46040. * Force the stencil to the normal expected value for none glowing parts
  46041. */
  46042. private _defaultStencilReference;
  46043. /**
  46044. * Free any resources and references associated to a mesh.
  46045. * Internal use
  46046. * @param mesh The mesh to free.
  46047. * @hidden
  46048. */
  46049. _disposeMesh(mesh: Mesh): void;
  46050. /**
  46051. * Dispose the highlight layer and free resources.
  46052. */
  46053. dispose(): void;
  46054. /**
  46055. * Gets the class name of the effect layer
  46056. * @returns the string with the class name of the effect layer
  46057. */
  46058. getClassName(): string;
  46059. /**
  46060. * Serializes this Highlight layer
  46061. * @returns a serialized Highlight layer object
  46062. */
  46063. serialize(): any;
  46064. /**
  46065. * Creates a Highlight layer from parsed Highlight layer data
  46066. * @param parsedHightlightLayer defines the Highlight layer data
  46067. * @param scene defines the current scene
  46068. * @param rootUrl defines the root URL containing the Highlight layer information
  46069. * @returns a parsed Highlight layer
  46070. */
  46071. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46072. }
  46073. }
  46074. declare module "babylonjs/Layers/index" {
  46075. export * from "babylonjs/Layers/effectLayer";
  46076. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46077. export * from "babylonjs/Layers/glowLayer";
  46078. export * from "babylonjs/Layers/highlightLayer";
  46079. export * from "babylonjs/Layers/layer";
  46080. export * from "babylonjs/Layers/layerSceneComponent";
  46081. }
  46082. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46083. /** @hidden */
  46084. export var lensFlarePixelShader: {
  46085. name: string;
  46086. shader: string;
  46087. };
  46088. }
  46089. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46090. /** @hidden */
  46091. export var lensFlareVertexShader: {
  46092. name: string;
  46093. shader: string;
  46094. };
  46095. }
  46096. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46097. import { Scene } from "babylonjs/scene";
  46098. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46100. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46101. import "babylonjs/Shaders/lensFlare.fragment";
  46102. import "babylonjs/Shaders/lensFlare.vertex";
  46103. /**
  46104. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46105. * It is usually composed of several `lensFlare`.
  46106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46107. */
  46108. export class LensFlareSystem {
  46109. /**
  46110. * Define the name of the lens flare system
  46111. */
  46112. name: string;
  46113. /**
  46114. * List of lens flares used in this system.
  46115. */
  46116. lensFlares: LensFlare[];
  46117. /**
  46118. * Define a limit from the border the lens flare can be visible.
  46119. */
  46120. borderLimit: number;
  46121. /**
  46122. * Define a viewport border we do not want to see the lens flare in.
  46123. */
  46124. viewportBorder: number;
  46125. /**
  46126. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46127. */
  46128. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46129. /**
  46130. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46131. */
  46132. layerMask: number;
  46133. /**
  46134. * Define the id of the lens flare system in the scene.
  46135. * (equal to name by default)
  46136. */
  46137. id: string;
  46138. private _scene;
  46139. private _emitter;
  46140. private _vertexBuffers;
  46141. private _indexBuffer;
  46142. private _effect;
  46143. private _positionX;
  46144. private _positionY;
  46145. private _isEnabled;
  46146. /** @hidden */
  46147. static _SceneComponentInitialization: (scene: Scene) => void;
  46148. /**
  46149. * Instantiates a lens flare system.
  46150. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46151. * It is usually composed of several `lensFlare`.
  46152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46153. * @param name Define the name of the lens flare system in the scene
  46154. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46155. * @param scene Define the scene the lens flare system belongs to
  46156. */
  46157. constructor(
  46158. /**
  46159. * Define the name of the lens flare system
  46160. */
  46161. name: string, emitter: any, scene: Scene);
  46162. /**
  46163. * Define if the lens flare system is enabled.
  46164. */
  46165. isEnabled: boolean;
  46166. /**
  46167. * Get the scene the effects belongs to.
  46168. * @returns the scene holding the lens flare system
  46169. */
  46170. getScene(): Scene;
  46171. /**
  46172. * Get the emitter of the lens flare system.
  46173. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46174. * @returns the emitter of the lens flare system
  46175. */
  46176. getEmitter(): any;
  46177. /**
  46178. * Set the emitter of the lens flare system.
  46179. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46180. * @param newEmitter Define the new emitter of the system
  46181. */
  46182. setEmitter(newEmitter: any): void;
  46183. /**
  46184. * Get the lens flare system emitter position.
  46185. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46186. * @returns the position
  46187. */
  46188. getEmitterPosition(): Vector3;
  46189. /**
  46190. * @hidden
  46191. */
  46192. computeEffectivePosition(globalViewport: Viewport): boolean;
  46193. /** @hidden */
  46194. _isVisible(): boolean;
  46195. /**
  46196. * @hidden
  46197. */
  46198. render(): boolean;
  46199. /**
  46200. * Dispose and release the lens flare with its associated resources.
  46201. */
  46202. dispose(): void;
  46203. /**
  46204. * Parse a lens flare system from a JSON repressentation
  46205. * @param parsedLensFlareSystem Define the JSON to parse
  46206. * @param scene Define the scene the parsed system should be instantiated in
  46207. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46208. * @returns the parsed system
  46209. */
  46210. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46211. /**
  46212. * Serialize the current Lens Flare System into a JSON representation.
  46213. * @returns the serialized JSON
  46214. */
  46215. serialize(): any;
  46216. }
  46217. }
  46218. declare module "babylonjs/LensFlares/lensFlare" {
  46219. import { Nullable } from "babylonjs/types";
  46220. import { Color3 } from "babylonjs/Maths/math";
  46221. import { Texture } from "babylonjs/Materials/Textures/texture";
  46222. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46223. /**
  46224. * This represents one of the lens effect in a `lensFlareSystem`.
  46225. * It controls one of the indiviual texture used in the effect.
  46226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46227. */
  46228. export class LensFlare {
  46229. /**
  46230. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46231. */
  46232. size: number;
  46233. /**
  46234. * 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.
  46235. */
  46236. position: number;
  46237. /**
  46238. * Define the lens color.
  46239. */
  46240. color: Color3;
  46241. /**
  46242. * Define the lens texture.
  46243. */
  46244. texture: Nullable<Texture>;
  46245. /**
  46246. * Define the alpha mode to render this particular lens.
  46247. */
  46248. alphaMode: number;
  46249. private _system;
  46250. /**
  46251. * Creates a new Lens Flare.
  46252. * This represents one of the lens effect in a `lensFlareSystem`.
  46253. * It controls one of the indiviual texture used in the effect.
  46254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46255. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46256. * @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.
  46257. * @param color Define the lens color
  46258. * @param imgUrl Define the lens texture url
  46259. * @param system Define the `lensFlareSystem` this flare is part of
  46260. * @returns The newly created Lens Flare
  46261. */
  46262. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46263. /**
  46264. * Instantiates a new Lens Flare.
  46265. * This represents one of the lens effect in a `lensFlareSystem`.
  46266. * It controls one of the indiviual texture used in the effect.
  46267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46268. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46269. * @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.
  46270. * @param color Define the lens color
  46271. * @param imgUrl Define the lens texture url
  46272. * @param system Define the `lensFlareSystem` this flare is part of
  46273. */
  46274. constructor(
  46275. /**
  46276. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46277. */
  46278. size: number,
  46279. /**
  46280. * 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.
  46281. */
  46282. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46283. /**
  46284. * Dispose and release the lens flare with its associated resources.
  46285. */
  46286. dispose(): void;
  46287. }
  46288. }
  46289. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46290. import { Nullable } from "babylonjs/types";
  46291. import { Scene } from "babylonjs/scene";
  46292. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46293. import { AbstractScene } from "babylonjs/abstractScene";
  46294. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46295. module "babylonjs/abstractScene" {
  46296. interface AbstractScene {
  46297. /**
  46298. * The list of lens flare system added to the scene
  46299. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46300. */
  46301. lensFlareSystems: Array<LensFlareSystem>;
  46302. /**
  46303. * Removes the given lens flare system from this scene.
  46304. * @param toRemove The lens flare system to remove
  46305. * @returns The index of the removed lens flare system
  46306. */
  46307. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46308. /**
  46309. * Adds the given lens flare system to this scene
  46310. * @param newLensFlareSystem The lens flare system to add
  46311. */
  46312. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46313. /**
  46314. * Gets a lens flare system using its name
  46315. * @param name defines the name to look for
  46316. * @returns the lens flare system or null if not found
  46317. */
  46318. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46319. /**
  46320. * Gets a lens flare system using its id
  46321. * @param id defines the id to look for
  46322. * @returns the lens flare system or null if not found
  46323. */
  46324. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46325. }
  46326. }
  46327. /**
  46328. * Defines the lens flare scene component responsible to manage any lens flares
  46329. * in a given scene.
  46330. */
  46331. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46332. /**
  46333. * The component name helpfull to identify the component in the list of scene components.
  46334. */
  46335. readonly name: string;
  46336. /**
  46337. * The scene the component belongs to.
  46338. */
  46339. scene: Scene;
  46340. /**
  46341. * Creates a new instance of the component for the given scene
  46342. * @param scene Defines the scene to register the component in
  46343. */
  46344. constructor(scene: Scene);
  46345. /**
  46346. * Registers the component in a given scene
  46347. */
  46348. register(): void;
  46349. /**
  46350. * Rebuilds the elements related to this component in case of
  46351. * context lost for instance.
  46352. */
  46353. rebuild(): void;
  46354. /**
  46355. * Adds all the element from the container to the scene
  46356. * @param container the container holding the elements
  46357. */
  46358. addFromContainer(container: AbstractScene): void;
  46359. /**
  46360. * Removes all the elements in the container from the scene
  46361. * @param container contains the elements to remove
  46362. */
  46363. removeFromContainer(container: AbstractScene): void;
  46364. /**
  46365. * Serializes the component data to the specified json object
  46366. * @param serializationObject The object to serialize to
  46367. */
  46368. serialize(serializationObject: any): void;
  46369. /**
  46370. * Disposes the component and the associated ressources.
  46371. */
  46372. dispose(): void;
  46373. private _draw;
  46374. }
  46375. }
  46376. declare module "babylonjs/LensFlares/index" {
  46377. export * from "babylonjs/LensFlares/lensFlare";
  46378. export * from "babylonjs/LensFlares/lensFlareSystem";
  46379. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46380. }
  46381. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46382. import { Scene } from "babylonjs/scene";
  46383. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46384. import { AbstractScene } from "babylonjs/abstractScene";
  46385. /**
  46386. * Defines the shadow generator component responsible to manage any shadow generators
  46387. * in a given scene.
  46388. */
  46389. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46390. /**
  46391. * The component name helpfull to identify the component in the list of scene components.
  46392. */
  46393. readonly name: string;
  46394. /**
  46395. * The scene the component belongs to.
  46396. */
  46397. scene: Scene;
  46398. /**
  46399. * Creates a new instance of the component for the given scene
  46400. * @param scene Defines the scene to register the component in
  46401. */
  46402. constructor(scene: Scene);
  46403. /**
  46404. * Registers the component in a given scene
  46405. */
  46406. register(): void;
  46407. /**
  46408. * Rebuilds the elements related to this component in case of
  46409. * context lost for instance.
  46410. */
  46411. rebuild(): void;
  46412. /**
  46413. * Serializes the component data to the specified json object
  46414. * @param serializationObject The object to serialize to
  46415. */
  46416. serialize(serializationObject: any): void;
  46417. /**
  46418. * Adds all the element from the container to the scene
  46419. * @param container the container holding the elements
  46420. */
  46421. addFromContainer(container: AbstractScene): void;
  46422. /**
  46423. * Removes all the elements in the container from the scene
  46424. * @param container contains the elements to remove
  46425. */
  46426. removeFromContainer(container: AbstractScene): void;
  46427. /**
  46428. * Rebuilds the elements related to this component in case of
  46429. * context lost for instance.
  46430. */
  46431. dispose(): void;
  46432. private _gatherRenderTargets;
  46433. }
  46434. }
  46435. declare module "babylonjs/Lights/Shadows/index" {
  46436. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46437. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46438. }
  46439. declare module "babylonjs/Lights/directionalLight" {
  46440. import { Camera } from "babylonjs/Cameras/camera";
  46441. import { Scene } from "babylonjs/scene";
  46442. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46444. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46445. import { Effect } from "babylonjs/Materials/effect";
  46446. /**
  46447. * A directional light is defined by a direction (what a surprise!).
  46448. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46449. * 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.
  46450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46451. */
  46452. export class DirectionalLight extends ShadowLight {
  46453. private _shadowFrustumSize;
  46454. /**
  46455. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46456. */
  46457. /**
  46458. * Specifies a fix frustum size for the shadow generation.
  46459. */
  46460. shadowFrustumSize: number;
  46461. private _shadowOrthoScale;
  46462. /**
  46463. * Gets the shadow projection scale against the optimal computed one.
  46464. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46465. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46466. */
  46467. /**
  46468. * Sets the shadow projection scale against the optimal computed one.
  46469. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46470. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46471. */
  46472. shadowOrthoScale: number;
  46473. /**
  46474. * Automatically compute the projection matrix to best fit (including all the casters)
  46475. * on each frame.
  46476. */
  46477. autoUpdateExtends: boolean;
  46478. private _orthoLeft;
  46479. private _orthoRight;
  46480. private _orthoTop;
  46481. private _orthoBottom;
  46482. /**
  46483. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46484. * The directional light is emitted from everywhere in the given direction.
  46485. * It can cast shadows.
  46486. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46487. * @param name The friendly name of the light
  46488. * @param direction The direction of the light
  46489. * @param scene The scene the light belongs to
  46490. */
  46491. constructor(name: string, direction: Vector3, scene: Scene);
  46492. /**
  46493. * Returns the string "DirectionalLight".
  46494. * @return The class name
  46495. */
  46496. getClassName(): string;
  46497. /**
  46498. * Returns the integer 1.
  46499. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46500. */
  46501. getTypeID(): number;
  46502. /**
  46503. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46504. * Returns the DirectionalLight Shadow projection matrix.
  46505. */
  46506. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46507. /**
  46508. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46509. * Returns the DirectionalLight Shadow projection matrix.
  46510. */
  46511. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46512. /**
  46513. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46514. * Returns the DirectionalLight Shadow projection matrix.
  46515. */
  46516. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46517. protected _buildUniformLayout(): void;
  46518. /**
  46519. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46520. * @param effect The effect to update
  46521. * @param lightIndex The index of the light in the effect to update
  46522. * @returns The directional light
  46523. */
  46524. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46525. /**
  46526. * Gets the minZ used for shadow according to both the scene and the light.
  46527. *
  46528. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46529. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46530. * @param activeCamera The camera we are returning the min for
  46531. * @returns the depth min z
  46532. */
  46533. getDepthMinZ(activeCamera: Camera): number;
  46534. /**
  46535. * Gets the maxZ used for shadow according to both the scene and the light.
  46536. *
  46537. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46538. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46539. * @param activeCamera The camera we are returning the max for
  46540. * @returns the depth max z
  46541. */
  46542. getDepthMaxZ(activeCamera: Camera): number;
  46543. /**
  46544. * Prepares the list of defines specific to the light type.
  46545. * @param defines the list of defines
  46546. * @param lightIndex defines the index of the light for the effect
  46547. */
  46548. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46549. }
  46550. }
  46551. declare module "babylonjs/Lights/pointLight" {
  46552. import { Scene } from "babylonjs/scene";
  46553. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46555. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46556. import { Effect } from "babylonjs/Materials/effect";
  46557. /**
  46558. * A point light is a light defined by an unique point in world space.
  46559. * The light is emitted in every direction from this point.
  46560. * A good example of a point light is a standard light bulb.
  46561. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46562. */
  46563. export class PointLight extends ShadowLight {
  46564. private _shadowAngle;
  46565. /**
  46566. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46567. * This specifies what angle the shadow will use to be created.
  46568. *
  46569. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46570. */
  46571. /**
  46572. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46573. * This specifies what angle the shadow will use to be created.
  46574. *
  46575. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46576. */
  46577. shadowAngle: number;
  46578. /**
  46579. * Gets the direction if it has been set.
  46580. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46581. */
  46582. /**
  46583. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46584. */
  46585. direction: Vector3;
  46586. /**
  46587. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46588. * A PointLight emits the light in every direction.
  46589. * It can cast shadows.
  46590. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46591. * ```javascript
  46592. * var pointLight = new PointLight("pl", camera.position, scene);
  46593. * ```
  46594. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46595. * @param name The light friendly name
  46596. * @param position The position of the point light in the scene
  46597. * @param scene The scene the lights belongs to
  46598. */
  46599. constructor(name: string, position: Vector3, scene: Scene);
  46600. /**
  46601. * Returns the string "PointLight"
  46602. * @returns the class name
  46603. */
  46604. getClassName(): string;
  46605. /**
  46606. * Returns the integer 0.
  46607. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46608. */
  46609. getTypeID(): number;
  46610. /**
  46611. * Specifies wether or not the shadowmap should be a cube texture.
  46612. * @returns true if the shadowmap needs to be a cube texture.
  46613. */
  46614. needCube(): boolean;
  46615. /**
  46616. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46617. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46618. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46619. */
  46620. getShadowDirection(faceIndex?: number): Vector3;
  46621. /**
  46622. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46623. * - fov = PI / 2
  46624. * - aspect ratio : 1.0
  46625. * - z-near and far equal to the active camera minZ and maxZ.
  46626. * Returns the PointLight.
  46627. */
  46628. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46629. protected _buildUniformLayout(): void;
  46630. /**
  46631. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46632. * @param effect The effect to update
  46633. * @param lightIndex The index of the light in the effect to update
  46634. * @returns The point light
  46635. */
  46636. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46637. /**
  46638. * Prepares the list of defines specific to the light type.
  46639. * @param defines the list of defines
  46640. * @param lightIndex defines the index of the light for the effect
  46641. */
  46642. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46643. }
  46644. }
  46645. declare module "babylonjs/Lights/spotLight" {
  46646. import { Nullable } from "babylonjs/types";
  46647. import { Scene } from "babylonjs/scene";
  46648. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46650. import { Effect } from "babylonjs/Materials/effect";
  46651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46652. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46653. /**
  46654. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46655. * These values define a cone of light starting from the position, emitting toward the direction.
  46656. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46657. * and the exponent defines the speed of the decay of the light with distance (reach).
  46658. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46659. */
  46660. export class SpotLight extends ShadowLight {
  46661. private _angle;
  46662. private _innerAngle;
  46663. private _cosHalfAngle;
  46664. private _lightAngleScale;
  46665. private _lightAngleOffset;
  46666. /**
  46667. * Gets the cone angle of the spot light in Radians.
  46668. */
  46669. /**
  46670. * Sets the cone angle of the spot light in Radians.
  46671. */
  46672. angle: number;
  46673. /**
  46674. * Only used in gltf falloff mode, this defines the angle where
  46675. * the directional falloff will start before cutting at angle which could be seen
  46676. * as outer angle.
  46677. */
  46678. /**
  46679. * Only used in gltf falloff mode, this defines the angle where
  46680. * the directional falloff will start before cutting at angle which could be seen
  46681. * as outer angle.
  46682. */
  46683. innerAngle: number;
  46684. private _shadowAngleScale;
  46685. /**
  46686. * Allows scaling the angle of the light for shadow generation only.
  46687. */
  46688. /**
  46689. * Allows scaling the angle of the light for shadow generation only.
  46690. */
  46691. shadowAngleScale: number;
  46692. /**
  46693. * The light decay speed with the distance from the emission spot.
  46694. */
  46695. exponent: number;
  46696. private _projectionTextureMatrix;
  46697. /**
  46698. * Allows reading the projecton texture
  46699. */
  46700. readonly projectionTextureMatrix: Matrix;
  46701. protected _projectionTextureLightNear: number;
  46702. /**
  46703. * Gets the near clip of the Spotlight for texture projection.
  46704. */
  46705. /**
  46706. * Sets the near clip of the Spotlight for texture projection.
  46707. */
  46708. projectionTextureLightNear: number;
  46709. protected _projectionTextureLightFar: number;
  46710. /**
  46711. * Gets the far clip of the Spotlight for texture projection.
  46712. */
  46713. /**
  46714. * Sets the far clip of the Spotlight for texture projection.
  46715. */
  46716. projectionTextureLightFar: number;
  46717. protected _projectionTextureUpDirection: Vector3;
  46718. /**
  46719. * Gets the Up vector of the Spotlight for texture projection.
  46720. */
  46721. /**
  46722. * Sets the Up vector of the Spotlight for texture projection.
  46723. */
  46724. projectionTextureUpDirection: Vector3;
  46725. private _projectionTexture;
  46726. /**
  46727. * Gets the projection texture of the light.
  46728. */
  46729. /**
  46730. * Sets the projection texture of the light.
  46731. */
  46732. projectionTexture: Nullable<BaseTexture>;
  46733. private _projectionTextureViewLightDirty;
  46734. private _projectionTextureProjectionLightDirty;
  46735. private _projectionTextureDirty;
  46736. private _projectionTextureViewTargetVector;
  46737. private _projectionTextureViewLightMatrix;
  46738. private _projectionTextureProjectionLightMatrix;
  46739. private _projectionTextureScalingMatrix;
  46740. /**
  46741. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46742. * It can cast shadows.
  46743. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46744. * @param name The light friendly name
  46745. * @param position The position of the spot light in the scene
  46746. * @param direction The direction of the light in the scene
  46747. * @param angle The cone angle of the light in Radians
  46748. * @param exponent The light decay speed with the distance from the emission spot
  46749. * @param scene The scene the lights belongs to
  46750. */
  46751. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46752. /**
  46753. * Returns the string "SpotLight".
  46754. * @returns the class name
  46755. */
  46756. getClassName(): string;
  46757. /**
  46758. * Returns the integer 2.
  46759. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46760. */
  46761. getTypeID(): number;
  46762. /**
  46763. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46764. */
  46765. protected _setDirection(value: Vector3): void;
  46766. /**
  46767. * Overrides the position setter to recompute the projection texture view light Matrix.
  46768. */
  46769. protected _setPosition(value: Vector3): void;
  46770. /**
  46771. * 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.
  46772. * Returns the SpotLight.
  46773. */
  46774. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46775. protected _computeProjectionTextureViewLightMatrix(): void;
  46776. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46777. /**
  46778. * Main function for light texture projection matrix computing.
  46779. */
  46780. protected _computeProjectionTextureMatrix(): void;
  46781. protected _buildUniformLayout(): void;
  46782. private _computeAngleValues;
  46783. /**
  46784. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46785. * @param effect The effect to update
  46786. * @param lightIndex The index of the light in the effect to update
  46787. * @returns The spot light
  46788. */
  46789. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46790. /**
  46791. * Disposes the light and the associated resources.
  46792. */
  46793. dispose(): void;
  46794. /**
  46795. * Prepares the list of defines specific to the light type.
  46796. * @param defines the list of defines
  46797. * @param lightIndex defines the index of the light for the effect
  46798. */
  46799. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46800. }
  46801. }
  46802. declare module "babylonjs/Lights/index" {
  46803. export * from "babylonjs/Lights/light";
  46804. export * from "babylonjs/Lights/shadowLight";
  46805. export * from "babylonjs/Lights/Shadows/index";
  46806. export * from "babylonjs/Lights/directionalLight";
  46807. export * from "babylonjs/Lights/hemisphericLight";
  46808. export * from "babylonjs/Lights/pointLight";
  46809. export * from "babylonjs/Lights/spotLight";
  46810. }
  46811. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46812. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46813. /**
  46814. * Header information of HDR texture files.
  46815. */
  46816. export interface HDRInfo {
  46817. /**
  46818. * The height of the texture in pixels.
  46819. */
  46820. height: number;
  46821. /**
  46822. * The width of the texture in pixels.
  46823. */
  46824. width: number;
  46825. /**
  46826. * The index of the beginning of the data in the binary file.
  46827. */
  46828. dataPosition: number;
  46829. }
  46830. /**
  46831. * This groups tools to convert HDR texture to native colors array.
  46832. */
  46833. export class HDRTools {
  46834. private static Ldexp;
  46835. private static Rgbe2float;
  46836. private static readStringLine;
  46837. /**
  46838. * Reads header information from an RGBE texture stored in a native array.
  46839. * More information on this format are available here:
  46840. * https://en.wikipedia.org/wiki/RGBE_image_format
  46841. *
  46842. * @param uint8array The binary file stored in native array.
  46843. * @return The header information.
  46844. */
  46845. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46846. /**
  46847. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46848. * This RGBE texture needs to store the information as a panorama.
  46849. *
  46850. * More information on this format are available here:
  46851. * https://en.wikipedia.org/wiki/RGBE_image_format
  46852. *
  46853. * @param buffer The binary file stored in an array buffer.
  46854. * @param size The expected size of the extracted cubemap.
  46855. * @return The Cube Map information.
  46856. */
  46857. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46858. /**
  46859. * Returns the pixels data extracted from an RGBE texture.
  46860. * This pixels will be stored left to right up to down in the R G B order in one array.
  46861. *
  46862. * More information on this format are available here:
  46863. * https://en.wikipedia.org/wiki/RGBE_image_format
  46864. *
  46865. * @param uint8array The binary file stored in an array buffer.
  46866. * @param hdrInfo The header information of the file.
  46867. * @return The pixels data in RGB right to left up to down order.
  46868. */
  46869. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46870. private static RGBE_ReadPixels_RLE;
  46871. }
  46872. }
  46873. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46874. import { Nullable } from "babylonjs/types";
  46875. import { Scene } from "babylonjs/scene";
  46876. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46878. /**
  46879. * This represents a texture coming from an HDR input.
  46880. *
  46881. * The only supported format is currently panorama picture stored in RGBE format.
  46882. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46883. */
  46884. export class HDRCubeTexture extends BaseTexture {
  46885. private static _facesMapping;
  46886. private _generateHarmonics;
  46887. private _noMipmap;
  46888. private _textureMatrix;
  46889. private _size;
  46890. private _onLoad;
  46891. private _onError;
  46892. /**
  46893. * The texture URL.
  46894. */
  46895. url: string;
  46896. /**
  46897. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46898. */
  46899. coordinatesMode: number;
  46900. protected _isBlocking: boolean;
  46901. /**
  46902. * Sets wether or not the texture is blocking during loading.
  46903. */
  46904. /**
  46905. * Gets wether or not the texture is blocking during loading.
  46906. */
  46907. isBlocking: boolean;
  46908. protected _rotationY: number;
  46909. /**
  46910. * Sets texture matrix rotation angle around Y axis in radians.
  46911. */
  46912. /**
  46913. * Gets texture matrix rotation angle around Y axis radians.
  46914. */
  46915. rotationY: number;
  46916. /**
  46917. * Gets or sets the center of the bounding box associated with the cube texture
  46918. * It must define where the camera used to render the texture was set
  46919. */
  46920. boundingBoxPosition: Vector3;
  46921. private _boundingBoxSize;
  46922. /**
  46923. * Gets or sets the size of the bounding box associated with the cube texture
  46924. * When defined, the cubemap will switch to local mode
  46925. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46926. * @example https://www.babylonjs-playground.com/#RNASML
  46927. */
  46928. boundingBoxSize: Vector3;
  46929. /**
  46930. * Instantiates an HDRTexture from the following parameters.
  46931. *
  46932. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46933. * @param scene The scene the texture will be used in
  46934. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46935. * @param noMipmap Forces to not generate the mipmap if true
  46936. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46937. * @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)
  46938. * @param reserved Reserved flag for internal use.
  46939. */
  46940. 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>);
  46941. /**
  46942. * Get the current class name of the texture useful for serialization or dynamic coding.
  46943. * @returns "HDRCubeTexture"
  46944. */
  46945. getClassName(): string;
  46946. /**
  46947. * Occurs when the file is raw .hdr file.
  46948. */
  46949. private loadTexture;
  46950. clone(): HDRCubeTexture;
  46951. delayLoad(): void;
  46952. /**
  46953. * Get the texture reflection matrix used to rotate/transform the reflection.
  46954. * @returns the reflection matrix
  46955. */
  46956. getReflectionTextureMatrix(): Matrix;
  46957. /**
  46958. * Set the texture reflection matrix used to rotate/transform the reflection.
  46959. * @param value Define the reflection matrix to set
  46960. */
  46961. setReflectionTextureMatrix(value: Matrix): void;
  46962. /**
  46963. * Parses a JSON representation of an HDR Texture in order to create the texture
  46964. * @param parsedTexture Define the JSON representation
  46965. * @param scene Define the scene the texture should be created in
  46966. * @param rootUrl Define the root url in case we need to load relative dependencies
  46967. * @returns the newly created texture after parsing
  46968. */
  46969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46970. serialize(): any;
  46971. }
  46972. }
  46973. declare module "babylonjs/Physics/physicsEngine" {
  46974. import { Nullable } from "babylonjs/types";
  46975. import { Vector3 } from "babylonjs/Maths/math";
  46976. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46977. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  46978. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  46979. /**
  46980. * Class used to control physics engine
  46981. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  46982. */
  46983. export class PhysicsEngine implements IPhysicsEngine {
  46984. private _physicsPlugin;
  46985. /**
  46986. * Global value used to control the smallest number supported by the simulation
  46987. */
  46988. static Epsilon: number;
  46989. private _impostors;
  46990. private _joints;
  46991. /**
  46992. * Gets the gravity vector used by the simulation
  46993. */
  46994. gravity: Vector3;
  46995. /**
  46996. * Factory used to create the default physics plugin.
  46997. * @returns The default physics plugin
  46998. */
  46999. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47000. /**
  47001. * Creates a new Physics Engine
  47002. * @param gravity defines the gravity vector used by the simulation
  47003. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47004. */
  47005. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47006. /**
  47007. * Sets the gravity vector used by the simulation
  47008. * @param gravity defines the gravity vector to use
  47009. */
  47010. setGravity(gravity: Vector3): void;
  47011. /**
  47012. * Set the time step of the physics engine.
  47013. * Default is 1/60.
  47014. * To slow it down, enter 1/600 for example.
  47015. * To speed it up, 1/30
  47016. * @param newTimeStep defines the new timestep to apply to this world.
  47017. */
  47018. setTimeStep(newTimeStep?: number): void;
  47019. /**
  47020. * Get the time step of the physics engine.
  47021. * @returns the current time step
  47022. */
  47023. getTimeStep(): number;
  47024. /**
  47025. * Release all resources
  47026. */
  47027. dispose(): void;
  47028. /**
  47029. * Gets the name of the current physics plugin
  47030. * @returns the name of the plugin
  47031. */
  47032. getPhysicsPluginName(): string;
  47033. /**
  47034. * Adding a new impostor for the impostor tracking.
  47035. * This will be done by the impostor itself.
  47036. * @param impostor the impostor to add
  47037. */
  47038. addImpostor(impostor: PhysicsImpostor): void;
  47039. /**
  47040. * Remove an impostor from the engine.
  47041. * This impostor and its mesh will not longer be updated by the physics engine.
  47042. * @param impostor the impostor to remove
  47043. */
  47044. removeImpostor(impostor: PhysicsImpostor): void;
  47045. /**
  47046. * Add a joint to the physics engine
  47047. * @param mainImpostor defines the main impostor to which the joint is added.
  47048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47049. * @param joint defines the joint that will connect both impostors.
  47050. */
  47051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47052. /**
  47053. * Removes a joint from the simulation
  47054. * @param mainImpostor defines the impostor used with the joint
  47055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47056. * @param joint defines the joint to remove
  47057. */
  47058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47059. /**
  47060. * Called by the scene. No need to call it.
  47061. * @param delta defines the timespam between frames
  47062. */
  47063. _step(delta: number): void;
  47064. /**
  47065. * Gets the current plugin used to run the simulation
  47066. * @returns current plugin
  47067. */
  47068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47069. /**
  47070. * Gets the list of physic impostors
  47071. * @returns an array of PhysicsImpostor
  47072. */
  47073. getImpostors(): Array<PhysicsImpostor>;
  47074. /**
  47075. * Gets the impostor for a physics enabled object
  47076. * @param object defines the object impersonated by the impostor
  47077. * @returns the PhysicsImpostor or null if not found
  47078. */
  47079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47080. /**
  47081. * Gets the impostor for a physics body object
  47082. * @param body defines physics body used by the impostor
  47083. * @returns the PhysicsImpostor or null if not found
  47084. */
  47085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47086. }
  47087. }
  47088. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47089. import { Nullable } from "babylonjs/types";
  47090. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47092. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47093. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47094. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47095. /** @hidden */
  47096. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47097. private _useDeltaForWorldStep;
  47098. world: any;
  47099. name: string;
  47100. private _physicsMaterials;
  47101. private _fixedTimeStep;
  47102. BJSCANNON: any;
  47103. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47104. setGravity(gravity: Vector3): void;
  47105. setTimeStep(timeStep: number): void;
  47106. getTimeStep(): number;
  47107. executeStep(delta: number): void;
  47108. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47109. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47110. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47111. private _processChildMeshes;
  47112. removePhysicsBody(impostor: PhysicsImpostor): void;
  47113. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47114. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47115. private _addMaterial;
  47116. private _checkWithEpsilon;
  47117. private _createShape;
  47118. private _createHeightmap;
  47119. private _minus90X;
  47120. private _plus90X;
  47121. private _tmpPosition;
  47122. private _tmpDeltaPosition;
  47123. private _tmpUnityRotation;
  47124. private _updatePhysicsBodyTransformation;
  47125. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47126. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47127. isSupported(): boolean;
  47128. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47129. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47130. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47131. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47132. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47133. getBodyMass(impostor: PhysicsImpostor): number;
  47134. getBodyFriction(impostor: PhysicsImpostor): number;
  47135. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47136. getBodyRestitution(impostor: PhysicsImpostor): number;
  47137. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47138. sleepBody(impostor: PhysicsImpostor): void;
  47139. wakeUpBody(impostor: PhysicsImpostor): void;
  47140. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47141. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47142. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47143. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47144. getRadius(impostor: PhysicsImpostor): number;
  47145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47146. dispose(): void;
  47147. private _extendNamespace;
  47148. }
  47149. }
  47150. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47151. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47152. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47153. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47155. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47156. import { Nullable } from "babylonjs/types";
  47157. /** @hidden */
  47158. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47159. world: any;
  47160. name: string;
  47161. BJSOIMO: any;
  47162. constructor(iterations?: number, oimoInjection?: any);
  47163. setGravity(gravity: Vector3): void;
  47164. setTimeStep(timeStep: number): void;
  47165. getTimeStep(): number;
  47166. private _tmpImpostorsArray;
  47167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47171. private _tmpPositionVector;
  47172. removePhysicsBody(impostor: PhysicsImpostor): void;
  47173. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47174. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47175. isSupported(): boolean;
  47176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47183. getBodyMass(impostor: PhysicsImpostor): number;
  47184. getBodyFriction(impostor: PhysicsImpostor): number;
  47185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47186. getBodyRestitution(impostor: PhysicsImpostor): number;
  47187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47188. sleepBody(impostor: PhysicsImpostor): void;
  47189. wakeUpBody(impostor: PhysicsImpostor): void;
  47190. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47191. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47192. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47193. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47194. getRadius(impostor: PhysicsImpostor): number;
  47195. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47196. dispose(): void;
  47197. }
  47198. }
  47199. declare module "babylonjs/Probes/reflectionProbe" {
  47200. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47201. import { Vector3 } from "babylonjs/Maths/math";
  47202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47203. import { Nullable } from "babylonjs/types";
  47204. import { Scene } from "babylonjs/scene";
  47205. module "babylonjs/abstractScene" {
  47206. interface AbstractScene {
  47207. /**
  47208. * The list of reflection probes added to the scene
  47209. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47210. */
  47211. reflectionProbes: Array<ReflectionProbe>;
  47212. /**
  47213. * Removes the given reflection probe from this scene.
  47214. * @param toRemove The reflection probe to remove
  47215. * @returns The index of the removed reflection probe
  47216. */
  47217. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47218. /**
  47219. * Adds the given reflection probe to this scene.
  47220. * @param newReflectionProbe The reflection probe to add
  47221. */
  47222. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47223. }
  47224. }
  47225. /**
  47226. * Class used to generate realtime reflection / refraction cube textures
  47227. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47228. */
  47229. export class ReflectionProbe {
  47230. /** defines the name of the probe */
  47231. name: string;
  47232. private _scene;
  47233. private _renderTargetTexture;
  47234. private _projectionMatrix;
  47235. private _viewMatrix;
  47236. private _target;
  47237. private _add;
  47238. private _attachedMesh;
  47239. private _invertYAxis;
  47240. /** Gets or sets probe position (center of the cube map) */
  47241. position: Vector3;
  47242. /**
  47243. * Creates a new reflection probe
  47244. * @param name defines the name of the probe
  47245. * @param size defines the texture resolution (for each face)
  47246. * @param scene defines the hosting scene
  47247. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47248. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47249. */
  47250. constructor(
  47251. /** defines the name of the probe */
  47252. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47253. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47254. samples: number;
  47255. /** Gets or sets the refresh rate to use (on every frame by default) */
  47256. refreshRate: number;
  47257. /**
  47258. * Gets the hosting scene
  47259. * @returns a Scene
  47260. */
  47261. getScene(): Scene;
  47262. /** Gets the internal CubeTexture used to render to */
  47263. readonly cubeTexture: RenderTargetTexture;
  47264. /** Gets the list of meshes to render */
  47265. readonly renderList: Nullable<AbstractMesh[]>;
  47266. /**
  47267. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47268. * @param mesh defines the mesh to attach to
  47269. */
  47270. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47271. /**
  47272. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47273. * @param renderingGroupId The rendering group id corresponding to its index
  47274. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47275. */
  47276. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47277. /**
  47278. * Clean all associated resources
  47279. */
  47280. dispose(): void;
  47281. /**
  47282. * Converts the reflection probe information to a readable string for debug purpose.
  47283. * @param fullDetails Supports for multiple levels of logging within scene loading
  47284. * @returns the human readable reflection probe info
  47285. */
  47286. toString(fullDetails?: boolean): string;
  47287. /**
  47288. * Get the class name of the relfection probe.
  47289. * @returns "ReflectionProbe"
  47290. */
  47291. getClassName(): string;
  47292. /**
  47293. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47294. * @returns The JSON representation of the texture
  47295. */
  47296. serialize(): any;
  47297. /**
  47298. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47299. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47300. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47301. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47302. * @returns The parsed reflection probe if successful
  47303. */
  47304. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47305. }
  47306. }
  47307. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47308. /** @hidden */
  47309. export var _BabylonLoaderRegistered: boolean;
  47310. }
  47311. declare module "babylonjs/Loading/Plugins/index" {
  47312. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47313. }
  47314. declare module "babylonjs/Loading/index" {
  47315. export * from "babylonjs/Loading/loadingScreen";
  47316. export * from "babylonjs/Loading/Plugins/index";
  47317. export * from "babylonjs/Loading/sceneLoader";
  47318. export * from "babylonjs/Loading/sceneLoaderFlags";
  47319. }
  47320. declare module "babylonjs/Materials/Background/index" {
  47321. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47322. }
  47323. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47324. import { Scene } from "babylonjs/scene";
  47325. import { Color3 } from "babylonjs/Maths/math";
  47326. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47328. /**
  47329. * The Physically based simple base material of BJS.
  47330. *
  47331. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47332. * It is used as the base class for both the specGloss and metalRough conventions.
  47333. */
  47334. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47335. /**
  47336. * Number of Simultaneous lights allowed on the material.
  47337. */
  47338. maxSimultaneousLights: number;
  47339. /**
  47340. * If sets to true, disables all the lights affecting the material.
  47341. */
  47342. disableLighting: boolean;
  47343. /**
  47344. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47345. */
  47346. environmentTexture: BaseTexture;
  47347. /**
  47348. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47349. */
  47350. invertNormalMapX: boolean;
  47351. /**
  47352. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47353. */
  47354. invertNormalMapY: boolean;
  47355. /**
  47356. * Normal map used in the model.
  47357. */
  47358. normalTexture: BaseTexture;
  47359. /**
  47360. * Emissivie color used to self-illuminate the model.
  47361. */
  47362. emissiveColor: Color3;
  47363. /**
  47364. * Emissivie texture used to self-illuminate the model.
  47365. */
  47366. emissiveTexture: BaseTexture;
  47367. /**
  47368. * Occlusion Channel Strenght.
  47369. */
  47370. occlusionStrength: number;
  47371. /**
  47372. * Occlusion Texture of the material (adding extra occlusion effects).
  47373. */
  47374. occlusionTexture: BaseTexture;
  47375. /**
  47376. * Defines the alpha limits in alpha test mode.
  47377. */
  47378. alphaCutOff: number;
  47379. /**
  47380. * Gets the current double sided mode.
  47381. */
  47382. /**
  47383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47384. */
  47385. doubleSided: boolean;
  47386. /**
  47387. * Stores the pre-calculated light information of a mesh in a texture.
  47388. */
  47389. lightmapTexture: BaseTexture;
  47390. /**
  47391. * If true, the light map contains occlusion information instead of lighting info.
  47392. */
  47393. useLightmapAsShadowmap: boolean;
  47394. /**
  47395. * Return the active textures of the material.
  47396. */
  47397. getActiveTextures(): BaseTexture[];
  47398. hasTexture(texture: BaseTexture): boolean;
  47399. /**
  47400. * Instantiates a new PBRMaterial instance.
  47401. *
  47402. * @param name The material name
  47403. * @param scene The scene the material will be use in.
  47404. */
  47405. constructor(name: string, scene: Scene);
  47406. getClassName(): string;
  47407. }
  47408. }
  47409. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47410. import { Scene } from "babylonjs/scene";
  47411. import { Color3 } from "babylonjs/Maths/math";
  47412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47413. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47414. /**
  47415. * The PBR material of BJS following the metal roughness convention.
  47416. *
  47417. * This fits to the PBR convention in the GLTF definition:
  47418. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47419. */
  47420. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47421. /**
  47422. * The base color has two different interpretations depending on the value of metalness.
  47423. * When the material is a metal, the base color is the specific measured reflectance value
  47424. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47425. * of the material.
  47426. */
  47427. baseColor: Color3;
  47428. /**
  47429. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47430. * well as opacity information in the alpha channel.
  47431. */
  47432. baseTexture: BaseTexture;
  47433. /**
  47434. * Specifies the metallic scalar value of the material.
  47435. * Can also be used to scale the metalness values of the metallic texture.
  47436. */
  47437. metallic: number;
  47438. /**
  47439. * Specifies the roughness scalar value of the material.
  47440. * Can also be used to scale the roughness values of the metallic texture.
  47441. */
  47442. roughness: number;
  47443. /**
  47444. * Texture containing both the metallic value in the B channel and the
  47445. * roughness value in the G channel to keep better precision.
  47446. */
  47447. metallicRoughnessTexture: BaseTexture;
  47448. /**
  47449. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47450. *
  47451. * @param name The material name
  47452. * @param scene The scene the material will be use in.
  47453. */
  47454. constructor(name: string, scene: Scene);
  47455. /**
  47456. * Return the currrent class name of the material.
  47457. */
  47458. getClassName(): string;
  47459. /**
  47460. * Return the active textures of the material.
  47461. */
  47462. getActiveTextures(): BaseTexture[];
  47463. /**
  47464. * Checks to see if a texture is used in the material.
  47465. * @param texture - Base texture to use.
  47466. * @returns - Boolean specifying if a texture is used in the material.
  47467. */
  47468. hasTexture(texture: BaseTexture): boolean;
  47469. /**
  47470. * Makes a duplicate of the current material.
  47471. * @param name - name to use for the new material.
  47472. */
  47473. clone(name: string): PBRMetallicRoughnessMaterial;
  47474. /**
  47475. * Serialize the material to a parsable JSON object.
  47476. */
  47477. serialize(): any;
  47478. /**
  47479. * Parses a JSON object correponding to the serialize function.
  47480. */
  47481. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47482. }
  47483. }
  47484. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47485. import { Scene } from "babylonjs/scene";
  47486. import { Color3 } from "babylonjs/Maths/math";
  47487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47488. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47489. /**
  47490. * The PBR material of BJS following the specular glossiness convention.
  47491. *
  47492. * This fits to the PBR convention in the GLTF definition:
  47493. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47494. */
  47495. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47496. /**
  47497. * Specifies the diffuse color of the material.
  47498. */
  47499. diffuseColor: Color3;
  47500. /**
  47501. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47502. * channel.
  47503. */
  47504. diffuseTexture: BaseTexture;
  47505. /**
  47506. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47507. */
  47508. specularColor: Color3;
  47509. /**
  47510. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47511. */
  47512. glossiness: number;
  47513. /**
  47514. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47515. */
  47516. specularGlossinessTexture: BaseTexture;
  47517. /**
  47518. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47519. *
  47520. * @param name The material name
  47521. * @param scene The scene the material will be use in.
  47522. */
  47523. constructor(name: string, scene: Scene);
  47524. /**
  47525. * Return the currrent class name of the material.
  47526. */
  47527. getClassName(): string;
  47528. /**
  47529. * Return the active textures of the material.
  47530. */
  47531. getActiveTextures(): BaseTexture[];
  47532. /**
  47533. * Checks to see if a texture is used in the material.
  47534. * @param texture - Base texture to use.
  47535. * @returns - Boolean specifying if a texture is used in the material.
  47536. */
  47537. hasTexture(texture: BaseTexture): boolean;
  47538. /**
  47539. * Makes a duplicate of the current material.
  47540. * @param name - name to use for the new material.
  47541. */
  47542. clone(name: string): PBRSpecularGlossinessMaterial;
  47543. /**
  47544. * Serialize the material to a parsable JSON object.
  47545. */
  47546. serialize(): any;
  47547. /**
  47548. * Parses a JSON object correponding to the serialize function.
  47549. */
  47550. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47551. }
  47552. }
  47553. declare module "babylonjs/Materials/PBR/index" {
  47554. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47555. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47556. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47557. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47558. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47559. }
  47560. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47561. import { Nullable } from "babylonjs/types";
  47562. import { Scene } from "babylonjs/scene";
  47563. import { Matrix } from "babylonjs/Maths/math";
  47564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47565. /**
  47566. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47567. * It can help converting any input color in a desired output one. This can then be used to create effects
  47568. * from sepia, black and white to sixties or futuristic rendering...
  47569. *
  47570. * The only supported format is currently 3dl.
  47571. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47572. */
  47573. export class ColorGradingTexture extends BaseTexture {
  47574. /**
  47575. * The current texture matrix. (will always be identity in color grading texture)
  47576. */
  47577. private _textureMatrix;
  47578. /**
  47579. * The texture URL.
  47580. */
  47581. url: string;
  47582. /**
  47583. * Empty line regex stored for GC.
  47584. */
  47585. private static _noneEmptyLineRegex;
  47586. private _engine;
  47587. /**
  47588. * Instantiates a ColorGradingTexture from the following parameters.
  47589. *
  47590. * @param url The location of the color gradind data (currently only supporting 3dl)
  47591. * @param scene The scene the texture will be used in
  47592. */
  47593. constructor(url: string, scene: Scene);
  47594. /**
  47595. * Returns the texture matrix used in most of the material.
  47596. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47597. */
  47598. getTextureMatrix(): Matrix;
  47599. /**
  47600. * Occurs when the file being loaded is a .3dl LUT file.
  47601. */
  47602. private load3dlTexture;
  47603. /**
  47604. * Starts the loading process of the texture.
  47605. */
  47606. private loadTexture;
  47607. /**
  47608. * Clones the color gradind texture.
  47609. */
  47610. clone(): ColorGradingTexture;
  47611. /**
  47612. * Called during delayed load for textures.
  47613. */
  47614. delayLoad(): void;
  47615. /**
  47616. * Parses a color grading texture serialized by Babylon.
  47617. * @param parsedTexture The texture information being parsedTexture
  47618. * @param scene The scene to load the texture in
  47619. * @param rootUrl The root url of the data assets to load
  47620. * @return A color gradind texture
  47621. */
  47622. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47623. /**
  47624. * Serializes the LUT texture to json format.
  47625. */
  47626. serialize(): any;
  47627. }
  47628. }
  47629. declare module "babylonjs/Misc/dds" {
  47630. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47631. import { Engine } from "babylonjs/Engines/engine";
  47632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47633. import { Nullable } from "babylonjs/types";
  47634. import { Scene } from "babylonjs/scene";
  47635. /**
  47636. * Direct draw surface info
  47637. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47638. */
  47639. export interface DDSInfo {
  47640. /**
  47641. * Width of the texture
  47642. */
  47643. width: number;
  47644. /**
  47645. * Width of the texture
  47646. */
  47647. height: number;
  47648. /**
  47649. * Number of Mipmaps for the texture
  47650. * @see https://en.wikipedia.org/wiki/Mipmap
  47651. */
  47652. mipmapCount: number;
  47653. /**
  47654. * If the textures format is a known fourCC format
  47655. * @see https://www.fourcc.org/
  47656. */
  47657. isFourCC: boolean;
  47658. /**
  47659. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47660. */
  47661. isRGB: boolean;
  47662. /**
  47663. * If the texture is a lumincance format
  47664. */
  47665. isLuminance: boolean;
  47666. /**
  47667. * If this is a cube texture
  47668. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47669. */
  47670. isCube: boolean;
  47671. /**
  47672. * If the texture is a compressed format eg. FOURCC_DXT1
  47673. */
  47674. isCompressed: boolean;
  47675. /**
  47676. * The dxgiFormat of the texture
  47677. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47678. */
  47679. dxgiFormat: number;
  47680. /**
  47681. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47682. */
  47683. textureType: number;
  47684. /**
  47685. * Sphericle polynomial created for the dds texture
  47686. */
  47687. sphericalPolynomial?: SphericalPolynomial;
  47688. }
  47689. /**
  47690. * Class used to provide DDS decompression tools
  47691. */
  47692. export class DDSTools {
  47693. /**
  47694. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47695. */
  47696. static StoreLODInAlphaChannel: boolean;
  47697. /**
  47698. * Gets DDS information from an array buffer
  47699. * @param arrayBuffer defines the array buffer to read data from
  47700. * @returns the DDS information
  47701. */
  47702. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47703. private static _FloatView;
  47704. private static _Int32View;
  47705. private static _ToHalfFloat;
  47706. private static _FromHalfFloat;
  47707. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47708. private static _GetHalfFloatRGBAArrayBuffer;
  47709. private static _GetFloatRGBAArrayBuffer;
  47710. private static _GetFloatAsUIntRGBAArrayBuffer;
  47711. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47712. private static _GetRGBAArrayBuffer;
  47713. private static _ExtractLongWordOrder;
  47714. private static _GetRGBArrayBuffer;
  47715. private static _GetLuminanceArrayBuffer;
  47716. /**
  47717. * Uploads DDS Levels to a Babylon Texture
  47718. * @hidden
  47719. */
  47720. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47721. }
  47722. module "babylonjs/Engines/engine" {
  47723. interface Engine {
  47724. /**
  47725. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47726. * @param rootUrl defines the url where the file to load is located
  47727. * @param scene defines the current scene
  47728. * @param lodScale defines scale to apply to the mip map selection
  47729. * @param lodOffset defines offset to apply to the mip map selection
  47730. * @param onLoad defines an optional callback raised when the texture is loaded
  47731. * @param onError defines an optional callback raised if there is an issue to load the texture
  47732. * @param format defines the format of the data
  47733. * @param forcedExtension defines the extension to use to pick the right loader
  47734. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47735. * @returns the cube texture as an InternalTexture
  47736. */
  47737. 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;
  47738. }
  47739. }
  47740. }
  47741. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47742. import { Nullable } from "babylonjs/types";
  47743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47744. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47745. /**
  47746. * Implementation of the DDS Texture Loader.
  47747. * @hidden
  47748. */
  47749. export class _DDSTextureLoader implements IInternalTextureLoader {
  47750. /**
  47751. * Defines wether the loader supports cascade loading the different faces.
  47752. */
  47753. readonly supportCascades: boolean;
  47754. /**
  47755. * This returns if the loader support the current file information.
  47756. * @param extension defines the file extension of the file being loaded
  47757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47758. * @param fallback defines the fallback internal texture if any
  47759. * @param isBase64 defines whether the texture is encoded as a base64
  47760. * @param isBuffer defines whether the texture data are stored as a buffer
  47761. * @returns true if the loader can load the specified file
  47762. */
  47763. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47764. /**
  47765. * Transform the url before loading if required.
  47766. * @param rootUrl the url of the texture
  47767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47768. * @returns the transformed texture
  47769. */
  47770. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47771. /**
  47772. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47773. * @param rootUrl the url of the texture
  47774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47775. * @returns the fallback texture
  47776. */
  47777. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47778. /**
  47779. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47780. * @param data contains the texture data
  47781. * @param texture defines the BabylonJS internal texture
  47782. * @param createPolynomials will be true if polynomials have been requested
  47783. * @param onLoad defines the callback to trigger once the texture is ready
  47784. * @param onError defines the callback to trigger in case of error
  47785. */
  47786. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47787. /**
  47788. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47789. * @param data contains the texture data
  47790. * @param texture defines the BabylonJS internal texture
  47791. * @param callback defines the method to call once ready to upload
  47792. */
  47793. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47794. }
  47795. }
  47796. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47797. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47798. /** @hidden */
  47799. export var rgbdEncodePixelShader: {
  47800. name: string;
  47801. shader: string;
  47802. };
  47803. }
  47804. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47806. /** @hidden */
  47807. export var rgbdDecodePixelShader: {
  47808. name: string;
  47809. shader: string;
  47810. };
  47811. }
  47812. declare module "babylonjs/Misc/environmentTextureTools" {
  47813. import { Nullable } from "babylonjs/types";
  47814. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47816. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47817. import "babylonjs/Shaders/rgbdEncode.fragment";
  47818. import "babylonjs/Shaders/rgbdDecode.fragment";
  47819. /**
  47820. * Raw texture data and descriptor sufficient for WebGL texture upload
  47821. */
  47822. export interface EnvironmentTextureInfo {
  47823. /**
  47824. * Version of the environment map
  47825. */
  47826. version: number;
  47827. /**
  47828. * Width of image
  47829. */
  47830. width: number;
  47831. /**
  47832. * Irradiance information stored in the file.
  47833. */
  47834. irradiance: any;
  47835. /**
  47836. * Specular information stored in the file.
  47837. */
  47838. specular: any;
  47839. }
  47840. /**
  47841. * Sets of helpers addressing the serialization and deserialization of environment texture
  47842. * stored in a BabylonJS env file.
  47843. * Those files are usually stored as .env files.
  47844. */
  47845. export class EnvironmentTextureTools {
  47846. /**
  47847. * Magic number identifying the env file.
  47848. */
  47849. private static _MagicBytes;
  47850. /**
  47851. * Gets the environment info from an env file.
  47852. * @param data The array buffer containing the .env bytes.
  47853. * @returns the environment file info (the json header) if successfully parsed.
  47854. */
  47855. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47856. /**
  47857. * Creates an environment texture from a loaded cube texture.
  47858. * @param texture defines the cube texture to convert in env file
  47859. * @return a promise containing the environment data if succesfull.
  47860. */
  47861. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47862. /**
  47863. * Creates a JSON representation of the spherical data.
  47864. * @param texture defines the texture containing the polynomials
  47865. * @return the JSON representation of the spherical info
  47866. */
  47867. private static _CreateEnvTextureIrradiance;
  47868. /**
  47869. * Uploads the texture info contained in the env file to the GPU.
  47870. * @param texture defines the internal texture to upload to
  47871. * @param arrayBuffer defines the buffer cotaining the data to load
  47872. * @param info defines the texture info retrieved through the GetEnvInfo method
  47873. * @returns a promise
  47874. */
  47875. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47876. /**
  47877. * Uploads the levels of image data to the GPU.
  47878. * @param texture defines the internal texture to upload to
  47879. * @param imageData defines the array buffer views of image data [mipmap][face]
  47880. * @returns a promise
  47881. */
  47882. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47883. /**
  47884. * Uploads spherical polynomials information to the texture.
  47885. * @param texture defines the texture we are trying to upload the information to
  47886. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47887. */
  47888. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47889. /** @hidden */
  47890. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47891. }
  47892. }
  47893. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47894. import { Nullable } from "babylonjs/types";
  47895. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47896. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47897. /**
  47898. * Implementation of the ENV Texture Loader.
  47899. * @hidden
  47900. */
  47901. export class _ENVTextureLoader implements IInternalTextureLoader {
  47902. /**
  47903. * Defines wether the loader supports cascade loading the different faces.
  47904. */
  47905. readonly supportCascades: boolean;
  47906. /**
  47907. * This returns if the loader support the current file information.
  47908. * @param extension defines the file extension of the file being loaded
  47909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47910. * @param fallback defines the fallback internal texture if any
  47911. * @param isBase64 defines whether the texture is encoded as a base64
  47912. * @param isBuffer defines whether the texture data are stored as a buffer
  47913. * @returns true if the loader can load the specified file
  47914. */
  47915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47916. /**
  47917. * Transform the url before loading if required.
  47918. * @param rootUrl the url of the texture
  47919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47920. * @returns the transformed texture
  47921. */
  47922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47923. /**
  47924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47925. * @param rootUrl the url of the texture
  47926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47927. * @returns the fallback texture
  47928. */
  47929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47930. /**
  47931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47932. * @param data contains the texture data
  47933. * @param texture defines the BabylonJS internal texture
  47934. * @param createPolynomials will be true if polynomials have been requested
  47935. * @param onLoad defines the callback to trigger once the texture is ready
  47936. * @param onError defines the callback to trigger in case of error
  47937. */
  47938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47939. /**
  47940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47941. * @param data contains the texture data
  47942. * @param texture defines the BabylonJS internal texture
  47943. * @param callback defines the method to call once ready to upload
  47944. */
  47945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47946. }
  47947. }
  47948. declare module "babylonjs/Misc/khronosTextureContainer" {
  47949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47950. /**
  47951. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47952. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47953. */
  47954. export class KhronosTextureContainer {
  47955. /** contents of the KTX container file */
  47956. arrayBuffer: any;
  47957. private static HEADER_LEN;
  47958. private static COMPRESSED_2D;
  47959. private static COMPRESSED_3D;
  47960. private static TEX_2D;
  47961. private static TEX_3D;
  47962. /**
  47963. * Gets the openGL type
  47964. */
  47965. glType: number;
  47966. /**
  47967. * Gets the openGL type size
  47968. */
  47969. glTypeSize: number;
  47970. /**
  47971. * Gets the openGL format
  47972. */
  47973. glFormat: number;
  47974. /**
  47975. * Gets the openGL internal format
  47976. */
  47977. glInternalFormat: number;
  47978. /**
  47979. * Gets the base internal format
  47980. */
  47981. glBaseInternalFormat: number;
  47982. /**
  47983. * Gets image width in pixel
  47984. */
  47985. pixelWidth: number;
  47986. /**
  47987. * Gets image height in pixel
  47988. */
  47989. pixelHeight: number;
  47990. /**
  47991. * Gets image depth in pixels
  47992. */
  47993. pixelDepth: number;
  47994. /**
  47995. * Gets the number of array elements
  47996. */
  47997. numberOfArrayElements: number;
  47998. /**
  47999. * Gets the number of faces
  48000. */
  48001. numberOfFaces: number;
  48002. /**
  48003. * Gets the number of mipmap levels
  48004. */
  48005. numberOfMipmapLevels: number;
  48006. /**
  48007. * Gets the bytes of key value data
  48008. */
  48009. bytesOfKeyValueData: number;
  48010. /**
  48011. * Gets the load type
  48012. */
  48013. loadType: number;
  48014. /**
  48015. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48016. */
  48017. isInvalid: boolean;
  48018. /**
  48019. * Creates a new KhronosTextureContainer
  48020. * @param arrayBuffer contents of the KTX container file
  48021. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48022. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48023. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48024. */
  48025. constructor(
  48026. /** contents of the KTX container file */
  48027. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48028. /**
  48029. * Uploads KTX content to a Babylon Texture.
  48030. * It is assumed that the texture has already been created & is currently bound
  48031. * @hidden
  48032. */
  48033. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48034. private _upload2DCompressedLevels;
  48035. }
  48036. }
  48037. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48038. import { Nullable } from "babylonjs/types";
  48039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48040. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48041. /**
  48042. * Implementation of the KTX Texture Loader.
  48043. * @hidden
  48044. */
  48045. export class _KTXTextureLoader implements IInternalTextureLoader {
  48046. /**
  48047. * Defines wether the loader supports cascade loading the different faces.
  48048. */
  48049. readonly supportCascades: boolean;
  48050. /**
  48051. * This returns if the loader support the current file information.
  48052. * @param extension defines the file extension of the file being loaded
  48053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48054. * @param fallback defines the fallback internal texture if any
  48055. * @param isBase64 defines whether the texture is encoded as a base64
  48056. * @param isBuffer defines whether the texture data are stored as a buffer
  48057. * @returns true if the loader can load the specified file
  48058. */
  48059. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48060. /**
  48061. * Transform the url before loading if required.
  48062. * @param rootUrl the url of the texture
  48063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48064. * @returns the transformed texture
  48065. */
  48066. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48067. /**
  48068. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48069. * @param rootUrl the url of the texture
  48070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48071. * @returns the fallback texture
  48072. */
  48073. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48074. /**
  48075. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48076. * @param data contains the texture data
  48077. * @param texture defines the BabylonJS internal texture
  48078. * @param createPolynomials will be true if polynomials have been requested
  48079. * @param onLoad defines the callback to trigger once the texture is ready
  48080. * @param onError defines the callback to trigger in case of error
  48081. */
  48082. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48083. /**
  48084. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48085. * @param data contains the texture data
  48086. * @param texture defines the BabylonJS internal texture
  48087. * @param callback defines the method to call once ready to upload
  48088. */
  48089. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48090. }
  48091. }
  48092. declare module "babylonjs/Misc/tga" {
  48093. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48094. /**
  48095. * Based on jsTGALoader - Javascript loader for TGA file
  48096. * By Vincent Thibault
  48097. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48098. */
  48099. export class TGATools {
  48100. private static _TYPE_INDEXED;
  48101. private static _TYPE_RGB;
  48102. private static _TYPE_GREY;
  48103. private static _TYPE_RLE_INDEXED;
  48104. private static _TYPE_RLE_RGB;
  48105. private static _TYPE_RLE_GREY;
  48106. private static _ORIGIN_MASK;
  48107. private static _ORIGIN_SHIFT;
  48108. private static _ORIGIN_BL;
  48109. private static _ORIGIN_BR;
  48110. private static _ORIGIN_UL;
  48111. private static _ORIGIN_UR;
  48112. /**
  48113. * Gets the header of a TGA file
  48114. * @param data defines the TGA data
  48115. * @returns the header
  48116. */
  48117. static GetTGAHeader(data: Uint8Array): any;
  48118. /**
  48119. * Uploads TGA content to a Babylon Texture
  48120. * @hidden
  48121. */
  48122. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48123. /** @hidden */
  48124. 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;
  48125. /** @hidden */
  48126. 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;
  48127. /** @hidden */
  48128. 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;
  48129. /** @hidden */
  48130. 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;
  48131. /** @hidden */
  48132. 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;
  48133. /** @hidden */
  48134. 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;
  48135. }
  48136. }
  48137. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48138. import { Nullable } from "babylonjs/types";
  48139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48140. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48141. /**
  48142. * Implementation of the TGA Texture Loader.
  48143. * @hidden
  48144. */
  48145. export class _TGATextureLoader implements IInternalTextureLoader {
  48146. /**
  48147. * Defines wether the loader supports cascade loading the different faces.
  48148. */
  48149. readonly supportCascades: boolean;
  48150. /**
  48151. * This returns if the loader support the current file information.
  48152. * @param extension defines the file extension of the file being loaded
  48153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48154. * @param fallback defines the fallback internal texture if any
  48155. * @param isBase64 defines whether the texture is encoded as a base64
  48156. * @param isBuffer defines whether the texture data are stored as a buffer
  48157. * @returns true if the loader can load the specified file
  48158. */
  48159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48160. /**
  48161. * Transform the url before loading if required.
  48162. * @param rootUrl the url of the texture
  48163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48164. * @returns the transformed texture
  48165. */
  48166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48167. /**
  48168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48169. * @param rootUrl the url of the texture
  48170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48171. * @returns the fallback texture
  48172. */
  48173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48174. /**
  48175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48176. * @param data contains the texture data
  48177. * @param texture defines the BabylonJS internal texture
  48178. * @param createPolynomials will be true if polynomials have been requested
  48179. * @param onLoad defines the callback to trigger once the texture is ready
  48180. * @param onError defines the callback to trigger in case of error
  48181. */
  48182. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48183. /**
  48184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48185. * @param data contains the texture data
  48186. * @param texture defines the BabylonJS internal texture
  48187. * @param callback defines the method to call once ready to upload
  48188. */
  48189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48190. }
  48191. }
  48192. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48193. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48194. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48195. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48196. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48197. }
  48198. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48199. import { Scene } from "babylonjs/scene";
  48200. import { Texture } from "babylonjs/Materials/Textures/texture";
  48201. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48202. /**
  48203. * 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.
  48204. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48205. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48206. */
  48207. export class CustomProceduralTexture extends ProceduralTexture {
  48208. private _animate;
  48209. private _time;
  48210. private _config;
  48211. private _texturePath;
  48212. /**
  48213. * Instantiates a new Custom Procedural Texture.
  48214. * 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.
  48215. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48217. * @param name Define the name of the texture
  48218. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48219. * @param size Define the size of the texture to create
  48220. * @param scene Define the scene the texture belongs to
  48221. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48222. * @param generateMipMaps Define if the texture should creates mip maps or not
  48223. */
  48224. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48225. private _loadJson;
  48226. /**
  48227. * Is the texture ready to be used ? (rendered at least once)
  48228. * @returns true if ready, otherwise, false.
  48229. */
  48230. isReady(): boolean;
  48231. /**
  48232. * Render the texture to its associated render target.
  48233. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48234. */
  48235. render(useCameraPostProcess?: boolean): void;
  48236. /**
  48237. * Update the list of dependant textures samplers in the shader.
  48238. */
  48239. updateTextures(): void;
  48240. /**
  48241. * Update the uniform values of the procedural texture in the shader.
  48242. */
  48243. updateShaderUniforms(): void;
  48244. /**
  48245. * Define if the texture animates or not.
  48246. */
  48247. animate: boolean;
  48248. }
  48249. }
  48250. declare module "babylonjs/Shaders/noise.fragment" {
  48251. /** @hidden */
  48252. export var noisePixelShader: {
  48253. name: string;
  48254. shader: string;
  48255. };
  48256. }
  48257. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48258. import { Nullable } from "babylonjs/types";
  48259. import { Scene } from "babylonjs/scene";
  48260. import { Texture } from "babylonjs/Materials/Textures/texture";
  48261. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48262. import "babylonjs/Shaders/noise.fragment";
  48263. /**
  48264. * Class used to generate noise procedural textures
  48265. */
  48266. export class NoiseProceduralTexture extends ProceduralTexture {
  48267. private _time;
  48268. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48269. brightness: number;
  48270. /** Defines the number of octaves to process */
  48271. octaves: number;
  48272. /** Defines the level of persistence (0.8 by default) */
  48273. persistence: number;
  48274. /** Gets or sets animation speed factor (default is 1) */
  48275. animationSpeedFactor: number;
  48276. /**
  48277. * Creates a new NoiseProceduralTexture
  48278. * @param name defines the name fo the texture
  48279. * @param size defines the size of the texture (default is 256)
  48280. * @param scene defines the hosting scene
  48281. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48282. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48283. */
  48284. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48285. private _updateShaderUniforms;
  48286. protected _getDefines(): string;
  48287. /** Generate the current state of the procedural texture */
  48288. render(useCameraPostProcess?: boolean): void;
  48289. /**
  48290. * Serializes this noise procedural texture
  48291. * @returns a serialized noise procedural texture object
  48292. */
  48293. serialize(): any;
  48294. /**
  48295. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48296. * @param parsedTexture defines parsed texture data
  48297. * @param scene defines the current scene
  48298. * @param rootUrl defines the root URL containing noise procedural texture information
  48299. * @returns a parsed NoiseProceduralTexture
  48300. */
  48301. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48302. }
  48303. }
  48304. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48305. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48306. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48307. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48308. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48309. }
  48310. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48311. import { Nullable } from "babylonjs/types";
  48312. import { Scene } from "babylonjs/scene";
  48313. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48315. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48316. /**
  48317. * Raw cube texture where the raw buffers are passed in
  48318. */
  48319. export class RawCubeTexture extends CubeTexture {
  48320. /**
  48321. * Creates a cube texture where the raw buffers are passed in.
  48322. * @param scene defines the scene the texture is attached to
  48323. * @param data defines the array of data to use to create each face
  48324. * @param size defines the size of the textures
  48325. * @param format defines the format of the data
  48326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48327. * @param generateMipMaps defines if the engine should generate the mip levels
  48328. * @param invertY defines if data must be stored with Y axis inverted
  48329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48330. * @param compression defines the compression used (null by default)
  48331. */
  48332. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48333. /**
  48334. * Updates the raw cube texture.
  48335. * @param data defines the data to store
  48336. * @param format defines the data format
  48337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48338. * @param invertY defines if data must be stored with Y axis inverted
  48339. * @param compression defines the compression used (null by default)
  48340. * @param level defines which level of the texture to update
  48341. */
  48342. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48343. /**
  48344. * Updates a raw cube texture with RGBD encoded data.
  48345. * @param data defines the array of data [mipmap][face] to use to create each face
  48346. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48347. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48348. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48349. * @returns a promsie that resolves when the operation is complete
  48350. */
  48351. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48352. /**
  48353. * Clones the raw cube texture.
  48354. * @return a new cube texture
  48355. */
  48356. clone(): CubeTexture;
  48357. /** @hidden */
  48358. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48359. }
  48360. }
  48361. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48362. import { Scene } from "babylonjs/scene";
  48363. import { Texture } from "babylonjs/Materials/Textures/texture";
  48364. /**
  48365. * Class used to store 3D textures containing user data
  48366. */
  48367. export class RawTexture3D extends Texture {
  48368. /** Gets or sets the texture format to use */
  48369. format: number;
  48370. private _engine;
  48371. /**
  48372. * Create a new RawTexture3D
  48373. * @param data defines the data of the texture
  48374. * @param width defines the width of the texture
  48375. * @param height defines the height of the texture
  48376. * @param depth defines the depth of the texture
  48377. * @param format defines the texture format to use
  48378. * @param scene defines the hosting scene
  48379. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48380. * @param invertY defines if texture must be stored with Y axis inverted
  48381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48382. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48383. */
  48384. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48385. /** Gets or sets the texture format to use */
  48386. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48387. /**
  48388. * Update the texture with new data
  48389. * @param data defines the data to store in the texture
  48390. */
  48391. update(data: ArrayBufferView): void;
  48392. }
  48393. }
  48394. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48395. import { Scene } from "babylonjs/scene";
  48396. import { Plane } from "babylonjs/Maths/math";
  48397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48398. /**
  48399. * Creates a refraction texture used by refraction channel of the standard material.
  48400. * It is like a mirror but to see through a material.
  48401. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48402. */
  48403. export class RefractionTexture extends RenderTargetTexture {
  48404. /**
  48405. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48406. * 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.
  48407. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48408. */
  48409. refractionPlane: Plane;
  48410. /**
  48411. * Define how deep under the surface we should see.
  48412. */
  48413. depth: number;
  48414. /**
  48415. * Creates a refraction texture used by refraction channel of the standard material.
  48416. * It is like a mirror but to see through a material.
  48417. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48418. * @param name Define the texture name
  48419. * @param size Define the size of the underlying texture
  48420. * @param scene Define the scene the refraction belongs to
  48421. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48422. */
  48423. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48424. /**
  48425. * Clone the refraction texture.
  48426. * @returns the cloned texture
  48427. */
  48428. clone(): RefractionTexture;
  48429. /**
  48430. * Serialize the texture to a JSON representation you could use in Parse later on
  48431. * @returns the serialized JSON representation
  48432. */
  48433. serialize(): any;
  48434. }
  48435. }
  48436. declare module "babylonjs/Materials/Textures/index" {
  48437. export * from "babylonjs/Materials/Textures/baseTexture";
  48438. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48439. export * from "babylonjs/Materials/Textures/cubeTexture";
  48440. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48441. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48442. export * from "babylonjs/Materials/Textures/internalTexture";
  48443. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48444. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48445. export * from "babylonjs/Materials/Textures/Loaders/index";
  48446. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48447. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48448. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48449. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48450. export * from "babylonjs/Materials/Textures/rawTexture";
  48451. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48452. export * from "babylonjs/Materials/Textures/refractionTexture";
  48453. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48454. export * from "babylonjs/Materials/Textures/texture";
  48455. export * from "babylonjs/Materials/Textures/videoTexture";
  48456. }
  48457. declare module "babylonjs/Materials/index" {
  48458. export * from "babylonjs/Materials/Background/index";
  48459. export * from "babylonjs/Materials/colorCurves";
  48460. export * from "babylonjs/Materials/effect";
  48461. export * from "babylonjs/Materials/fresnelParameters";
  48462. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48463. export * from "babylonjs/Materials/material";
  48464. export * from "babylonjs/Materials/materialDefines";
  48465. export * from "babylonjs/Materials/materialHelper";
  48466. export * from "babylonjs/Materials/multiMaterial";
  48467. export * from "babylonjs/Materials/PBR/index";
  48468. export * from "babylonjs/Materials/pushMaterial";
  48469. export * from "babylonjs/Materials/shaderMaterial";
  48470. export * from "babylonjs/Materials/standardMaterial";
  48471. export * from "babylonjs/Materials/Textures/index";
  48472. export * from "babylonjs/Materials/uniformBuffer";
  48473. export * from "babylonjs/Materials/materialFlags";
  48474. }
  48475. declare module "babylonjs/Maths/index" {
  48476. export * from "babylonjs/Maths/math.scalar";
  48477. export * from "babylonjs/Maths/math";
  48478. export * from "babylonjs/Maths/sphericalPolynomial";
  48479. }
  48480. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48481. import { IDisposable } from "babylonjs/scene";
  48482. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48483. /**
  48484. * Configuration for Draco compression
  48485. */
  48486. export interface IDracoCompressionConfiguration {
  48487. /**
  48488. * Configuration for the decoder.
  48489. */
  48490. decoder?: {
  48491. /**
  48492. * The url to the WebAssembly module.
  48493. */
  48494. wasmUrl?: string;
  48495. /**
  48496. * The url to the WebAssembly binary.
  48497. */
  48498. wasmBinaryUrl?: string;
  48499. /**
  48500. * The url to the fallback JavaScript module.
  48501. */
  48502. fallbackUrl?: string;
  48503. };
  48504. }
  48505. /**
  48506. * Draco compression (https://google.github.io/draco/)
  48507. *
  48508. * This class wraps the Draco module.
  48509. *
  48510. * **Encoder**
  48511. *
  48512. * The encoder is not currently implemented.
  48513. *
  48514. * **Decoder**
  48515. *
  48516. * 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.
  48517. *
  48518. * To update the configuration, use the following code:
  48519. * ```javascript
  48520. * DracoCompression.Configuration = {
  48521. * decoder: {
  48522. * wasmUrl: "<url to the WebAssembly library>",
  48523. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48524. * fallbackUrl: "<url to the fallback JavaScript library>",
  48525. * }
  48526. * };
  48527. * ```
  48528. *
  48529. * 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.
  48530. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48531. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48532. *
  48533. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48534. * ```javascript
  48535. * var dracoCompression = new DracoCompression();
  48536. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48537. * [VertexBuffer.PositionKind]: 0
  48538. * });
  48539. * ```
  48540. *
  48541. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48542. */
  48543. export class DracoCompression implements IDisposable {
  48544. private static _DecoderModulePromise;
  48545. /**
  48546. * The configuration. Defaults to the following urls:
  48547. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48548. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48549. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48550. */
  48551. static Configuration: IDracoCompressionConfiguration;
  48552. /**
  48553. * Returns true if the decoder is available.
  48554. */
  48555. static readonly DecoderAvailable: boolean;
  48556. /**
  48557. * Constructor
  48558. */
  48559. constructor();
  48560. /**
  48561. * Stop all async operations and release resources.
  48562. */
  48563. dispose(): void;
  48564. /**
  48565. * Decode Draco compressed mesh data to vertex data.
  48566. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48567. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48568. * @returns A promise that resolves with the decoded vertex data
  48569. */
  48570. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48571. [kind: string]: number;
  48572. }): Promise<VertexData>;
  48573. private static _GetDecoderModule;
  48574. private static _LoadScriptAsync;
  48575. private static _LoadFileAsync;
  48576. }
  48577. }
  48578. declare module "babylonjs/Meshes/Compression/index" {
  48579. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48580. }
  48581. declare module "babylonjs/Meshes/csg" {
  48582. import { Nullable } from "babylonjs/types";
  48583. import { Scene } from "babylonjs/scene";
  48584. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48585. import { Mesh } from "babylonjs/Meshes/mesh";
  48586. import { Material } from "babylonjs/Materials/material";
  48587. /**
  48588. * Class for building Constructive Solid Geometry
  48589. */
  48590. export class CSG {
  48591. private polygons;
  48592. /**
  48593. * The world matrix
  48594. */
  48595. matrix: Matrix;
  48596. /**
  48597. * Stores the position
  48598. */
  48599. position: Vector3;
  48600. /**
  48601. * Stores the rotation
  48602. */
  48603. rotation: Vector3;
  48604. /**
  48605. * Stores the rotation quaternion
  48606. */
  48607. rotationQuaternion: Nullable<Quaternion>;
  48608. /**
  48609. * Stores the scaling vector
  48610. */
  48611. scaling: Vector3;
  48612. /**
  48613. * Convert the Mesh to CSG
  48614. * @param mesh The Mesh to convert to CSG
  48615. * @returns A new CSG from the Mesh
  48616. */
  48617. static FromMesh(mesh: Mesh): CSG;
  48618. /**
  48619. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48620. * @param polygons Polygons used to construct a CSG solid
  48621. */
  48622. private static FromPolygons;
  48623. /**
  48624. * Clones, or makes a deep copy, of the CSG
  48625. * @returns A new CSG
  48626. */
  48627. clone(): CSG;
  48628. /**
  48629. * Unions this CSG with another CSG
  48630. * @param csg The CSG to union against this CSG
  48631. * @returns The unioned CSG
  48632. */
  48633. union(csg: CSG): CSG;
  48634. /**
  48635. * Unions this CSG with another CSG in place
  48636. * @param csg The CSG to union against this CSG
  48637. */
  48638. unionInPlace(csg: CSG): void;
  48639. /**
  48640. * Subtracts this CSG with another CSG
  48641. * @param csg The CSG to subtract against this CSG
  48642. * @returns A new CSG
  48643. */
  48644. subtract(csg: CSG): CSG;
  48645. /**
  48646. * Subtracts this CSG with another CSG in place
  48647. * @param csg The CSG to subtact against this CSG
  48648. */
  48649. subtractInPlace(csg: CSG): void;
  48650. /**
  48651. * Intersect this CSG with another CSG
  48652. * @param csg The CSG to intersect against this CSG
  48653. * @returns A new CSG
  48654. */
  48655. intersect(csg: CSG): CSG;
  48656. /**
  48657. * Intersects this CSG with another CSG in place
  48658. * @param csg The CSG to intersect against this CSG
  48659. */
  48660. intersectInPlace(csg: CSG): void;
  48661. /**
  48662. * Return a new CSG solid with solid and empty space switched. This solid is
  48663. * not modified.
  48664. * @returns A new CSG solid with solid and empty space switched
  48665. */
  48666. inverse(): CSG;
  48667. /**
  48668. * Inverses the CSG in place
  48669. */
  48670. inverseInPlace(): void;
  48671. /**
  48672. * This is used to keep meshes transformations so they can be restored
  48673. * when we build back a Babylon Mesh
  48674. * NB : All CSG operations are performed in world coordinates
  48675. * @param csg The CSG to copy the transform attributes from
  48676. * @returns This CSG
  48677. */
  48678. copyTransformAttributes(csg: CSG): CSG;
  48679. /**
  48680. * Build Raw mesh from CSG
  48681. * Coordinates here are in world space
  48682. * @param name The name of the mesh geometry
  48683. * @param scene The Scene
  48684. * @param keepSubMeshes Specifies if the submeshes should be kept
  48685. * @returns A new Mesh
  48686. */
  48687. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48688. /**
  48689. * Build Mesh from CSG taking material and transforms into account
  48690. * @param name The name of the Mesh
  48691. * @param material The material of the Mesh
  48692. * @param scene The Scene
  48693. * @param keepSubMeshes Specifies if submeshes should be kept
  48694. * @returns The new Mesh
  48695. */
  48696. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48697. }
  48698. }
  48699. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48700. import { Nullable } from "babylonjs/types";
  48701. import { Scene } from "babylonjs/scene";
  48702. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48703. import { Mesh } from "babylonjs/Meshes/mesh";
  48704. /**
  48705. * Class containing static functions to help procedurally build meshes
  48706. */
  48707. export class RibbonBuilder {
  48708. /**
  48709. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48710. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48711. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48712. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48713. * * 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
  48714. * * 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
  48715. * * 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
  48716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48719. * * 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
  48720. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48721. * * 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
  48722. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48724. * @param name defines the name of the mesh
  48725. * @param options defines the options used to create the mesh
  48726. * @param scene defines the hosting scene
  48727. * @returns the ribbon mesh
  48728. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48730. */
  48731. static CreateRibbon(name: string, options: {
  48732. pathArray: Vector3[][];
  48733. closeArray?: boolean;
  48734. closePath?: boolean;
  48735. offset?: number;
  48736. updatable?: boolean;
  48737. sideOrientation?: number;
  48738. frontUVs?: Vector4;
  48739. backUVs?: Vector4;
  48740. instance?: Mesh;
  48741. invertUV?: boolean;
  48742. uvs?: Vector2[];
  48743. colors?: Color4[];
  48744. }, scene?: Nullable<Scene>): Mesh;
  48745. }
  48746. }
  48747. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48748. import { Vector4 } from "babylonjs/Maths/math";
  48749. import { Mesh } from "babylonjs/Meshes/mesh";
  48750. /**
  48751. * Class containing static functions to help procedurally build meshes
  48752. */
  48753. export class TorusKnotBuilder {
  48754. /**
  48755. * Creates a torus knot mesh
  48756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48763. * @param name defines the name of the mesh
  48764. * @param options defines the options used to create the mesh
  48765. * @param scene defines the hosting scene
  48766. * @returns the torus knot mesh
  48767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48768. */
  48769. static CreateTorusKnot(name: string, options: {
  48770. radius?: number;
  48771. tube?: number;
  48772. radialSegments?: number;
  48773. tubularSegments?: number;
  48774. p?: number;
  48775. q?: number;
  48776. updatable?: boolean;
  48777. sideOrientation?: number;
  48778. frontUVs?: Vector4;
  48779. backUVs?: Vector4;
  48780. }, scene: any): Mesh;
  48781. }
  48782. }
  48783. declare module "babylonjs/Meshes/polygonMesh" {
  48784. import { Scene } from "babylonjs/scene";
  48785. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48786. import { Mesh } from "babylonjs/Meshes/mesh";
  48787. /**
  48788. * Polygon
  48789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48790. */
  48791. export class Polygon {
  48792. /**
  48793. * Creates a rectangle
  48794. * @param xmin bottom X coord
  48795. * @param ymin bottom Y coord
  48796. * @param xmax top X coord
  48797. * @param ymax top Y coord
  48798. * @returns points that make the resulting rectation
  48799. */
  48800. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48801. /**
  48802. * Creates a circle
  48803. * @param radius radius of circle
  48804. * @param cx scale in x
  48805. * @param cy scale in y
  48806. * @param numberOfSides number of sides that make up the circle
  48807. * @returns points that make the resulting circle
  48808. */
  48809. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48810. /**
  48811. * Creates a polygon from input string
  48812. * @param input Input polygon data
  48813. * @returns the parsed points
  48814. */
  48815. static Parse(input: string): Vector2[];
  48816. /**
  48817. * Starts building a polygon from x and y coordinates
  48818. * @param x x coordinate
  48819. * @param y y coordinate
  48820. * @returns the started path2
  48821. */
  48822. static StartingAt(x: number, y: number): Path2;
  48823. }
  48824. /**
  48825. * Builds a polygon
  48826. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48827. */
  48828. export class PolygonMeshBuilder {
  48829. private _points;
  48830. private _outlinepoints;
  48831. private _holes;
  48832. private _name;
  48833. private _scene;
  48834. private _epoints;
  48835. private _eholes;
  48836. private _addToepoint;
  48837. /**
  48838. * Babylon reference to the earcut plugin.
  48839. */
  48840. bjsEarcut: any;
  48841. /**
  48842. * Creates a PolygonMeshBuilder
  48843. * @param name name of the builder
  48844. * @param contours Path of the polygon
  48845. * @param scene scene to add to
  48846. * @param earcutInjection can be used to inject your own earcut reference
  48847. */
  48848. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48849. /**
  48850. * Adds a whole within the polygon
  48851. * @param hole Array of points defining the hole
  48852. * @returns this
  48853. */
  48854. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48855. /**
  48856. * Creates the polygon
  48857. * @param updatable If the mesh should be updatable
  48858. * @param depth The depth of the mesh created
  48859. * @returns the created mesh
  48860. */
  48861. build(updatable?: boolean, depth?: number): Mesh;
  48862. /**
  48863. * Adds a side to the polygon
  48864. * @param positions points that make the polygon
  48865. * @param normals normals of the polygon
  48866. * @param uvs uvs of the polygon
  48867. * @param indices indices of the polygon
  48868. * @param bounds bounds of the polygon
  48869. * @param points points of the polygon
  48870. * @param depth depth of the polygon
  48871. * @param flip flip of the polygon
  48872. */
  48873. private addSide;
  48874. }
  48875. }
  48876. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48877. import { Scene } from "babylonjs/scene";
  48878. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48879. import { Mesh } from "babylonjs/Meshes/mesh";
  48880. /**
  48881. * Class containing static functions to help procedurally build meshes
  48882. */
  48883. export class PolygonBuilder {
  48884. /**
  48885. * Creates a polygon mesh
  48886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48887. * * 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
  48888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48891. * * Remember you can only change the shape positions, not their number when updating a polygon
  48892. * @param name defines the name of the mesh
  48893. * @param options defines the options used to create the mesh
  48894. * @param scene defines the hosting scene
  48895. * @param earcutInjection can be used to inject your own earcut reference
  48896. * @returns the polygon mesh
  48897. */
  48898. static CreatePolygon(name: string, options: {
  48899. shape: Vector3[];
  48900. holes?: Vector3[][];
  48901. depth?: number;
  48902. faceUV?: Vector4[];
  48903. faceColors?: Color4[];
  48904. updatable?: boolean;
  48905. sideOrientation?: number;
  48906. frontUVs?: Vector4;
  48907. backUVs?: Vector4;
  48908. }, scene: Scene, earcutInjection?: any): Mesh;
  48909. /**
  48910. * Creates an extruded polygon mesh, with depth in the Y direction.
  48911. * * 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)
  48912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48913. * @param name defines the name of the mesh
  48914. * @param options defines the options used to create the mesh
  48915. * @param scene defines the hosting scene
  48916. * @param earcutInjection can be used to inject your own earcut reference
  48917. * @returns the polygon mesh
  48918. */
  48919. static ExtrudePolygon(name: string, options: {
  48920. shape: Vector3[];
  48921. holes?: Vector3[][];
  48922. depth?: number;
  48923. faceUV?: Vector4[];
  48924. faceColors?: Color4[];
  48925. updatable?: boolean;
  48926. sideOrientation?: number;
  48927. frontUVs?: Vector4;
  48928. backUVs?: Vector4;
  48929. }, scene: Scene, earcutInjection?: any): Mesh;
  48930. }
  48931. }
  48932. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48933. import { Nullable } from "babylonjs/types";
  48934. import { Scene } from "babylonjs/scene";
  48935. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48936. import { Mesh } from "babylonjs/Meshes/mesh";
  48937. /**
  48938. * Class containing static functions to help procedurally build meshes
  48939. */
  48940. export class ShapeBuilder {
  48941. /**
  48942. * 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.
  48943. * * 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.
  48944. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48945. * * 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.
  48946. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48947. * * 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
  48948. * * 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
  48949. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48952. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48954. * @param name defines the name of the mesh
  48955. * @param options defines the options used to create the mesh
  48956. * @param scene defines the hosting scene
  48957. * @returns the extruded shape mesh
  48958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48960. */
  48961. static ExtrudeShape(name: string, options: {
  48962. shape: Vector3[];
  48963. path: Vector3[];
  48964. scale?: number;
  48965. rotation?: number;
  48966. cap?: number;
  48967. updatable?: boolean;
  48968. sideOrientation?: number;
  48969. frontUVs?: Vector4;
  48970. backUVs?: Vector4;
  48971. instance?: Mesh;
  48972. invertUV?: boolean;
  48973. }, scene?: Nullable<Scene>): Mesh;
  48974. /**
  48975. * Creates an custom extruded shape mesh.
  48976. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48977. * * 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.
  48978. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48979. * * 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
  48980. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48981. * * 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
  48982. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48983. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48984. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48985. * * 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
  48986. * * 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
  48987. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48992. * @param name defines the name of the mesh
  48993. * @param options defines the options used to create the mesh
  48994. * @param scene defines the hosting scene
  48995. * @returns the custom extruded shape mesh
  48996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48999. */
  49000. static ExtrudeShapeCustom(name: string, options: {
  49001. shape: Vector3[];
  49002. path: Vector3[];
  49003. scaleFunction?: any;
  49004. rotationFunction?: any;
  49005. ribbonCloseArray?: boolean;
  49006. ribbonClosePath?: boolean;
  49007. cap?: number;
  49008. updatable?: boolean;
  49009. sideOrientation?: number;
  49010. frontUVs?: Vector4;
  49011. backUVs?: Vector4;
  49012. instance?: Mesh;
  49013. invertUV?: boolean;
  49014. }, scene: Scene): Mesh;
  49015. private static _ExtrudeShapeGeneric;
  49016. }
  49017. }
  49018. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49019. import { Scene } from "babylonjs/scene";
  49020. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49021. import { Mesh } from "babylonjs/Meshes/mesh";
  49022. /**
  49023. * Class containing static functions to help procedurally build meshes
  49024. */
  49025. export class LatheBuilder {
  49026. /**
  49027. * Creates lathe mesh.
  49028. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49029. * * 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
  49030. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49031. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49032. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49033. * * 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
  49034. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49035. * * 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
  49036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49040. * @param name defines the name of the mesh
  49041. * @param options defines the options used to create the mesh
  49042. * @param scene defines the hosting scene
  49043. * @returns the lathe mesh
  49044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49045. */
  49046. static CreateLathe(name: string, options: {
  49047. shape: Vector3[];
  49048. radius?: number;
  49049. tessellation?: number;
  49050. clip?: number;
  49051. arc?: number;
  49052. closed?: boolean;
  49053. updatable?: boolean;
  49054. sideOrientation?: number;
  49055. frontUVs?: Vector4;
  49056. backUVs?: Vector4;
  49057. cap?: number;
  49058. invertUV?: boolean;
  49059. }, scene: Scene): Mesh;
  49060. }
  49061. }
  49062. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49063. import { Scene } from "babylonjs/scene";
  49064. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49065. import { Mesh } from "babylonjs/Meshes/mesh";
  49066. /**
  49067. * Class containing static functions to help procedurally build meshes
  49068. */
  49069. export class TubeBuilder {
  49070. /**
  49071. * Creates a tube mesh.
  49072. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49073. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49074. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49075. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49076. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49077. * * 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)
  49078. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49079. * * 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
  49080. * * 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
  49081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49085. * @param name defines the name of the mesh
  49086. * @param options defines the options used to create the mesh
  49087. * @param scene defines the hosting scene
  49088. * @returns the tube mesh
  49089. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49090. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49091. */
  49092. static CreateTube(name: string, options: {
  49093. path: Vector3[];
  49094. radius?: number;
  49095. tessellation?: number;
  49096. radiusFunction?: {
  49097. (i: number, distance: number): number;
  49098. };
  49099. cap?: number;
  49100. arc?: number;
  49101. updatable?: boolean;
  49102. sideOrientation?: number;
  49103. frontUVs?: Vector4;
  49104. backUVs?: Vector4;
  49105. instance?: Mesh;
  49106. invertUV?: boolean;
  49107. }, scene: Scene): Mesh;
  49108. }
  49109. }
  49110. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49111. import { Scene } from "babylonjs/scene";
  49112. import { Vector4 } from "babylonjs/Maths/math";
  49113. import { Mesh } from "babylonjs/Meshes/mesh";
  49114. /**
  49115. * Class containing static functions to help procedurally build meshes
  49116. */
  49117. export class IcoSphereBuilder {
  49118. /**
  49119. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49120. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49121. * * 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`)
  49122. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49123. * * 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
  49124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49127. * @param name defines the name of the mesh
  49128. * @param options defines the options used to create the mesh
  49129. * @param scene defines the hosting scene
  49130. * @returns the icosahedron mesh
  49131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49132. */
  49133. static CreateIcoSphere(name: string, options: {
  49134. radius?: number;
  49135. radiusX?: number;
  49136. radiusY?: number;
  49137. radiusZ?: number;
  49138. flat?: boolean;
  49139. subdivisions?: number;
  49140. sideOrientation?: number;
  49141. frontUVs?: Vector4;
  49142. backUVs?: Vector4;
  49143. updatable?: boolean;
  49144. }, scene: Scene): Mesh;
  49145. }
  49146. }
  49147. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49148. import { Vector3 } from "babylonjs/Maths/math";
  49149. import { Mesh } from "babylonjs/Meshes/mesh";
  49150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49151. /**
  49152. * Class containing static functions to help procedurally build meshes
  49153. */
  49154. export class DecalBuilder {
  49155. /**
  49156. * Creates a decal mesh.
  49157. * 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
  49158. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49159. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49160. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49161. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49162. * @param name defines the name of the mesh
  49163. * @param sourceMesh defines the mesh where the decal must be applied
  49164. * @param options defines the options used to create the mesh
  49165. * @param scene defines the hosting scene
  49166. * @returns the decal mesh
  49167. * @see https://doc.babylonjs.com/how_to/decals
  49168. */
  49169. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49170. position?: Vector3;
  49171. normal?: Vector3;
  49172. size?: Vector3;
  49173. angle?: number;
  49174. }): Mesh;
  49175. }
  49176. }
  49177. declare module "babylonjs/Meshes/meshBuilder" {
  49178. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49179. import { Nullable } from "babylonjs/types";
  49180. import { Scene } from "babylonjs/scene";
  49181. import { Mesh } from "babylonjs/Meshes/mesh";
  49182. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49183. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49185. /**
  49186. * Class containing static functions to help procedurally build meshes
  49187. */
  49188. export class MeshBuilder {
  49189. /**
  49190. * Creates a box mesh
  49191. * * The parameter `size` sets the size (float) of each box side (default 1)
  49192. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49193. * * 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)
  49194. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49199. * @param name defines the name of the mesh
  49200. * @param options defines the options used to create the mesh
  49201. * @param scene defines the hosting scene
  49202. * @returns the box mesh
  49203. */
  49204. static CreateBox(name: string, options: {
  49205. size?: number;
  49206. width?: number;
  49207. height?: number;
  49208. depth?: number;
  49209. faceUV?: Vector4[];
  49210. faceColors?: Color4[];
  49211. sideOrientation?: number;
  49212. frontUVs?: Vector4;
  49213. backUVs?: Vector4;
  49214. updatable?: boolean;
  49215. }, scene?: Nullable<Scene>): Mesh;
  49216. /**
  49217. * Creates a sphere mesh
  49218. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49219. * * 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`)
  49220. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49221. * * 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
  49222. * * 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)
  49223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49226. * @param name defines the name of the mesh
  49227. * @param options defines the options used to create the mesh
  49228. * @param scene defines the hosting scene
  49229. * @returns the sphere mesh
  49230. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49231. */
  49232. static CreateSphere(name: string, options: {
  49233. segments?: number;
  49234. diameter?: number;
  49235. diameterX?: number;
  49236. diameterY?: number;
  49237. diameterZ?: number;
  49238. arc?: number;
  49239. slice?: number;
  49240. sideOrientation?: number;
  49241. frontUVs?: Vector4;
  49242. backUVs?: Vector4;
  49243. updatable?: boolean;
  49244. }, scene: any): Mesh;
  49245. /**
  49246. * Creates a plane polygonal mesh. By default, this is a disc
  49247. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49248. * * 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
  49249. * * 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
  49250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49253. * @param name defines the name of the mesh
  49254. * @param options defines the options used to create the mesh
  49255. * @param scene defines the hosting scene
  49256. * @returns the plane polygonal mesh
  49257. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49258. */
  49259. static CreateDisc(name: string, options: {
  49260. radius?: number;
  49261. tessellation?: number;
  49262. arc?: number;
  49263. updatable?: boolean;
  49264. sideOrientation?: number;
  49265. frontUVs?: Vector4;
  49266. backUVs?: Vector4;
  49267. }, scene?: Nullable<Scene>): Mesh;
  49268. /**
  49269. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49270. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49271. * * 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`)
  49272. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49273. * * 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
  49274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49277. * @param name defines the name of the mesh
  49278. * @param options defines the options used to create the mesh
  49279. * @param scene defines the hosting scene
  49280. * @returns the icosahedron mesh
  49281. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49282. */
  49283. static CreateIcoSphere(name: string, options: {
  49284. radius?: number;
  49285. radiusX?: number;
  49286. radiusY?: number;
  49287. radiusZ?: number;
  49288. flat?: boolean;
  49289. subdivisions?: number;
  49290. sideOrientation?: number;
  49291. frontUVs?: Vector4;
  49292. backUVs?: Vector4;
  49293. updatable?: boolean;
  49294. }, scene: Scene): Mesh;
  49295. /**
  49296. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49297. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49298. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49299. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49300. * * 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
  49301. * * 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
  49302. * * 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
  49303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49306. * * 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
  49307. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49308. * * 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
  49309. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49311. * @param name defines the name of the mesh
  49312. * @param options defines the options used to create the mesh
  49313. * @param scene defines the hosting scene
  49314. * @returns the ribbon mesh
  49315. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49317. */
  49318. static CreateRibbon(name: string, options: {
  49319. pathArray: Vector3[][];
  49320. closeArray?: boolean;
  49321. closePath?: boolean;
  49322. offset?: number;
  49323. updatable?: boolean;
  49324. sideOrientation?: number;
  49325. frontUVs?: Vector4;
  49326. backUVs?: Vector4;
  49327. instance?: Mesh;
  49328. invertUV?: boolean;
  49329. uvs?: Vector2[];
  49330. colors?: Color4[];
  49331. }, scene?: Nullable<Scene>): Mesh;
  49332. /**
  49333. * Creates a cylinder or a cone mesh
  49334. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49335. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49336. * * 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.
  49337. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49338. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49339. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49340. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49341. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49342. * * 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).
  49343. * * 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
  49344. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49345. * * 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
  49346. * * 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.
  49347. * * If `enclose` is false, a ring surface is one element.
  49348. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49349. * * 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
  49350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49353. * @param name defines the name of the mesh
  49354. * @param options defines the options used to create the mesh
  49355. * @param scene defines the hosting scene
  49356. * @returns the cylinder mesh
  49357. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49358. */
  49359. static CreateCylinder(name: string, options: {
  49360. height?: number;
  49361. diameterTop?: number;
  49362. diameterBottom?: number;
  49363. diameter?: number;
  49364. tessellation?: number;
  49365. subdivisions?: number;
  49366. arc?: number;
  49367. faceColors?: Color4[];
  49368. faceUV?: Vector4[];
  49369. updatable?: boolean;
  49370. hasRings?: boolean;
  49371. enclose?: boolean;
  49372. sideOrientation?: number;
  49373. frontUVs?: Vector4;
  49374. backUVs?: Vector4;
  49375. }, scene: any): Mesh;
  49376. /**
  49377. * Creates a torus mesh
  49378. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49379. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49380. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49384. * @param name defines the name of the mesh
  49385. * @param options defines the options used to create the mesh
  49386. * @param scene defines the hosting scene
  49387. * @returns the torus mesh
  49388. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49389. */
  49390. static CreateTorus(name: string, options: {
  49391. diameter?: number;
  49392. thickness?: number;
  49393. tessellation?: number;
  49394. updatable?: boolean;
  49395. sideOrientation?: number;
  49396. frontUVs?: Vector4;
  49397. backUVs?: Vector4;
  49398. }, scene: any): Mesh;
  49399. /**
  49400. * Creates a torus knot mesh
  49401. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49402. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49403. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49404. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49408. * @param name defines the name of the mesh
  49409. * @param options defines the options used to create the mesh
  49410. * @param scene defines the hosting scene
  49411. * @returns the torus knot mesh
  49412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49413. */
  49414. static CreateTorusKnot(name: string, options: {
  49415. radius?: number;
  49416. tube?: number;
  49417. radialSegments?: number;
  49418. tubularSegments?: number;
  49419. p?: number;
  49420. q?: number;
  49421. updatable?: boolean;
  49422. sideOrientation?: number;
  49423. frontUVs?: Vector4;
  49424. backUVs?: Vector4;
  49425. }, scene: any): Mesh;
  49426. /**
  49427. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49428. * * 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
  49429. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49430. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49431. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49432. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49433. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49434. * * 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
  49435. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49438. * @param name defines the name of the new line system
  49439. * @param options defines the options used to create the line system
  49440. * @param scene defines the hosting scene
  49441. * @returns a new line system mesh
  49442. */
  49443. static CreateLineSystem(name: string, options: {
  49444. lines: Vector3[][];
  49445. updatable?: boolean;
  49446. instance?: Nullable<LinesMesh>;
  49447. colors?: Nullable<Color4[][]>;
  49448. useVertexAlpha?: boolean;
  49449. }, scene: Nullable<Scene>): LinesMesh;
  49450. /**
  49451. * Creates a line mesh
  49452. * 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
  49453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49454. * * The parameter `points` is an array successive Vector3
  49455. * * 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
  49456. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49457. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49458. * * When updating an instance, remember that only point positions can change, not the number of points
  49459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49461. * @param name defines the name of the new line system
  49462. * @param options defines the options used to create the line system
  49463. * @param scene defines the hosting scene
  49464. * @returns a new line mesh
  49465. */
  49466. static CreateLines(name: string, options: {
  49467. points: Vector3[];
  49468. updatable?: boolean;
  49469. instance?: Nullable<LinesMesh>;
  49470. colors?: Color4[];
  49471. useVertexAlpha?: boolean;
  49472. }, scene?: Nullable<Scene>): LinesMesh;
  49473. /**
  49474. * Creates a dashed line mesh
  49475. * * 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
  49476. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49477. * * The parameter `points` is an array successive Vector3
  49478. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49479. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49480. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49481. * * 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
  49482. * * When updating an instance, remember that only point positions can change, not the number of points
  49483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49484. * @param name defines the name of the mesh
  49485. * @param options defines the options used to create the mesh
  49486. * @param scene defines the hosting scene
  49487. * @returns the dashed line mesh
  49488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49489. */
  49490. static CreateDashedLines(name: string, options: {
  49491. points: Vector3[];
  49492. dashSize?: number;
  49493. gapSize?: number;
  49494. dashNb?: number;
  49495. updatable?: boolean;
  49496. instance?: LinesMesh;
  49497. }, scene?: Nullable<Scene>): LinesMesh;
  49498. /**
  49499. * 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.
  49500. * * 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.
  49501. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49502. * * 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.
  49503. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49504. * * 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
  49505. * * 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
  49506. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49509. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49511. * @param name defines the name of the mesh
  49512. * @param options defines the options used to create the mesh
  49513. * @param scene defines the hosting scene
  49514. * @returns the extruded shape mesh
  49515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49517. */
  49518. static ExtrudeShape(name: string, options: {
  49519. shape: Vector3[];
  49520. path: Vector3[];
  49521. scale?: number;
  49522. rotation?: number;
  49523. cap?: number;
  49524. updatable?: boolean;
  49525. sideOrientation?: number;
  49526. frontUVs?: Vector4;
  49527. backUVs?: Vector4;
  49528. instance?: Mesh;
  49529. invertUV?: boolean;
  49530. }, scene?: Nullable<Scene>): Mesh;
  49531. /**
  49532. * Creates an custom extruded shape mesh.
  49533. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49534. * * 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.
  49535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49536. * * 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
  49537. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49538. * * 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
  49539. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49540. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49541. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49542. * * 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
  49543. * * 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
  49544. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49549. * @param name defines the name of the mesh
  49550. * @param options defines the options used to create the mesh
  49551. * @param scene defines the hosting scene
  49552. * @returns the custom extruded shape mesh
  49553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49556. */
  49557. static ExtrudeShapeCustom(name: string, options: {
  49558. shape: Vector3[];
  49559. path: Vector3[];
  49560. scaleFunction?: any;
  49561. rotationFunction?: any;
  49562. ribbonCloseArray?: boolean;
  49563. ribbonClosePath?: boolean;
  49564. cap?: number;
  49565. updatable?: boolean;
  49566. sideOrientation?: number;
  49567. frontUVs?: Vector4;
  49568. backUVs?: Vector4;
  49569. instance?: Mesh;
  49570. invertUV?: boolean;
  49571. }, scene: Scene): Mesh;
  49572. /**
  49573. * Creates lathe mesh.
  49574. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49575. * * 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
  49576. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49577. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49578. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49579. * * 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
  49580. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49581. * * 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
  49582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49586. * @param name defines the name of the mesh
  49587. * @param options defines the options used to create the mesh
  49588. * @param scene defines the hosting scene
  49589. * @returns the lathe mesh
  49590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49591. */
  49592. static CreateLathe(name: string, options: {
  49593. shape: Vector3[];
  49594. radius?: number;
  49595. tessellation?: number;
  49596. clip?: number;
  49597. arc?: number;
  49598. closed?: boolean;
  49599. updatable?: boolean;
  49600. sideOrientation?: number;
  49601. frontUVs?: Vector4;
  49602. backUVs?: Vector4;
  49603. cap?: number;
  49604. invertUV?: boolean;
  49605. }, scene: Scene): Mesh;
  49606. /**
  49607. * Creates a plane mesh
  49608. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49609. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49610. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49614. * @param name defines the name of the mesh
  49615. * @param options defines the options used to create the mesh
  49616. * @param scene defines the hosting scene
  49617. * @returns the plane mesh
  49618. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49619. */
  49620. static CreatePlane(name: string, options: {
  49621. size?: number;
  49622. width?: number;
  49623. height?: number;
  49624. sideOrientation?: number;
  49625. frontUVs?: Vector4;
  49626. backUVs?: Vector4;
  49627. updatable?: boolean;
  49628. sourcePlane?: Plane;
  49629. }, scene: Scene): Mesh;
  49630. /**
  49631. * Creates a ground mesh
  49632. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49633. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49635. * @param name defines the name of the mesh
  49636. * @param options defines the options used to create the mesh
  49637. * @param scene defines the hosting scene
  49638. * @returns the ground mesh
  49639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49640. */
  49641. static CreateGround(name: string, options: {
  49642. width?: number;
  49643. height?: number;
  49644. subdivisions?: number;
  49645. subdivisionsX?: number;
  49646. subdivisionsY?: number;
  49647. updatable?: boolean;
  49648. }, scene: any): Mesh;
  49649. /**
  49650. * Creates a tiled ground mesh
  49651. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49652. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49653. * * 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
  49654. * * 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
  49655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49656. * @param name defines the name of the mesh
  49657. * @param options defines the options used to create the mesh
  49658. * @param scene defines the hosting scene
  49659. * @returns the tiled ground mesh
  49660. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49661. */
  49662. static CreateTiledGround(name: string, options: {
  49663. xmin: number;
  49664. zmin: number;
  49665. xmax: number;
  49666. zmax: number;
  49667. subdivisions?: {
  49668. w: number;
  49669. h: number;
  49670. };
  49671. precision?: {
  49672. w: number;
  49673. h: number;
  49674. };
  49675. updatable?: boolean;
  49676. }, scene: Scene): Mesh;
  49677. /**
  49678. * Creates a ground mesh from a height map
  49679. * * The parameter `url` sets the URL of the height map image resource.
  49680. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49681. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49682. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49683. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49684. * * 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.
  49685. * * 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).
  49686. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49688. * @param name defines the name of the mesh
  49689. * @param url defines the url to the height map
  49690. * @param options defines the options used to create the mesh
  49691. * @param scene defines the hosting scene
  49692. * @returns the ground mesh
  49693. * @see https://doc.babylonjs.com/babylon101/height_map
  49694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49695. */
  49696. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49697. width?: number;
  49698. height?: number;
  49699. subdivisions?: number;
  49700. minHeight?: number;
  49701. maxHeight?: number;
  49702. colorFilter?: Color3;
  49703. alphaFilter?: number;
  49704. updatable?: boolean;
  49705. onReady?: (mesh: GroundMesh) => void;
  49706. }, scene: Scene): GroundMesh;
  49707. /**
  49708. * Creates a polygon mesh
  49709. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49710. * * 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
  49711. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49714. * * Remember you can only change the shape positions, not their number when updating a polygon
  49715. * @param name defines the name of the mesh
  49716. * @param options defines the options used to create the mesh
  49717. * @param scene defines the hosting scene
  49718. * @param earcutInjection can be used to inject your own earcut reference
  49719. * @returns the polygon mesh
  49720. */
  49721. static CreatePolygon(name: string, options: {
  49722. shape: Vector3[];
  49723. holes?: Vector3[][];
  49724. depth?: number;
  49725. faceUV?: Vector4[];
  49726. faceColors?: Color4[];
  49727. updatable?: boolean;
  49728. sideOrientation?: number;
  49729. frontUVs?: Vector4;
  49730. backUVs?: Vector4;
  49731. }, scene: Scene, earcutInjection?: any): Mesh;
  49732. /**
  49733. * Creates an extruded polygon mesh, with depth in the Y direction.
  49734. * * 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)
  49735. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49736. * @param name defines the name of the mesh
  49737. * @param options defines the options used to create the mesh
  49738. * @param scene defines the hosting scene
  49739. * @param earcutInjection can be used to inject your own earcut reference
  49740. * @returns the polygon mesh
  49741. */
  49742. static ExtrudePolygon(name: string, options: {
  49743. shape: Vector3[];
  49744. holes?: Vector3[][];
  49745. depth?: number;
  49746. faceUV?: Vector4[];
  49747. faceColors?: Color4[];
  49748. updatable?: boolean;
  49749. sideOrientation?: number;
  49750. frontUVs?: Vector4;
  49751. backUVs?: Vector4;
  49752. }, scene: Scene, earcutInjection?: any): Mesh;
  49753. /**
  49754. * Creates a tube mesh.
  49755. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49756. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49757. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49758. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49759. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49760. * * 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)
  49761. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49762. * * 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
  49763. * * 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
  49764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49768. * @param name defines the name of the mesh
  49769. * @param options defines the options used to create the mesh
  49770. * @param scene defines the hosting scene
  49771. * @returns the tube mesh
  49772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49773. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49774. */
  49775. static CreateTube(name: string, options: {
  49776. path: Vector3[];
  49777. radius?: number;
  49778. tessellation?: number;
  49779. radiusFunction?: {
  49780. (i: number, distance: number): number;
  49781. };
  49782. cap?: number;
  49783. arc?: number;
  49784. updatable?: boolean;
  49785. sideOrientation?: number;
  49786. frontUVs?: Vector4;
  49787. backUVs?: Vector4;
  49788. instance?: Mesh;
  49789. invertUV?: boolean;
  49790. }, scene: Scene): Mesh;
  49791. /**
  49792. * Creates a polyhedron mesh
  49793. * * 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
  49794. * * The parameter `size` (positive float, default 1) sets the polygon size
  49795. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49796. * * 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`
  49797. * * 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
  49798. * * 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)`)
  49799. * * 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
  49800. * * 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
  49801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49804. * @param name defines the name of the mesh
  49805. * @param options defines the options used to create the mesh
  49806. * @param scene defines the hosting scene
  49807. * @returns the polyhedron mesh
  49808. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49809. */
  49810. static CreatePolyhedron(name: string, options: {
  49811. type?: number;
  49812. size?: number;
  49813. sizeX?: number;
  49814. sizeY?: number;
  49815. sizeZ?: number;
  49816. custom?: any;
  49817. faceUV?: Vector4[];
  49818. faceColors?: Color4[];
  49819. flat?: boolean;
  49820. updatable?: boolean;
  49821. sideOrientation?: number;
  49822. frontUVs?: Vector4;
  49823. backUVs?: Vector4;
  49824. }, scene: Scene): Mesh;
  49825. /**
  49826. * Creates a decal mesh.
  49827. * 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
  49828. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49829. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49830. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49831. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49832. * @param name defines the name of the mesh
  49833. * @param sourceMesh defines the mesh where the decal must be applied
  49834. * @param options defines the options used to create the mesh
  49835. * @param scene defines the hosting scene
  49836. * @returns the decal mesh
  49837. * @see https://doc.babylonjs.com/how_to/decals
  49838. */
  49839. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49840. position?: Vector3;
  49841. normal?: Vector3;
  49842. size?: Vector3;
  49843. angle?: number;
  49844. }): Mesh;
  49845. }
  49846. }
  49847. declare module "babylonjs/Meshes/meshSimplification" {
  49848. import { Mesh } from "babylonjs/Meshes/mesh";
  49849. /**
  49850. * A simplifier interface for future simplification implementations
  49851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49852. */
  49853. export interface ISimplifier {
  49854. /**
  49855. * Simplification of a given mesh according to the given settings.
  49856. * Since this requires computation, it is assumed that the function runs async.
  49857. * @param settings The settings of the simplification, including quality and distance
  49858. * @param successCallback A callback that will be called after the mesh was simplified.
  49859. * @param errorCallback in case of an error, this callback will be called. optional.
  49860. */
  49861. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49862. }
  49863. /**
  49864. * Expected simplification settings.
  49865. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49866. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49867. */
  49868. export interface ISimplificationSettings {
  49869. /**
  49870. * Gets or sets the expected quality
  49871. */
  49872. quality: number;
  49873. /**
  49874. * Gets or sets the distance when this optimized version should be used
  49875. */
  49876. distance: number;
  49877. /**
  49878. * Gets an already optimized mesh
  49879. */
  49880. optimizeMesh?: boolean;
  49881. }
  49882. /**
  49883. * Class used to specify simplification options
  49884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49885. */
  49886. export class SimplificationSettings implements ISimplificationSettings {
  49887. /** expected quality */
  49888. quality: number;
  49889. /** distance when this optimized version should be used */
  49890. distance: number;
  49891. /** already optimized mesh */
  49892. optimizeMesh?: boolean | undefined;
  49893. /**
  49894. * Creates a SimplificationSettings
  49895. * @param quality expected quality
  49896. * @param distance distance when this optimized version should be used
  49897. * @param optimizeMesh already optimized mesh
  49898. */
  49899. constructor(
  49900. /** expected quality */
  49901. quality: number,
  49902. /** distance when this optimized version should be used */
  49903. distance: number,
  49904. /** already optimized mesh */
  49905. optimizeMesh?: boolean | undefined);
  49906. }
  49907. /**
  49908. * Interface used to define a simplification task
  49909. */
  49910. export interface ISimplificationTask {
  49911. /**
  49912. * Array of settings
  49913. */
  49914. settings: Array<ISimplificationSettings>;
  49915. /**
  49916. * Simplification type
  49917. */
  49918. simplificationType: SimplificationType;
  49919. /**
  49920. * Mesh to simplify
  49921. */
  49922. mesh: Mesh;
  49923. /**
  49924. * Callback called on success
  49925. */
  49926. successCallback?: () => void;
  49927. /**
  49928. * Defines if parallel processing can be used
  49929. */
  49930. parallelProcessing: boolean;
  49931. }
  49932. /**
  49933. * Queue used to order the simplification tasks
  49934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49935. */
  49936. export class SimplificationQueue {
  49937. private _simplificationArray;
  49938. /**
  49939. * Gets a boolean indicating that the process is still running
  49940. */
  49941. running: boolean;
  49942. /**
  49943. * Creates a new queue
  49944. */
  49945. constructor();
  49946. /**
  49947. * Adds a new simplification task
  49948. * @param task defines a task to add
  49949. */
  49950. addTask(task: ISimplificationTask): void;
  49951. /**
  49952. * Execute next task
  49953. */
  49954. executeNext(): void;
  49955. /**
  49956. * Execute a simplification task
  49957. * @param task defines the task to run
  49958. */
  49959. runSimplification(task: ISimplificationTask): void;
  49960. private getSimplifier;
  49961. }
  49962. /**
  49963. * The implemented types of simplification
  49964. * At the moment only Quadratic Error Decimation is implemented
  49965. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49966. */
  49967. export enum SimplificationType {
  49968. /** Quadratic error decimation */
  49969. QUADRATIC = 0
  49970. }
  49971. }
  49972. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49973. import { Scene } from "babylonjs/scene";
  49974. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49975. import { ISceneComponent } from "babylonjs/sceneComponent";
  49976. module "babylonjs/scene" {
  49977. interface Scene {
  49978. /** @hidden (Backing field) */
  49979. _simplificationQueue: SimplificationQueue;
  49980. /**
  49981. * Gets or sets the simplification queue attached to the scene
  49982. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49983. */
  49984. simplificationQueue: SimplificationQueue;
  49985. }
  49986. }
  49987. module "babylonjs/Meshes/mesh" {
  49988. interface Mesh {
  49989. /**
  49990. * Simplify the mesh according to the given array of settings.
  49991. * Function will return immediately and will simplify async
  49992. * @param settings a collection of simplification settings
  49993. * @param parallelProcessing should all levels calculate parallel or one after the other
  49994. * @param simplificationType the type of simplification to run
  49995. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49996. * @returns the current mesh
  49997. */
  49998. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49999. }
  50000. }
  50001. /**
  50002. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50003. * created in a scene
  50004. */
  50005. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50006. /**
  50007. * The component name helpfull to identify the component in the list of scene components.
  50008. */
  50009. readonly name: string;
  50010. /**
  50011. * The scene the component belongs to.
  50012. */
  50013. scene: Scene;
  50014. /**
  50015. * Creates a new instance of the component for the given scene
  50016. * @param scene Defines the scene to register the component in
  50017. */
  50018. constructor(scene: Scene);
  50019. /**
  50020. * Registers the component in a given scene
  50021. */
  50022. register(): void;
  50023. /**
  50024. * Rebuilds the elements related to this component in case of
  50025. * context lost for instance.
  50026. */
  50027. rebuild(): void;
  50028. /**
  50029. * Disposes the component and the associated ressources
  50030. */
  50031. dispose(): void;
  50032. private _beforeCameraUpdate;
  50033. }
  50034. }
  50035. declare module "babylonjs/Meshes/Builders/index" {
  50036. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50037. export * from "babylonjs/Meshes/Builders/discBuilder";
  50038. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50039. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50040. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50041. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50042. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50043. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50044. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50045. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50046. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50047. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50048. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50049. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50050. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50051. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50052. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50053. }
  50054. declare module "babylonjs/Meshes/index" {
  50055. export * from "babylonjs/Meshes/abstractMesh";
  50056. export * from "babylonjs/Meshes/buffer";
  50057. export * from "babylonjs/Meshes/Compression/index";
  50058. export * from "babylonjs/Meshes/csg";
  50059. export * from "babylonjs/Meshes/geometry";
  50060. export * from "babylonjs/Meshes/groundMesh";
  50061. export * from "babylonjs/Meshes/instancedMesh";
  50062. export * from "babylonjs/Meshes/linesMesh";
  50063. export * from "babylonjs/Meshes/mesh";
  50064. export * from "babylonjs/Meshes/mesh.vertexData";
  50065. export * from "babylonjs/Meshes/meshBuilder";
  50066. export * from "babylonjs/Meshes/meshSimplification";
  50067. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50068. export * from "babylonjs/Meshes/polygonMesh";
  50069. export * from "babylonjs/Meshes/subMesh";
  50070. export * from "babylonjs/Meshes/transformNode";
  50071. export * from "babylonjs/Meshes/Builders/index";
  50072. }
  50073. declare module "babylonjs/Morph/index" {
  50074. export * from "babylonjs/Morph/morphTarget";
  50075. export * from "babylonjs/Morph/morphTargetManager";
  50076. }
  50077. declare module "babylonjs/Offline/database" {
  50078. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50079. /**
  50080. * Class used to enable access to IndexedDB
  50081. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50082. */
  50083. export class Database implements IOfflineProvider {
  50084. private _callbackManifestChecked;
  50085. private _currentSceneUrl;
  50086. private _db;
  50087. private _enableSceneOffline;
  50088. private _enableTexturesOffline;
  50089. private _manifestVersionFound;
  50090. private _mustUpdateRessources;
  50091. private _hasReachedQuota;
  50092. private _isSupported;
  50093. private _idbFactory;
  50094. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50095. private static IsUASupportingBlobStorage;
  50096. /**
  50097. * Gets a boolean indicating if Database storate is enabled (off by default)
  50098. */
  50099. static IDBStorageEnabled: boolean;
  50100. /**
  50101. * Gets a boolean indicating if scene must be saved in the database
  50102. */
  50103. readonly enableSceneOffline: boolean;
  50104. /**
  50105. * Gets a boolean indicating if textures must be saved in the database
  50106. */
  50107. readonly enableTexturesOffline: boolean;
  50108. /**
  50109. * Creates a new Database
  50110. * @param urlToScene defines the url to load the scene
  50111. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50112. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50113. */
  50114. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50115. private static _ParseURL;
  50116. private static _ReturnFullUrlLocation;
  50117. private _checkManifestFile;
  50118. /**
  50119. * Open the database and make it available
  50120. * @param successCallback defines the callback to call on success
  50121. * @param errorCallback defines the callback to call on error
  50122. */
  50123. open(successCallback: () => void, errorCallback: () => void): void;
  50124. /**
  50125. * Loads an image from the database
  50126. * @param url defines the url to load from
  50127. * @param image defines the target DOM image
  50128. */
  50129. loadImage(url: string, image: HTMLImageElement): void;
  50130. private _loadImageFromDBAsync;
  50131. private _saveImageIntoDBAsync;
  50132. private _checkVersionFromDB;
  50133. private _loadVersionFromDBAsync;
  50134. private _saveVersionIntoDBAsync;
  50135. /**
  50136. * Loads a file from database
  50137. * @param url defines the URL to load from
  50138. * @param sceneLoaded defines a callback to call on success
  50139. * @param progressCallBack defines a callback to call when progress changed
  50140. * @param errorCallback defines a callback to call on error
  50141. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50142. */
  50143. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50144. private _loadFileAsync;
  50145. private _saveFileAsync;
  50146. /**
  50147. * Validates if xhr data is correct
  50148. * @param xhr defines the request to validate
  50149. * @param dataType defines the expected data type
  50150. * @returns true if data is correct
  50151. */
  50152. private static _ValidateXHRData;
  50153. }
  50154. }
  50155. declare module "babylonjs/Offline/index" {
  50156. export * from "babylonjs/Offline/database";
  50157. export * from "babylonjs/Offline/IOfflineProvider";
  50158. }
  50159. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50160. /** @hidden */
  50161. export var gpuUpdateParticlesPixelShader: {
  50162. name: string;
  50163. shader: string;
  50164. };
  50165. }
  50166. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50167. /** @hidden */
  50168. export var gpuUpdateParticlesVertexShader: {
  50169. name: string;
  50170. shader: string;
  50171. };
  50172. }
  50173. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50174. /** @hidden */
  50175. export var clipPlaneFragmentDeclaration2: {
  50176. name: string;
  50177. shader: string;
  50178. };
  50179. }
  50180. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50181. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50182. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50183. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50184. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50185. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50186. /** @hidden */
  50187. export var gpuRenderParticlesPixelShader: {
  50188. name: string;
  50189. shader: string;
  50190. };
  50191. }
  50192. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50193. /** @hidden */
  50194. export var clipPlaneVertexDeclaration2: {
  50195. name: string;
  50196. shader: string;
  50197. };
  50198. }
  50199. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50200. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50202. /** @hidden */
  50203. export var gpuRenderParticlesVertexShader: {
  50204. name: string;
  50205. shader: string;
  50206. };
  50207. }
  50208. declare module "babylonjs/Particles/gpuParticleSystem" {
  50209. import { Nullable } from "babylonjs/types";
  50210. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50211. import { Observable } from "babylonjs/Misc/observable";
  50212. import { Color4, Color3 } from "babylonjs/Maths/math";
  50213. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50214. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50215. import { Scene, IDisposable } from "babylonjs/scene";
  50216. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50217. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50218. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50219. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50220. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50221. /**
  50222. * This represents a GPU particle system in Babylon
  50223. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50224. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50225. */
  50226. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50227. /**
  50228. * The layer mask we are rendering the particles through.
  50229. */
  50230. layerMask: number;
  50231. private _capacity;
  50232. private _activeCount;
  50233. private _currentActiveCount;
  50234. private _accumulatedCount;
  50235. private _renderEffect;
  50236. private _updateEffect;
  50237. private _buffer0;
  50238. private _buffer1;
  50239. private _spriteBuffer;
  50240. private _updateVAO;
  50241. private _renderVAO;
  50242. private _targetIndex;
  50243. private _sourceBuffer;
  50244. private _targetBuffer;
  50245. private _engine;
  50246. private _currentRenderId;
  50247. private _started;
  50248. private _stopped;
  50249. private _timeDelta;
  50250. private _randomTexture;
  50251. private _randomTexture2;
  50252. private _attributesStrideSize;
  50253. private _updateEffectOptions;
  50254. private _randomTextureSize;
  50255. private _actualFrame;
  50256. private readonly _rawTextureWidth;
  50257. /**
  50258. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50259. */
  50260. static readonly IsSupported: boolean;
  50261. /**
  50262. * An event triggered when the system is disposed.
  50263. */
  50264. onDisposeObservable: Observable<GPUParticleSystem>;
  50265. /**
  50266. * Gets the maximum number of particles active at the same time.
  50267. * @returns The max number of active particles.
  50268. */
  50269. getCapacity(): number;
  50270. /**
  50271. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50272. * to override the particles.
  50273. */
  50274. forceDepthWrite: boolean;
  50275. /**
  50276. * Gets or set the number of active particles
  50277. */
  50278. activeParticleCount: number;
  50279. private _preWarmDone;
  50280. /**
  50281. * Is this system ready to be used/rendered
  50282. * @return true if the system is ready
  50283. */
  50284. isReady(): boolean;
  50285. /**
  50286. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50287. * @returns True if it has been started, otherwise false.
  50288. */
  50289. isStarted(): boolean;
  50290. /**
  50291. * Starts the particle system and begins to emit
  50292. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50293. */
  50294. start(delay?: number): void;
  50295. /**
  50296. * Stops the particle system.
  50297. */
  50298. stop(): void;
  50299. /**
  50300. * Remove all active particles
  50301. */
  50302. reset(): void;
  50303. /**
  50304. * Returns the string "GPUParticleSystem"
  50305. * @returns a string containing the class name
  50306. */
  50307. getClassName(): string;
  50308. private _colorGradientsTexture;
  50309. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50310. /**
  50311. * Adds a new color gradient
  50312. * @param gradient defines the gradient to use (between 0 and 1)
  50313. * @param color1 defines the color to affect to the specified gradient
  50314. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50315. * @returns the current particle system
  50316. */
  50317. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50318. /**
  50319. * Remove a specific color gradient
  50320. * @param gradient defines the gradient to remove
  50321. * @returns the current particle system
  50322. */
  50323. removeColorGradient(gradient: number): GPUParticleSystem;
  50324. private _angularSpeedGradientsTexture;
  50325. private _sizeGradientsTexture;
  50326. private _velocityGradientsTexture;
  50327. private _limitVelocityGradientsTexture;
  50328. private _dragGradientsTexture;
  50329. private _addFactorGradient;
  50330. /**
  50331. * Adds a new size gradient
  50332. * @param gradient defines the gradient to use (between 0 and 1)
  50333. * @param factor defines the size factor to affect to the specified gradient
  50334. * @returns the current particle system
  50335. */
  50336. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50337. /**
  50338. * Remove a specific size gradient
  50339. * @param gradient defines the gradient to remove
  50340. * @returns the current particle system
  50341. */
  50342. removeSizeGradient(gradient: number): GPUParticleSystem;
  50343. /**
  50344. * Adds a new angular speed gradient
  50345. * @param gradient defines the gradient to use (between 0 and 1)
  50346. * @param factor defines the angular speed to affect to the specified gradient
  50347. * @returns the current particle system
  50348. */
  50349. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50350. /**
  50351. * Remove a specific angular speed gradient
  50352. * @param gradient defines the gradient to remove
  50353. * @returns the current particle system
  50354. */
  50355. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50356. /**
  50357. * Adds a new velocity gradient
  50358. * @param gradient defines the gradient to use (between 0 and 1)
  50359. * @param factor defines the velocity to affect to the specified gradient
  50360. * @returns the current particle system
  50361. */
  50362. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50363. /**
  50364. * Remove a specific velocity gradient
  50365. * @param gradient defines the gradient to remove
  50366. * @returns the current particle system
  50367. */
  50368. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50369. /**
  50370. * Adds a new limit velocity gradient
  50371. * @param gradient defines the gradient to use (between 0 and 1)
  50372. * @param factor defines the limit velocity value to affect to the specified gradient
  50373. * @returns the current particle system
  50374. */
  50375. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50376. /**
  50377. * Remove a specific limit velocity gradient
  50378. * @param gradient defines the gradient to remove
  50379. * @returns the current particle system
  50380. */
  50381. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50382. /**
  50383. * Adds a new drag gradient
  50384. * @param gradient defines the gradient to use (between 0 and 1)
  50385. * @param factor defines the drag value to affect to the specified gradient
  50386. * @returns the current particle system
  50387. */
  50388. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50389. /**
  50390. * Remove a specific drag gradient
  50391. * @param gradient defines the gradient to remove
  50392. * @returns the current particle system
  50393. */
  50394. removeDragGradient(gradient: number): GPUParticleSystem;
  50395. /**
  50396. * Not supported by GPUParticleSystem
  50397. * @param gradient defines the gradient to use (between 0 and 1)
  50398. * @param factor defines the emit rate value to affect to the specified gradient
  50399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50400. * @returns the current particle system
  50401. */
  50402. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50403. /**
  50404. * Not supported by GPUParticleSystem
  50405. * @param gradient defines the gradient to remove
  50406. * @returns the current particle system
  50407. */
  50408. removeEmitRateGradient(gradient: number): IParticleSystem;
  50409. /**
  50410. * Not supported by GPUParticleSystem
  50411. * @param gradient defines the gradient to use (between 0 and 1)
  50412. * @param factor defines the start size value to affect to the specified gradient
  50413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50414. * @returns the current particle system
  50415. */
  50416. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50417. /**
  50418. * Not supported by GPUParticleSystem
  50419. * @param gradient defines the gradient to remove
  50420. * @returns the current particle system
  50421. */
  50422. removeStartSizeGradient(gradient: number): IParticleSystem;
  50423. /**
  50424. * Not supported by GPUParticleSystem
  50425. * @param gradient defines the gradient to use (between 0 and 1)
  50426. * @param min defines the color remap minimal range
  50427. * @param max defines the color remap maximal range
  50428. * @returns the current particle system
  50429. */
  50430. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50431. /**
  50432. * Not supported by GPUParticleSystem
  50433. * @param gradient defines the gradient to remove
  50434. * @returns the current particle system
  50435. */
  50436. removeColorRemapGradient(): IParticleSystem;
  50437. /**
  50438. * Not supported by GPUParticleSystem
  50439. * @param gradient defines the gradient to use (between 0 and 1)
  50440. * @param min defines the alpha remap minimal range
  50441. * @param max defines the alpha remap maximal range
  50442. * @returns the current particle system
  50443. */
  50444. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50445. /**
  50446. * Not supported by GPUParticleSystem
  50447. * @param gradient defines the gradient to remove
  50448. * @returns the current particle system
  50449. */
  50450. removeAlphaRemapGradient(): IParticleSystem;
  50451. /**
  50452. * Not supported by GPUParticleSystem
  50453. * @param gradient defines the gradient to use (between 0 and 1)
  50454. * @param color defines the color to affect to the specified gradient
  50455. * @returns the current particle system
  50456. */
  50457. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50458. /**
  50459. * Not supported by GPUParticleSystem
  50460. * @param gradient defines the gradient to remove
  50461. * @returns the current particle system
  50462. */
  50463. removeRampGradient(): IParticleSystem;
  50464. /**
  50465. * Not supported by GPUParticleSystem
  50466. * @returns the list of ramp gradients
  50467. */
  50468. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50469. /**
  50470. * Not supported by GPUParticleSystem
  50471. * Gets or sets a boolean indicating that ramp gradients must be used
  50472. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50473. */
  50474. useRampGradients: boolean;
  50475. /**
  50476. * Not supported by GPUParticleSystem
  50477. * @param gradient defines the gradient to use (between 0 and 1)
  50478. * @param factor defines the life time factor to affect to the specified gradient
  50479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50480. * @returns the current particle system
  50481. */
  50482. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50483. /**
  50484. * Not supported by GPUParticleSystem
  50485. * @param gradient defines the gradient to remove
  50486. * @returns the current particle system
  50487. */
  50488. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50489. /**
  50490. * Instantiates a GPU particle system.
  50491. * 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.
  50492. * @param name The name of the particle system
  50493. * @param options The options used to create the system
  50494. * @param scene The scene the particle system belongs to
  50495. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50496. */
  50497. constructor(name: string, options: Partial<{
  50498. capacity: number;
  50499. randomTextureSize: number;
  50500. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50501. protected _reset(): void;
  50502. private _createUpdateVAO;
  50503. private _createRenderVAO;
  50504. private _initialize;
  50505. /** @hidden */
  50506. _recreateUpdateEffect(): void;
  50507. /** @hidden */
  50508. _recreateRenderEffect(): void;
  50509. /**
  50510. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50511. * @param preWarm defines if we are in the pre-warmimg phase
  50512. */
  50513. animate(preWarm?: boolean): void;
  50514. private _createFactorGradientTexture;
  50515. private _createSizeGradientTexture;
  50516. private _createAngularSpeedGradientTexture;
  50517. private _createVelocityGradientTexture;
  50518. private _createLimitVelocityGradientTexture;
  50519. private _createDragGradientTexture;
  50520. private _createColorGradientTexture;
  50521. /**
  50522. * Renders the particle system in its current state
  50523. * @param preWarm defines if the system should only update the particles but not render them
  50524. * @returns the current number of particles
  50525. */
  50526. render(preWarm?: boolean): number;
  50527. /**
  50528. * Rebuilds the particle system
  50529. */
  50530. rebuild(): void;
  50531. private _releaseBuffers;
  50532. private _releaseVAOs;
  50533. /**
  50534. * Disposes the particle system and free the associated resources
  50535. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50536. */
  50537. dispose(disposeTexture?: boolean): void;
  50538. /**
  50539. * Clones the particle system.
  50540. * @param name The name of the cloned object
  50541. * @param newEmitter The new emitter to use
  50542. * @returns the cloned particle system
  50543. */
  50544. clone(name: string, newEmitter: any): GPUParticleSystem;
  50545. /**
  50546. * Serializes the particle system to a JSON object.
  50547. * @returns the JSON object
  50548. */
  50549. serialize(): any;
  50550. /**
  50551. * Parses a JSON object to create a GPU particle system.
  50552. * @param parsedParticleSystem The JSON object to parse
  50553. * @param scene The scene to create the particle system in
  50554. * @param rootUrl The root url to use to load external dependencies like texture
  50555. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50556. * @returns the parsed GPU particle system
  50557. */
  50558. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50559. }
  50560. }
  50561. declare module "babylonjs/Particles/particleSystemSet" {
  50562. import { Nullable } from "babylonjs/types";
  50563. import { Color3 } from "babylonjs/Maths/math";
  50564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50566. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50567. import { Scene, IDisposable } from "babylonjs/scene";
  50568. /**
  50569. * Represents a set of particle systems working together to create a specific effect
  50570. */
  50571. export class ParticleSystemSet implements IDisposable {
  50572. private _emitterCreationOptions;
  50573. private _emitterNode;
  50574. /**
  50575. * Gets the particle system list
  50576. */
  50577. systems: IParticleSystem[];
  50578. /**
  50579. * Gets the emitter node used with this set
  50580. */
  50581. readonly emitterNode: Nullable<TransformNode>;
  50582. /**
  50583. * Creates a new emitter mesh as a sphere
  50584. * @param options defines the options used to create the sphere
  50585. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50586. * @param scene defines the hosting scene
  50587. */
  50588. setEmitterAsSphere(options: {
  50589. diameter: number;
  50590. segments: number;
  50591. color: Color3;
  50592. }, renderingGroupId: number, scene: Scene): void;
  50593. /**
  50594. * Starts all particle systems of the set
  50595. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50596. */
  50597. start(emitter?: AbstractMesh): void;
  50598. /**
  50599. * Release all associated resources
  50600. */
  50601. dispose(): void;
  50602. /**
  50603. * Serialize the set into a JSON compatible object
  50604. * @returns a JSON compatible representation of the set
  50605. */
  50606. serialize(): any;
  50607. /**
  50608. * Parse a new ParticleSystemSet from a serialized source
  50609. * @param data defines a JSON compatible representation of the set
  50610. * @param scene defines the hosting scene
  50611. * @param gpu defines if we want GPU particles or CPU particles
  50612. * @returns a new ParticleSystemSet
  50613. */
  50614. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50615. }
  50616. }
  50617. declare module "babylonjs/Particles/particleHelper" {
  50618. import { Nullable } from "babylonjs/types";
  50619. import { Scene } from "babylonjs/scene";
  50620. import { Vector3 } from "babylonjs/Maths/math";
  50621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50622. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50623. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50624. /**
  50625. * This class is made for on one-liner static method to help creating particle system set.
  50626. */
  50627. export class ParticleHelper {
  50628. /**
  50629. * Gets or sets base Assets URL
  50630. */
  50631. static BaseAssetsUrl: string;
  50632. /**
  50633. * Create a default particle system that you can tweak
  50634. * @param emitter defines the emitter to use
  50635. * @param capacity defines the system capacity (default is 500 particles)
  50636. * @param scene defines the hosting scene
  50637. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50638. * @returns the new Particle system
  50639. */
  50640. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50641. /**
  50642. * This is the main static method (one-liner) of this helper to create different particle systems
  50643. * @param type This string represents the type to the particle system to create
  50644. * @param scene The scene where the particle system should live
  50645. * @param gpu If the system will use gpu
  50646. * @returns the ParticleSystemSet created
  50647. */
  50648. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50649. /**
  50650. * Static function used to export a particle system to a ParticleSystemSet variable.
  50651. * Please note that the emitter shape is not exported
  50652. * @param systems defines the particle systems to export
  50653. * @returns the created particle system set
  50654. */
  50655. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50656. }
  50657. }
  50658. declare module "babylonjs/Particles/particleSystemComponent" {
  50659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50660. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50661. import "babylonjs/Shaders/particles.vertex";
  50662. module "babylonjs/Engines/engine" {
  50663. interface Engine {
  50664. /**
  50665. * Create an effect to use with particle systems.
  50666. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50667. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50668. * @param uniformsNames defines a list of attribute names
  50669. * @param samplers defines an array of string used to represent textures
  50670. * @param defines defines the string containing the defines to use to compile the shaders
  50671. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50672. * @param onCompiled defines a function to call when the effect creation is successful
  50673. * @param onError defines a function to call when the effect creation has failed
  50674. * @returns the new Effect
  50675. */
  50676. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50677. }
  50678. }
  50679. module "babylonjs/Meshes/mesh" {
  50680. interface Mesh {
  50681. /**
  50682. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50683. * @returns an array of IParticleSystem
  50684. */
  50685. getEmittedParticleSystems(): IParticleSystem[];
  50686. /**
  50687. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50688. * @returns an array of IParticleSystem
  50689. */
  50690. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50691. }
  50692. }
  50693. /**
  50694. * @hidden
  50695. */
  50696. export var _IDoNeedToBeInTheBuild: number;
  50697. }
  50698. declare module "babylonjs/Particles/index" {
  50699. export * from "babylonjs/Particles/baseParticleSystem";
  50700. export * from "babylonjs/Particles/EmitterTypes/index";
  50701. export * from "babylonjs/Particles/gpuParticleSystem";
  50702. export * from "babylonjs/Particles/IParticleSystem";
  50703. export * from "babylonjs/Particles/particle";
  50704. export * from "babylonjs/Particles/particleHelper";
  50705. export * from "babylonjs/Particles/particleSystem";
  50706. export * from "babylonjs/Particles/particleSystemComponent";
  50707. export * from "babylonjs/Particles/particleSystemSet";
  50708. export * from "babylonjs/Particles/solidParticle";
  50709. export * from "babylonjs/Particles/solidParticleSystem";
  50710. export * from "babylonjs/Particles/subEmitter";
  50711. }
  50712. declare module "babylonjs/Physics/physicsEngineComponent" {
  50713. import { Nullable } from "babylonjs/types";
  50714. import { Observable, Observer } from "babylonjs/Misc/observable";
  50715. import { Vector3 } from "babylonjs/Maths/math";
  50716. import { Mesh } from "babylonjs/Meshes/mesh";
  50717. import { ISceneComponent } from "babylonjs/sceneComponent";
  50718. import { Scene } from "babylonjs/scene";
  50719. import { Node } from "babylonjs/node";
  50720. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50721. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50722. module "babylonjs/scene" {
  50723. interface Scene {
  50724. /** @hidden (Backing field) */
  50725. _physicsEngine: Nullable<IPhysicsEngine>;
  50726. /**
  50727. * Gets the current physics engine
  50728. * @returns a IPhysicsEngine or null if none attached
  50729. */
  50730. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50731. /**
  50732. * Enables physics to the current scene
  50733. * @param gravity defines the scene's gravity for the physics engine
  50734. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50735. * @return a boolean indicating if the physics engine was initialized
  50736. */
  50737. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50738. /**
  50739. * Disables and disposes the physics engine associated with the scene
  50740. */
  50741. disablePhysicsEngine(): void;
  50742. /**
  50743. * Gets a boolean indicating if there is an active physics engine
  50744. * @returns a boolean indicating if there is an active physics engine
  50745. */
  50746. isPhysicsEnabled(): boolean;
  50747. /**
  50748. * Deletes a physics compound impostor
  50749. * @param compound defines the compound to delete
  50750. */
  50751. deleteCompoundImpostor(compound: any): void;
  50752. /**
  50753. * An event triggered when physic simulation is about to be run
  50754. */
  50755. onBeforePhysicsObservable: Observable<Scene>;
  50756. /**
  50757. * An event triggered when physic simulation has been done
  50758. */
  50759. onAfterPhysicsObservable: Observable<Scene>;
  50760. }
  50761. }
  50762. module "babylonjs/Meshes/abstractMesh" {
  50763. interface AbstractMesh {
  50764. /** @hidden */
  50765. _physicsImpostor: Nullable<PhysicsImpostor>;
  50766. /**
  50767. * Gets or sets impostor used for physic simulation
  50768. * @see http://doc.babylonjs.com/features/physics_engine
  50769. */
  50770. physicsImpostor: Nullable<PhysicsImpostor>;
  50771. /**
  50772. * Gets the current physics impostor
  50773. * @see http://doc.babylonjs.com/features/physics_engine
  50774. * @returns a physics impostor or null
  50775. */
  50776. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50777. /** Apply a physic impulse to the mesh
  50778. * @param force defines the force to apply
  50779. * @param contactPoint defines where to apply the force
  50780. * @returns the current mesh
  50781. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50782. */
  50783. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50784. /**
  50785. * Creates a physic joint between two meshes
  50786. * @param otherMesh defines the other mesh to use
  50787. * @param pivot1 defines the pivot to use on this mesh
  50788. * @param pivot2 defines the pivot to use on the other mesh
  50789. * @param options defines additional options (can be plugin dependent)
  50790. * @returns the current mesh
  50791. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50792. */
  50793. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50794. /** @hidden */
  50795. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50796. }
  50797. }
  50798. /**
  50799. * Defines the physics engine scene component responsible to manage a physics engine
  50800. */
  50801. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50802. /**
  50803. * The component name helpful to identify the component in the list of scene components.
  50804. */
  50805. readonly name: string;
  50806. /**
  50807. * The scene the component belongs to.
  50808. */
  50809. scene: Scene;
  50810. /**
  50811. * Creates a new instance of the component for the given scene
  50812. * @param scene Defines the scene to register the component in
  50813. */
  50814. constructor(scene: Scene);
  50815. /**
  50816. * Registers the component in a given scene
  50817. */
  50818. register(): void;
  50819. /**
  50820. * Rebuilds the elements related to this component in case of
  50821. * context lost for instance.
  50822. */
  50823. rebuild(): void;
  50824. /**
  50825. * Disposes the component and the associated ressources
  50826. */
  50827. dispose(): void;
  50828. }
  50829. }
  50830. declare module "babylonjs/Physics/physicsHelper" {
  50831. import { Nullable } from "babylonjs/types";
  50832. import { Vector3 } from "babylonjs/Maths/math";
  50833. import { Mesh } from "babylonjs/Meshes/mesh";
  50834. import { Ray } from "babylonjs/Culling/ray";
  50835. import { Scene } from "babylonjs/scene";
  50836. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50837. /**
  50838. * A helper for physics simulations
  50839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50840. */
  50841. export class PhysicsHelper {
  50842. private _scene;
  50843. private _physicsEngine;
  50844. /**
  50845. * Initializes the Physics helper
  50846. * @param scene Babylon.js scene
  50847. */
  50848. constructor(scene: Scene);
  50849. /**
  50850. * Applies a radial explosion impulse
  50851. * @param origin the origin of the explosion
  50852. * @param radius the explosion radius
  50853. * @param strength the explosion strength
  50854. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50855. * @returns A physics radial explosion event, or null
  50856. */
  50857. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50858. /**
  50859. * Applies a radial explosion force
  50860. * @param origin the origin of the explosion
  50861. * @param radius the explosion radius
  50862. * @param strength the explosion strength
  50863. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50864. * @returns A physics radial explosion event, or null
  50865. */
  50866. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50867. /**
  50868. * Creates a gravitational field
  50869. * @param origin the origin of the explosion
  50870. * @param radius the explosion radius
  50871. * @param strength the explosion strength
  50872. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50873. * @returns A physics gravitational field event, or null
  50874. */
  50875. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50876. /**
  50877. * Creates a physics updraft event
  50878. * @param origin the origin of the updraft
  50879. * @param radius the radius of the updraft
  50880. * @param strength the strength of the updraft
  50881. * @param height the height of the updraft
  50882. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50883. * @returns A physics updraft event, or null
  50884. */
  50885. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50886. /**
  50887. * Creates a physics vortex event
  50888. * @param origin the of the vortex
  50889. * @param radius the radius of the vortex
  50890. * @param strength the strength of the vortex
  50891. * @param height the height of the vortex
  50892. * @returns a Physics vortex event, or null
  50893. * A physics vortex event or null
  50894. */
  50895. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50896. }
  50897. /**
  50898. * Represents a physics radial explosion event
  50899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50900. */
  50901. export class PhysicsRadialExplosionEvent {
  50902. private _scene;
  50903. private _sphere;
  50904. private _sphereOptions;
  50905. private _rays;
  50906. private _dataFetched;
  50907. /**
  50908. * Initializes a radial explosioin event
  50909. * @param scene BabylonJS scene
  50910. */
  50911. constructor(scene: Scene);
  50912. /**
  50913. * Returns the data related to the radial explosion event (sphere & rays).
  50914. * @returns The radial explosion event data
  50915. */
  50916. getData(): PhysicsRadialExplosionEventData;
  50917. /**
  50918. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50919. * @param impostor A physics imposter
  50920. * @param origin the origin of the explosion
  50921. * @param radius the explosion radius
  50922. * @param strength the explosion strength
  50923. * @param falloff possible options: Constant & Linear
  50924. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50925. */
  50926. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50927. /**
  50928. * Disposes the sphere.
  50929. * @param force Specifies if the sphere should be disposed by force
  50930. */
  50931. dispose(force?: boolean): void;
  50932. /*** Helpers ***/
  50933. private _prepareSphere;
  50934. private _intersectsWithSphere;
  50935. }
  50936. /**
  50937. * Represents a gravitational field event
  50938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50939. */
  50940. export class PhysicsGravitationalFieldEvent {
  50941. private _physicsHelper;
  50942. private _scene;
  50943. private _origin;
  50944. private _radius;
  50945. private _strength;
  50946. private _falloff;
  50947. private _tickCallback;
  50948. private _sphere;
  50949. private _dataFetched;
  50950. /**
  50951. * Initializes the physics gravitational field event
  50952. * @param physicsHelper A physics helper
  50953. * @param scene BabylonJS scene
  50954. * @param origin The origin position of the gravitational field event
  50955. * @param radius The radius of the gravitational field event
  50956. * @param strength The strength of the gravitational field event
  50957. * @param falloff The falloff for the gravitational field event
  50958. */
  50959. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50960. /**
  50961. * Returns the data related to the gravitational field event (sphere).
  50962. * @returns A gravitational field event
  50963. */
  50964. getData(): PhysicsGravitationalFieldEventData;
  50965. /**
  50966. * Enables the gravitational field.
  50967. */
  50968. enable(): void;
  50969. /**
  50970. * Disables the gravitational field.
  50971. */
  50972. disable(): void;
  50973. /**
  50974. * Disposes the sphere.
  50975. * @param force The force to dispose from the gravitational field event
  50976. */
  50977. dispose(force?: boolean): void;
  50978. private _tick;
  50979. }
  50980. /**
  50981. * Represents a physics updraft event
  50982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50983. */
  50984. export class PhysicsUpdraftEvent {
  50985. private _scene;
  50986. private _origin;
  50987. private _radius;
  50988. private _strength;
  50989. private _height;
  50990. private _updraftMode;
  50991. private _physicsEngine;
  50992. private _originTop;
  50993. private _originDirection;
  50994. private _tickCallback;
  50995. private _cylinder;
  50996. private _cylinderPosition;
  50997. private _dataFetched;
  50998. /**
  50999. * Initializes the physics updraft event
  51000. * @param _scene BabylonJS scene
  51001. * @param _origin The origin position of the updraft
  51002. * @param _radius The radius of the updraft
  51003. * @param _strength The strength of the updraft
  51004. * @param _height The height of the updraft
  51005. * @param _updraftMode The mode of the updraft
  51006. */
  51007. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51008. /**
  51009. * Returns the data related to the updraft event (cylinder).
  51010. * @returns A physics updraft event
  51011. */
  51012. getData(): PhysicsUpdraftEventData;
  51013. /**
  51014. * Enables the updraft.
  51015. */
  51016. enable(): void;
  51017. /**
  51018. * Disables the cortex.
  51019. */
  51020. disable(): void;
  51021. /**
  51022. * Disposes the sphere.
  51023. * @param force Specifies if the updraft should be disposed by force
  51024. */
  51025. dispose(force?: boolean): void;
  51026. private getImpostorForceAndContactPoint;
  51027. private _tick;
  51028. /*** Helpers ***/
  51029. private _prepareCylinder;
  51030. private _intersectsWithCylinder;
  51031. }
  51032. /**
  51033. * Represents a physics vortex event
  51034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51035. */
  51036. export class PhysicsVortexEvent {
  51037. private _scene;
  51038. private _origin;
  51039. private _radius;
  51040. private _strength;
  51041. private _height;
  51042. private _physicsEngine;
  51043. private _originTop;
  51044. private _centripetalForceThreshold;
  51045. private _updraftMultiplier;
  51046. private _tickCallback;
  51047. private _cylinder;
  51048. private _cylinderPosition;
  51049. private _dataFetched;
  51050. /**
  51051. * Initializes the physics vortex event
  51052. * @param _scene The BabylonJS scene
  51053. * @param _origin The origin position of the vortex
  51054. * @param _radius The radius of the vortex
  51055. * @param _strength The strength of the vortex
  51056. * @param _height The height of the vortex
  51057. */
  51058. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51059. /**
  51060. * Returns the data related to the vortex event (cylinder).
  51061. * @returns The physics vortex event data
  51062. */
  51063. getData(): PhysicsVortexEventData;
  51064. /**
  51065. * Enables the vortex.
  51066. */
  51067. enable(): void;
  51068. /**
  51069. * Disables the cortex.
  51070. */
  51071. disable(): void;
  51072. /**
  51073. * Disposes the sphere.
  51074. * @param force
  51075. */
  51076. dispose(force?: boolean): void;
  51077. private getImpostorForceAndContactPoint;
  51078. private _tick;
  51079. /*** Helpers ***/
  51080. private _prepareCylinder;
  51081. private _intersectsWithCylinder;
  51082. }
  51083. /**
  51084. * The strenght of the force in correspondence to the distance of the affected object
  51085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51086. */
  51087. export enum PhysicsRadialImpulseFalloff {
  51088. /** Defines that impulse is constant in strength across it's whole radius */
  51089. Constant = 0,
  51090. /** DEfines that impulse gets weaker if it's further from the origin */
  51091. Linear = 1
  51092. }
  51093. /**
  51094. * The strength of the force in correspondence to the distance of the affected object
  51095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51096. */
  51097. export enum PhysicsUpdraftMode {
  51098. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51099. Center = 0,
  51100. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51101. Perpendicular = 1
  51102. }
  51103. /**
  51104. * Interface for a physics force and contact point
  51105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51106. */
  51107. export interface PhysicsForceAndContactPoint {
  51108. /**
  51109. * The force applied at the contact point
  51110. */
  51111. force: Vector3;
  51112. /**
  51113. * The contact point
  51114. */
  51115. contactPoint: Vector3;
  51116. }
  51117. /**
  51118. * Interface for radial explosion event data
  51119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51120. */
  51121. export interface PhysicsRadialExplosionEventData {
  51122. /**
  51123. * A sphere used for the radial explosion event
  51124. */
  51125. sphere: Mesh;
  51126. /**
  51127. * An array of rays for the radial explosion event
  51128. */
  51129. rays: Array<Ray>;
  51130. }
  51131. /**
  51132. * Interface for gravitational field event data
  51133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51134. */
  51135. export interface PhysicsGravitationalFieldEventData {
  51136. /**
  51137. * A sphere mesh used for the gravitational field event
  51138. */
  51139. sphere: Mesh;
  51140. }
  51141. /**
  51142. * Interface for updraft event data
  51143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51144. */
  51145. export interface PhysicsUpdraftEventData {
  51146. /**
  51147. * A cylinder used for the updraft event
  51148. */
  51149. cylinder: Mesh;
  51150. }
  51151. /**
  51152. * Interface for vortex event data
  51153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51154. */
  51155. export interface PhysicsVortexEventData {
  51156. /**
  51157. * A cylinder used for the vortex event
  51158. */
  51159. cylinder: Mesh;
  51160. }
  51161. }
  51162. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51163. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51164. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51165. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51166. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51167. import { Nullable } from "babylonjs/types";
  51168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51169. /**
  51170. * AmmoJS Physics plugin
  51171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51172. * @see https://github.com/kripken/ammo.js/
  51173. */
  51174. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51175. private _useDeltaForWorldStep;
  51176. /**
  51177. * Reference to the Ammo library
  51178. */
  51179. bjsAMMO: any;
  51180. /**
  51181. * Created ammoJS world which physics bodies are added to
  51182. */
  51183. world: any;
  51184. /**
  51185. * Name of the plugin
  51186. */
  51187. name: string;
  51188. private _timeStep;
  51189. private _fixedTimeStep;
  51190. private _maxSteps;
  51191. private _tmpQuaternion;
  51192. private _tmpAmmoTransform;
  51193. private _tmpAmmoQuaternion;
  51194. private _tmpAmmoConcreteContactResultCallback;
  51195. private _collisionConfiguration;
  51196. private _dispatcher;
  51197. private _overlappingPairCache;
  51198. private _solver;
  51199. private _tmpAmmoVectorA;
  51200. private _tmpAmmoVectorB;
  51201. private _tmpAmmoVectorC;
  51202. private _tmpContactCallbackResult;
  51203. private static readonly DISABLE_COLLISION_FLAG;
  51204. private static readonly KINEMATIC_FLAG;
  51205. private static readonly DISABLE_DEACTIVATION_FLAG;
  51206. /**
  51207. * Initializes the ammoJS plugin
  51208. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51209. * @param ammoInjection can be used to inject your own ammo reference
  51210. */
  51211. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51212. /**
  51213. * Sets the gravity of the physics world (m/(s^2))
  51214. * @param gravity Gravity to set
  51215. */
  51216. setGravity(gravity: Vector3): void;
  51217. /**
  51218. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51219. * @param timeStep timestep to use in seconds
  51220. */
  51221. setTimeStep(timeStep: number): void;
  51222. /**
  51223. * 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)
  51224. * @param fixedTimeStep fixedTimeStep to use in seconds
  51225. */
  51226. setFixedTimeStep(fixedTimeStep: number): void;
  51227. /**
  51228. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51229. * @param maxSteps the maximum number of steps by the physics engine per frame
  51230. */
  51231. setMaxSteps(maxSteps: number): void;
  51232. /**
  51233. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51234. * @returns the current timestep in seconds
  51235. */
  51236. getTimeStep(): number;
  51237. private _isImpostorInContact;
  51238. private _isImpostorPairInContact;
  51239. private _stepSimulation;
  51240. /**
  51241. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51242. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51243. * After the step the babylon meshes are set to the position of the physics imposters
  51244. * @param delta amount of time to step forward
  51245. * @param impostors array of imposters to update before/after the step
  51246. */
  51247. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51248. private _tmpVector;
  51249. private _tmpMatrix;
  51250. /**
  51251. * Applies an implulse on the imposter
  51252. * @param impostor imposter to apply impulse
  51253. * @param force amount of force to be applied to the imposter
  51254. * @param contactPoint the location to apply the impulse on the imposter
  51255. */
  51256. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51257. /**
  51258. * Applies a force on the imposter
  51259. * @param impostor imposter to apply force
  51260. * @param force amount of force to be applied to the imposter
  51261. * @param contactPoint the location to apply the force on the imposter
  51262. */
  51263. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51264. /**
  51265. * Creates a physics body using the plugin
  51266. * @param impostor the imposter to create the physics body on
  51267. */
  51268. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51269. /**
  51270. * Removes the physics body from the imposter and disposes of the body's memory
  51271. * @param impostor imposter to remove the physics body from
  51272. */
  51273. removePhysicsBody(impostor: PhysicsImpostor): void;
  51274. /**
  51275. * Generates a joint
  51276. * @param impostorJoint the imposter joint to create the joint with
  51277. */
  51278. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51279. /**
  51280. * Removes a joint
  51281. * @param impostorJoint the imposter joint to remove the joint from
  51282. */
  51283. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51284. private _addMeshVerts;
  51285. private _createShape;
  51286. /**
  51287. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51288. * @param impostor imposter containing the physics body and babylon object
  51289. */
  51290. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51291. /**
  51292. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51293. * @param impostor imposter containing the physics body and babylon object
  51294. * @param newPosition new position
  51295. * @param newRotation new rotation
  51296. */
  51297. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51298. /**
  51299. * If this plugin is supported
  51300. * @returns true if its supported
  51301. */
  51302. isSupported(): boolean;
  51303. /**
  51304. * Sets the linear velocity of the physics body
  51305. * @param impostor imposter to set the velocity on
  51306. * @param velocity velocity to set
  51307. */
  51308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51309. /**
  51310. * Sets the angular velocity of the physics body
  51311. * @param impostor imposter to set the velocity on
  51312. * @param velocity velocity to set
  51313. */
  51314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51315. /**
  51316. * gets the linear velocity
  51317. * @param impostor imposter to get linear velocity from
  51318. * @returns linear velocity
  51319. */
  51320. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51321. /**
  51322. * gets the angular velocity
  51323. * @param impostor imposter to get angular velocity from
  51324. * @returns angular velocity
  51325. */
  51326. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51327. /**
  51328. * Sets the mass of physics body
  51329. * @param impostor imposter to set the mass on
  51330. * @param mass mass to set
  51331. */
  51332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51333. /**
  51334. * Gets the mass of the physics body
  51335. * @param impostor imposter to get the mass from
  51336. * @returns mass
  51337. */
  51338. getBodyMass(impostor: PhysicsImpostor): number;
  51339. /**
  51340. * Gets friction of the impostor
  51341. * @param impostor impostor to get friction from
  51342. * @returns friction value
  51343. */
  51344. getBodyFriction(impostor: PhysicsImpostor): number;
  51345. /**
  51346. * Sets friction of the impostor
  51347. * @param impostor impostor to set friction on
  51348. * @param friction friction value
  51349. */
  51350. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51351. /**
  51352. * Gets restitution of the impostor
  51353. * @param impostor impostor to get restitution from
  51354. * @returns restitution value
  51355. */
  51356. getBodyRestitution(impostor: PhysicsImpostor): number;
  51357. /**
  51358. * Sets resitution of the impostor
  51359. * @param impostor impostor to set resitution on
  51360. * @param restitution resitution value
  51361. */
  51362. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51363. /**
  51364. * Sleeps the physics body and stops it from being active
  51365. * @param impostor impostor to sleep
  51366. */
  51367. sleepBody(impostor: PhysicsImpostor): void;
  51368. /**
  51369. * Activates the physics body
  51370. * @param impostor impostor to activate
  51371. */
  51372. wakeUpBody(impostor: PhysicsImpostor): void;
  51373. /**
  51374. * Updates the distance parameters of the joint
  51375. * @param joint joint to update
  51376. * @param maxDistance maximum distance of the joint
  51377. * @param minDistance minimum distance of the joint
  51378. */
  51379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51380. /**
  51381. * Sets a motor on the joint
  51382. * @param joint joint to set motor on
  51383. * @param speed speed of the motor
  51384. * @param maxForce maximum force of the motor
  51385. * @param motorIndex index of the motor
  51386. */
  51387. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51388. /**
  51389. * Sets the motors limit
  51390. * @param joint joint to set limit on
  51391. * @param upperLimit upper limit
  51392. * @param lowerLimit lower limit
  51393. */
  51394. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51395. /**
  51396. * Syncs the position and rotation of a mesh with the impostor
  51397. * @param mesh mesh to sync
  51398. * @param impostor impostor to update the mesh with
  51399. */
  51400. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51401. /**
  51402. * Gets the radius of the impostor
  51403. * @param impostor impostor to get radius from
  51404. * @returns the radius
  51405. */
  51406. getRadius(impostor: PhysicsImpostor): number;
  51407. /**
  51408. * Gets the box size of the impostor
  51409. * @param impostor impostor to get box size from
  51410. * @param result the resulting box size
  51411. */
  51412. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51413. /**
  51414. * Disposes of the impostor
  51415. */
  51416. dispose(): void;
  51417. }
  51418. }
  51419. declare module "babylonjs/Physics/Plugins/index" {
  51420. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51421. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51422. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51423. }
  51424. declare module "babylonjs/Physics/index" {
  51425. export * from "babylonjs/Physics/IPhysicsEngine";
  51426. export * from "babylonjs/Physics/physicsEngine";
  51427. export * from "babylonjs/Physics/physicsEngineComponent";
  51428. export * from "babylonjs/Physics/physicsHelper";
  51429. export * from "babylonjs/Physics/physicsImpostor";
  51430. export * from "babylonjs/Physics/physicsJoint";
  51431. export * from "babylonjs/Physics/Plugins/index";
  51432. }
  51433. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51434. /** @hidden */
  51435. export var blackAndWhitePixelShader: {
  51436. name: string;
  51437. shader: string;
  51438. };
  51439. }
  51440. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51441. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51442. import { Camera } from "babylonjs/Cameras/camera";
  51443. import { Engine } from "babylonjs/Engines/engine";
  51444. import "babylonjs/Shaders/blackAndWhite.fragment";
  51445. /**
  51446. * Post process used to render in black and white
  51447. */
  51448. export class BlackAndWhitePostProcess extends PostProcess {
  51449. /**
  51450. * Linear about to convert he result to black and white (default: 1)
  51451. */
  51452. degree: number;
  51453. /**
  51454. * Creates a black and white post process
  51455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51456. * @param name The name of the effect.
  51457. * @param options The required width/height ratio to downsize to before computing the render pass.
  51458. * @param camera The camera to apply the render pass to.
  51459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51460. * @param engine The engine which the post process will be applied. (default: current engine)
  51461. * @param reusable If the post process can be reused on the same frame. (default: false)
  51462. */
  51463. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51464. }
  51465. }
  51466. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51467. import { Nullable } from "babylonjs/types";
  51468. import { Camera } from "babylonjs/Cameras/camera";
  51469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51470. import { Engine } from "babylonjs/Engines/engine";
  51471. /**
  51472. * This represents a set of one or more post processes in Babylon.
  51473. * A post process can be used to apply a shader to a texture after it is rendered.
  51474. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51475. */
  51476. export class PostProcessRenderEffect {
  51477. private _postProcesses;
  51478. private _getPostProcesses;
  51479. private _singleInstance;
  51480. private _cameras;
  51481. private _indicesForCamera;
  51482. /**
  51483. * Name of the effect
  51484. * @hidden
  51485. */
  51486. _name: string;
  51487. /**
  51488. * Instantiates a post process render effect.
  51489. * A post process can be used to apply a shader to a texture after it is rendered.
  51490. * @param engine The engine the effect is tied to
  51491. * @param name The name of the effect
  51492. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51493. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51494. */
  51495. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51496. /**
  51497. * Checks if all the post processes in the effect are supported.
  51498. */
  51499. readonly isSupported: boolean;
  51500. /**
  51501. * Updates the current state of the effect
  51502. * @hidden
  51503. */
  51504. _update(): void;
  51505. /**
  51506. * Attaches the effect on cameras
  51507. * @param cameras The camera to attach to.
  51508. * @hidden
  51509. */
  51510. _attachCameras(cameras: Camera): void;
  51511. /**
  51512. * Attaches the effect on cameras
  51513. * @param cameras The camera to attach to.
  51514. * @hidden
  51515. */
  51516. _attachCameras(cameras: Camera[]): void;
  51517. /**
  51518. * Detatches the effect on cameras
  51519. * @param cameras The camera to detatch from.
  51520. * @hidden
  51521. */
  51522. _detachCameras(cameras: Camera): void;
  51523. /**
  51524. * Detatches the effect on cameras
  51525. * @param cameras The camera to detatch from.
  51526. * @hidden
  51527. */
  51528. _detachCameras(cameras: Camera[]): void;
  51529. /**
  51530. * Enables the effect on given cameras
  51531. * @param cameras The camera to enable.
  51532. * @hidden
  51533. */
  51534. _enable(cameras: Camera): void;
  51535. /**
  51536. * Enables the effect on given cameras
  51537. * @param cameras The camera to enable.
  51538. * @hidden
  51539. */
  51540. _enable(cameras: Nullable<Camera[]>): void;
  51541. /**
  51542. * Disables the effect on the given cameras
  51543. * @param cameras The camera to disable.
  51544. * @hidden
  51545. */
  51546. _disable(cameras: Camera): void;
  51547. /**
  51548. * Disables the effect on the given cameras
  51549. * @param cameras The camera to disable.
  51550. * @hidden
  51551. */
  51552. _disable(cameras: Nullable<Camera[]>): void;
  51553. /**
  51554. * Gets a list of the post processes contained in the effect.
  51555. * @param camera The camera to get the post processes on.
  51556. * @returns The list of the post processes in the effect.
  51557. */
  51558. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51559. }
  51560. }
  51561. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51563. /** @hidden */
  51564. export var extractHighlightsPixelShader: {
  51565. name: string;
  51566. shader: string;
  51567. };
  51568. }
  51569. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51570. import { Nullable } from "babylonjs/types";
  51571. import { Camera } from "babylonjs/Cameras/camera";
  51572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51573. import { Engine } from "babylonjs/Engines/engine";
  51574. import "babylonjs/Shaders/extractHighlights.fragment";
  51575. /**
  51576. * 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.
  51577. */
  51578. export class ExtractHighlightsPostProcess extends PostProcess {
  51579. /**
  51580. * The luminance threshold, pixels below this value will be set to black.
  51581. */
  51582. threshold: number;
  51583. /** @hidden */
  51584. _exposure: number;
  51585. /**
  51586. * Post process which has the input texture to be used when performing highlight extraction
  51587. * @hidden
  51588. */
  51589. _inputPostProcess: Nullable<PostProcess>;
  51590. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51591. }
  51592. }
  51593. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51594. /** @hidden */
  51595. export var bloomMergePixelShader: {
  51596. name: string;
  51597. shader: string;
  51598. };
  51599. }
  51600. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51601. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51602. import { Nullable } from "babylonjs/types";
  51603. import { Engine } from "babylonjs/Engines/engine";
  51604. import { Camera } from "babylonjs/Cameras/camera";
  51605. import "babylonjs/Shaders/bloomMerge.fragment";
  51606. /**
  51607. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51608. */
  51609. export class BloomMergePostProcess extends PostProcess {
  51610. /** Weight of the bloom to be added to the original input. */
  51611. weight: number;
  51612. /**
  51613. * Creates a new instance of @see BloomMergePostProcess
  51614. * @param name The name of the effect.
  51615. * @param originalFromInput Post process which's input will be used for the merge.
  51616. * @param blurred Blurred highlights post process which's output will be used.
  51617. * @param weight Weight of the bloom to be added to the original input.
  51618. * @param options The required width/height ratio to downsize to before computing the render pass.
  51619. * @param camera The camera to apply the render pass to.
  51620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51621. * @param engine The engine which the post process will be applied. (default: current engine)
  51622. * @param reusable If the post process can be reused on the same frame. (default: false)
  51623. * @param textureType Type of textures used when performing the post process. (default: 0)
  51624. * @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)
  51625. */
  51626. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51627. /** Weight of the bloom to be added to the original input. */
  51628. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51629. }
  51630. }
  51631. declare module "babylonjs/PostProcesses/bloomEffect" {
  51632. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51633. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51634. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51635. import { Camera } from "babylonjs/Cameras/camera";
  51636. import { Scene } from "babylonjs/scene";
  51637. /**
  51638. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51639. */
  51640. export class BloomEffect extends PostProcessRenderEffect {
  51641. private bloomScale;
  51642. /**
  51643. * @hidden Internal
  51644. */
  51645. _effects: Array<PostProcess>;
  51646. /**
  51647. * @hidden Internal
  51648. */
  51649. _downscale: ExtractHighlightsPostProcess;
  51650. private _blurX;
  51651. private _blurY;
  51652. private _merge;
  51653. /**
  51654. * The luminance threshold to find bright areas of the image to bloom.
  51655. */
  51656. threshold: number;
  51657. /**
  51658. * The strength of the bloom.
  51659. */
  51660. weight: number;
  51661. /**
  51662. * Specifies the size of the bloom blur kernel, relative to the final output size
  51663. */
  51664. kernel: number;
  51665. /**
  51666. * Creates a new instance of @see BloomEffect
  51667. * @param scene The scene the effect belongs to.
  51668. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51669. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51670. * @param bloomWeight The the strength of bloom.
  51671. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51672. * @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)
  51673. */
  51674. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51675. /**
  51676. * Disposes each of the internal effects for a given camera.
  51677. * @param camera The camera to dispose the effect on.
  51678. */
  51679. disposeEffects(camera: Camera): void;
  51680. /**
  51681. * @hidden Internal
  51682. */
  51683. _updateEffects(): void;
  51684. /**
  51685. * Internal
  51686. * @returns if all the contained post processes are ready.
  51687. * @hidden
  51688. */
  51689. _isReady(): boolean;
  51690. }
  51691. }
  51692. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51693. /** @hidden */
  51694. export var chromaticAberrationPixelShader: {
  51695. name: string;
  51696. shader: string;
  51697. };
  51698. }
  51699. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51700. import { Vector2 } from "babylonjs/Maths/math";
  51701. import { Nullable } from "babylonjs/types";
  51702. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51703. import { Camera } from "babylonjs/Cameras/camera";
  51704. import { Engine } from "babylonjs/Engines/engine";
  51705. import "babylonjs/Shaders/chromaticAberration.fragment";
  51706. /**
  51707. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51708. */
  51709. export class ChromaticAberrationPostProcess extends PostProcess {
  51710. /**
  51711. * The amount of seperation of rgb channels (default: 30)
  51712. */
  51713. aberrationAmount: number;
  51714. /**
  51715. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51716. */
  51717. radialIntensity: number;
  51718. /**
  51719. * 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))
  51720. */
  51721. direction: Vector2;
  51722. /**
  51723. * 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))
  51724. */
  51725. centerPosition: Vector2;
  51726. /**
  51727. * Creates a new instance ChromaticAberrationPostProcess
  51728. * @param name The name of the effect.
  51729. * @param screenWidth The width of the screen to apply the effect on.
  51730. * @param screenHeight The height of the screen to apply the effect on.
  51731. * @param options The required width/height ratio to downsize to before computing the render pass.
  51732. * @param camera The camera to apply the render pass to.
  51733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51734. * @param engine The engine which the post process will be applied. (default: current engine)
  51735. * @param reusable If the post process can be reused on the same frame. (default: false)
  51736. * @param textureType Type of textures used when performing the post process. (default: 0)
  51737. * @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)
  51738. */
  51739. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51740. }
  51741. }
  51742. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51743. /** @hidden */
  51744. export var circleOfConfusionPixelShader: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51750. import { Nullable } from "babylonjs/types";
  51751. import { Engine } from "babylonjs/Engines/engine";
  51752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51754. import { Camera } from "babylonjs/Cameras/camera";
  51755. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51756. /**
  51757. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51758. */
  51759. export class CircleOfConfusionPostProcess extends PostProcess {
  51760. /**
  51761. * 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.
  51762. */
  51763. lensSize: number;
  51764. /**
  51765. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51766. */
  51767. fStop: number;
  51768. /**
  51769. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51770. */
  51771. focusDistance: number;
  51772. /**
  51773. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51774. */
  51775. focalLength: number;
  51776. private _depthTexture;
  51777. /**
  51778. * Creates a new instance CircleOfConfusionPostProcess
  51779. * @param name The name of the effect.
  51780. * @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.
  51781. * @param options The required width/height ratio to downsize to before computing the render pass.
  51782. * @param camera The camera to apply the render pass to.
  51783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51784. * @param engine The engine which the post process will be applied. (default: current engine)
  51785. * @param reusable If the post process can be reused on the same frame. (default: false)
  51786. * @param textureType Type of textures used when performing the post process. (default: 0)
  51787. * @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)
  51788. */
  51789. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51790. /**
  51791. * 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.
  51792. */
  51793. depthTexture: RenderTargetTexture;
  51794. }
  51795. }
  51796. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51797. /** @hidden */
  51798. export var colorCorrectionPixelShader: {
  51799. name: string;
  51800. shader: string;
  51801. };
  51802. }
  51803. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51805. import { Engine } from "babylonjs/Engines/engine";
  51806. import { Camera } from "babylonjs/Cameras/camera";
  51807. import "babylonjs/Shaders/colorCorrection.fragment";
  51808. /**
  51809. *
  51810. * This post-process allows the modification of rendered colors by using
  51811. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51812. *
  51813. * The object needs to be provided an url to a texture containing the color
  51814. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51815. * Use an image editing software to tweak the LUT to match your needs.
  51816. *
  51817. * For an example of a color LUT, see here:
  51818. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51819. * For explanations on color grading, see here:
  51820. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51821. *
  51822. */
  51823. export class ColorCorrectionPostProcess extends PostProcess {
  51824. private _colorTableTexture;
  51825. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51826. }
  51827. }
  51828. declare module "babylonjs/Shaders/convolution.fragment" {
  51829. /** @hidden */
  51830. export var convolutionPixelShader: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51837. import { Nullable } from "babylonjs/types";
  51838. import { Camera } from "babylonjs/Cameras/camera";
  51839. import { Engine } from "babylonjs/Engines/engine";
  51840. import "babylonjs/Shaders/convolution.fragment";
  51841. /**
  51842. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51843. * input texture to perform effects such as edge detection or sharpening
  51844. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51845. */
  51846. export class ConvolutionPostProcess extends PostProcess {
  51847. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51848. kernel: number[];
  51849. /**
  51850. * Creates a new instance ConvolutionPostProcess
  51851. * @param name The name of the effect.
  51852. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51853. * @param options The required width/height ratio to downsize to before computing the render pass.
  51854. * @param camera The camera to apply the render pass to.
  51855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51856. * @param engine The engine which the post process will be applied. (default: current engine)
  51857. * @param reusable If the post process can be reused on the same frame. (default: false)
  51858. * @param textureType Type of textures used when performing the post process. (default: 0)
  51859. */
  51860. constructor(name: string,
  51861. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51862. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51863. /**
  51864. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51865. */
  51866. static EdgeDetect0Kernel: number[];
  51867. /**
  51868. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51869. */
  51870. static EdgeDetect1Kernel: number[];
  51871. /**
  51872. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51873. */
  51874. static EdgeDetect2Kernel: number[];
  51875. /**
  51876. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51877. */
  51878. static SharpenKernel: number[];
  51879. /**
  51880. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51881. */
  51882. static EmbossKernel: number[];
  51883. /**
  51884. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51885. */
  51886. static GaussianKernel: number[];
  51887. }
  51888. }
  51889. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51890. import { Nullable } from "babylonjs/types";
  51891. import { Vector2 } from "babylonjs/Maths/math";
  51892. import { Camera } from "babylonjs/Cameras/camera";
  51893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51894. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51895. import { Engine } from "babylonjs/Engines/engine";
  51896. import { Scene } from "babylonjs/scene";
  51897. /**
  51898. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51899. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51900. * based on samples that have a large difference in distance than the center pixel.
  51901. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51902. */
  51903. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51904. direction: Vector2;
  51905. /**
  51906. * Creates a new instance CircleOfConfusionPostProcess
  51907. * @param name The name of the effect.
  51908. * @param scene The scene the effect belongs to.
  51909. * @param direction The direction the blur should be applied.
  51910. * @param kernel The size of the kernel used to blur.
  51911. * @param options The required width/height ratio to downsize to before computing the render pass.
  51912. * @param camera The camera to apply the render pass to.
  51913. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51914. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51916. * @param engine The engine which the post process will be applied. (default: current engine)
  51917. * @param reusable If the post process can be reused on the same frame. (default: false)
  51918. * @param textureType Type of textures used when performing the post process. (default: 0)
  51919. * @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)
  51920. */
  51921. 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);
  51922. }
  51923. }
  51924. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51925. /** @hidden */
  51926. export var depthOfFieldMergePixelShader: {
  51927. name: string;
  51928. shader: string;
  51929. };
  51930. }
  51931. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51932. import { Nullable } from "babylonjs/types";
  51933. import { Camera } from "babylonjs/Cameras/camera";
  51934. import { Effect } from "babylonjs/Materials/effect";
  51935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51936. import { Engine } from "babylonjs/Engines/engine";
  51937. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51938. /**
  51939. * Options to be set when merging outputs from the default pipeline.
  51940. */
  51941. export class DepthOfFieldMergePostProcessOptions {
  51942. /**
  51943. * The original image to merge on top of
  51944. */
  51945. originalFromInput: PostProcess;
  51946. /**
  51947. * Parameters to perform the merge of the depth of field effect
  51948. */
  51949. depthOfField?: {
  51950. circleOfConfusion: PostProcess;
  51951. blurSteps: Array<PostProcess>;
  51952. };
  51953. /**
  51954. * Parameters to perform the merge of bloom effect
  51955. */
  51956. bloom?: {
  51957. blurred: PostProcess;
  51958. weight: number;
  51959. };
  51960. }
  51961. /**
  51962. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51963. */
  51964. export class DepthOfFieldMergePostProcess extends PostProcess {
  51965. private blurSteps;
  51966. /**
  51967. * Creates a new instance of DepthOfFieldMergePostProcess
  51968. * @param name The name of the effect.
  51969. * @param originalFromInput Post process which's input will be used for the merge.
  51970. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51971. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51972. * @param options The required width/height ratio to downsize to before computing the render pass.
  51973. * @param camera The camera to apply the render pass to.
  51974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51975. * @param engine The engine which the post process will be applied. (default: current engine)
  51976. * @param reusable If the post process can be reused on the same frame. (default: false)
  51977. * @param textureType Type of textures used when performing the post process. (default: 0)
  51978. * @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)
  51979. */
  51980. 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);
  51981. /**
  51982. * Updates the effect with the current post process compile time values and recompiles the shader.
  51983. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51984. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51985. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51986. * @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
  51987. * @param onCompiled Called when the shader has been compiled.
  51988. * @param onError Called if there is an error when compiling a shader.
  51989. */
  51990. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51991. }
  51992. }
  51993. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51994. import { Nullable } from "babylonjs/types";
  51995. import { Camera } from "babylonjs/Cameras/camera";
  51996. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51997. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51998. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51999. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52000. import { Scene } from "babylonjs/scene";
  52001. /**
  52002. * Specifies the level of max blur that should be applied when using the depth of field effect
  52003. */
  52004. export enum DepthOfFieldEffectBlurLevel {
  52005. /**
  52006. * Subtle blur
  52007. */
  52008. Low = 0,
  52009. /**
  52010. * Medium blur
  52011. */
  52012. Medium = 1,
  52013. /**
  52014. * Large blur
  52015. */
  52016. High = 2
  52017. }
  52018. /**
  52019. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52020. */
  52021. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52022. private _circleOfConfusion;
  52023. /**
  52024. * @hidden Internal, blurs from high to low
  52025. */
  52026. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52027. private _depthOfFieldBlurY;
  52028. private _dofMerge;
  52029. /**
  52030. * @hidden Internal post processes in depth of field effect
  52031. */
  52032. _effects: Array<PostProcess>;
  52033. /**
  52034. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52035. */
  52036. focalLength: number;
  52037. /**
  52038. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52039. */
  52040. fStop: number;
  52041. /**
  52042. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52043. */
  52044. focusDistance: number;
  52045. /**
  52046. * 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.
  52047. */
  52048. lensSize: number;
  52049. /**
  52050. * Creates a new instance DepthOfFieldEffect
  52051. * @param scene The scene the effect belongs to.
  52052. * @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.
  52053. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52054. * @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)
  52055. */
  52056. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52057. /**
  52058. * 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.
  52059. */
  52060. depthTexture: RenderTargetTexture;
  52061. /**
  52062. * Disposes each of the internal effects for a given camera.
  52063. * @param camera The camera to dispose the effect on.
  52064. */
  52065. disposeEffects(camera: Camera): void;
  52066. /**
  52067. * @hidden Internal
  52068. */
  52069. _updateEffects(): void;
  52070. /**
  52071. * Internal
  52072. * @returns if all the contained post processes are ready.
  52073. * @hidden
  52074. */
  52075. _isReady(): boolean;
  52076. }
  52077. }
  52078. declare module "babylonjs/Shaders/displayPass.fragment" {
  52079. /** @hidden */
  52080. export var displayPassPixelShader: {
  52081. name: string;
  52082. shader: string;
  52083. };
  52084. }
  52085. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52086. import { Nullable } from "babylonjs/types";
  52087. import { Camera } from "babylonjs/Cameras/camera";
  52088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52089. import { Engine } from "babylonjs/Engines/engine";
  52090. import "babylonjs/Shaders/displayPass.fragment";
  52091. /**
  52092. * DisplayPassPostProcess which produces an output the same as it's input
  52093. */
  52094. export class DisplayPassPostProcess extends PostProcess {
  52095. /**
  52096. * Creates the DisplayPassPostProcess
  52097. * @param name The name of the effect.
  52098. * @param options The required width/height ratio to downsize to before computing the render pass.
  52099. * @param camera The camera to apply the render pass to.
  52100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52101. * @param engine The engine which the post process will be applied. (default: current engine)
  52102. * @param reusable If the post process can be reused on the same frame. (default: false)
  52103. */
  52104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52105. }
  52106. }
  52107. declare module "babylonjs/Shaders/filter.fragment" {
  52108. /** @hidden */
  52109. export var filterPixelShader: {
  52110. name: string;
  52111. shader: string;
  52112. };
  52113. }
  52114. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52115. import { Nullable } from "babylonjs/types";
  52116. import { Matrix } from "babylonjs/Maths/math";
  52117. import { Camera } from "babylonjs/Cameras/camera";
  52118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52119. import { Engine } from "babylonjs/Engines/engine";
  52120. import "babylonjs/Shaders/filter.fragment";
  52121. /**
  52122. * Applies a kernel filter to the image
  52123. */
  52124. export class FilterPostProcess extends PostProcess {
  52125. /** The matrix to be applied to the image */
  52126. kernelMatrix: Matrix;
  52127. /**
  52128. *
  52129. * @param name The name of the effect.
  52130. * @param kernelMatrix The matrix to be applied to the image
  52131. * @param options The required width/height ratio to downsize to before computing the render pass.
  52132. * @param camera The camera to apply the render pass to.
  52133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52134. * @param engine The engine which the post process will be applied. (default: current engine)
  52135. * @param reusable If the post process can be reused on the same frame. (default: false)
  52136. */
  52137. constructor(name: string,
  52138. /** The matrix to be applied to the image */
  52139. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52140. }
  52141. }
  52142. declare module "babylonjs/Shaders/fxaa.fragment" {
  52143. /** @hidden */
  52144. export var fxaaPixelShader: {
  52145. name: string;
  52146. shader: string;
  52147. };
  52148. }
  52149. declare module "babylonjs/Shaders/fxaa.vertex" {
  52150. /** @hidden */
  52151. export var fxaaVertexShader: {
  52152. name: string;
  52153. shader: string;
  52154. };
  52155. }
  52156. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52157. import { Nullable } from "babylonjs/types";
  52158. import { Camera } from "babylonjs/Cameras/camera";
  52159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52160. import { Engine } from "babylonjs/Engines/engine";
  52161. import "babylonjs/Shaders/fxaa.fragment";
  52162. import "babylonjs/Shaders/fxaa.vertex";
  52163. /**
  52164. * Fxaa post process
  52165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52166. */
  52167. export class FxaaPostProcess extends PostProcess {
  52168. /** @hidden */
  52169. texelWidth: number;
  52170. /** @hidden */
  52171. texelHeight: number;
  52172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52173. private _getDefines;
  52174. }
  52175. }
  52176. declare module "babylonjs/Shaders/grain.fragment" {
  52177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52178. /** @hidden */
  52179. export var grainPixelShader: {
  52180. name: string;
  52181. shader: string;
  52182. };
  52183. }
  52184. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52185. import { Nullable } from "babylonjs/types";
  52186. import { Camera } from "babylonjs/Cameras/camera";
  52187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52188. import { Engine } from "babylonjs/Engines/engine";
  52189. import "babylonjs/Shaders/grain.fragment";
  52190. /**
  52191. * The GrainPostProcess adds noise to the image at mid luminance levels
  52192. */
  52193. export class GrainPostProcess extends PostProcess {
  52194. /**
  52195. * The intensity of the grain added (default: 30)
  52196. */
  52197. intensity: number;
  52198. /**
  52199. * If the grain should be randomized on every frame
  52200. */
  52201. animated: boolean;
  52202. /**
  52203. * Creates a new instance of @see GrainPostProcess
  52204. * @param name The name of the effect.
  52205. * @param options The required width/height ratio to downsize to before computing the render pass.
  52206. * @param camera The camera to apply the render pass to.
  52207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52208. * @param engine The engine which the post process will be applied. (default: current engine)
  52209. * @param reusable If the post process can be reused on the same frame. (default: false)
  52210. * @param textureType Type of textures used when performing the post process. (default: 0)
  52211. * @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)
  52212. */
  52213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52214. }
  52215. }
  52216. declare module "babylonjs/Shaders/highlights.fragment" {
  52217. /** @hidden */
  52218. export var highlightsPixelShader: {
  52219. name: string;
  52220. shader: string;
  52221. };
  52222. }
  52223. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52224. import { Nullable } from "babylonjs/types";
  52225. import { Camera } from "babylonjs/Cameras/camera";
  52226. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52227. import { Engine } from "babylonjs/Engines/engine";
  52228. import "babylonjs/Shaders/highlights.fragment";
  52229. /**
  52230. * Extracts highlights from the image
  52231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52232. */
  52233. export class HighlightsPostProcess extends PostProcess {
  52234. /**
  52235. * Extracts highlights from the image
  52236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52237. * @param name The name of the effect.
  52238. * @param options The required width/height ratio to downsize to before computing the render pass.
  52239. * @param camera The camera to apply the render pass to.
  52240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52241. * @param engine The engine which the post process will be applied. (default: current engine)
  52242. * @param reusable If the post process can be reused on the same frame. (default: false)
  52243. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52244. */
  52245. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52246. }
  52247. }
  52248. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52249. /** @hidden */
  52250. export var mrtFragmentDeclaration: {
  52251. name: string;
  52252. shader: string;
  52253. };
  52254. }
  52255. declare module "babylonjs/Shaders/geometry.fragment" {
  52256. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52257. /** @hidden */
  52258. export var geometryPixelShader: {
  52259. name: string;
  52260. shader: string;
  52261. };
  52262. }
  52263. declare module "babylonjs/Shaders/geometry.vertex" {
  52264. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52265. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52268. /** @hidden */
  52269. export var geometryVertexShader: {
  52270. name: string;
  52271. shader: string;
  52272. };
  52273. }
  52274. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52275. import { Matrix } from "babylonjs/Maths/math";
  52276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52277. import { Mesh } from "babylonjs/Meshes/mesh";
  52278. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52279. import { Effect } from "babylonjs/Materials/effect";
  52280. import { Scene } from "babylonjs/scene";
  52281. import "babylonjs/Shaders/geometry.fragment";
  52282. import "babylonjs/Shaders/geometry.vertex";
  52283. /**
  52284. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52285. */
  52286. export class GeometryBufferRenderer {
  52287. /**
  52288. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52289. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52290. */
  52291. static readonly POSITION_TEXTURE_TYPE: number;
  52292. /**
  52293. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52294. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52295. */
  52296. static readonly VELOCITY_TEXTURE_TYPE: number;
  52297. /**
  52298. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52299. * in order to compute objects velocities when enableVelocity is set to "true"
  52300. * @hidden
  52301. */
  52302. _previousTransformationMatrices: {
  52303. [index: number]: Matrix;
  52304. };
  52305. private _scene;
  52306. private _multiRenderTarget;
  52307. private _ratio;
  52308. private _enablePosition;
  52309. private _enableVelocity;
  52310. private _positionIndex;
  52311. private _velocityIndex;
  52312. protected _effect: Effect;
  52313. protected _cachedDefines: string;
  52314. /**
  52315. * Set the render list (meshes to be rendered) used in the G buffer.
  52316. */
  52317. renderList: Mesh[];
  52318. /**
  52319. * Gets wether or not G buffer are supported by the running hardware.
  52320. * This requires draw buffer supports
  52321. */
  52322. readonly isSupported: boolean;
  52323. /**
  52324. * Returns the index of the given texture type in the G-Buffer textures array
  52325. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52326. * @returns the index of the given texture type in the G-Buffer textures array
  52327. */
  52328. getTextureIndex(textureType: number): number;
  52329. /**
  52330. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52331. */
  52332. /**
  52333. * Sets whether or not objects positions are enabled for the G buffer.
  52334. */
  52335. enablePosition: boolean;
  52336. /**
  52337. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52338. */
  52339. /**
  52340. * Sets wether or not objects velocities are enabled for the G buffer.
  52341. */
  52342. enableVelocity: boolean;
  52343. /**
  52344. * Gets the scene associated with the buffer.
  52345. */
  52346. readonly scene: Scene;
  52347. /**
  52348. * Gets the ratio used by the buffer during its creation.
  52349. * How big is the buffer related to the main canvas.
  52350. */
  52351. readonly ratio: number;
  52352. /** @hidden */
  52353. static _SceneComponentInitialization: (scene: Scene) => void;
  52354. /**
  52355. * Creates a new G Buffer for the scene
  52356. * @param scene The scene the buffer belongs to
  52357. * @param ratio How big is the buffer related to the main canvas.
  52358. */
  52359. constructor(scene: Scene, ratio?: number);
  52360. /**
  52361. * Checks wether everything is ready to render a submesh to the G buffer.
  52362. * @param subMesh the submesh to check readiness for
  52363. * @param useInstances is the mesh drawn using instance or not
  52364. * @returns true if ready otherwise false
  52365. */
  52366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52367. /**
  52368. * Gets the current underlying G Buffer.
  52369. * @returns the buffer
  52370. */
  52371. getGBuffer(): MultiRenderTarget;
  52372. /**
  52373. * Gets the number of samples used to render the buffer (anti aliasing).
  52374. */
  52375. /**
  52376. * Sets the number of samples used to render the buffer (anti aliasing).
  52377. */
  52378. samples: number;
  52379. /**
  52380. * Disposes the renderer and frees up associated resources.
  52381. */
  52382. dispose(): void;
  52383. protected _createRenderTargets(): void;
  52384. }
  52385. }
  52386. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52387. /** @hidden */
  52388. export var motionBlurPixelShader: {
  52389. name: string;
  52390. shader: string;
  52391. };
  52392. }
  52393. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52394. import { Nullable } from "babylonjs/types";
  52395. import { Camera } from "babylonjs/Cameras/camera";
  52396. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52397. import { Scene } from "babylonjs/scene";
  52398. import "babylonjs/Shaders/motionBlur.fragment";
  52399. import { Engine } from "babylonjs/Engines/engine";
  52400. /**
  52401. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52402. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52403. * As an example, all you have to do is to create the post-process:
  52404. * var mb = new BABYLON.MotionBlurPostProcess(
  52405. * 'mb', // The name of the effect.
  52406. * scene, // The scene containing the objects to blur according to their velocity.
  52407. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52408. * camera // The camera to apply the render pass to.
  52409. * );
  52410. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52411. */
  52412. export class MotionBlurPostProcess extends PostProcess {
  52413. /**
  52414. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52415. */
  52416. motionStrength: number;
  52417. /**
  52418. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52419. */
  52420. /**
  52421. * Sets the number of iterations to be used for motion blur quality
  52422. */
  52423. motionBlurSamples: number;
  52424. private _motionBlurSamples;
  52425. private _geometryBufferRenderer;
  52426. /**
  52427. * Creates a new instance MotionBlurPostProcess
  52428. * @param name The name of the effect.
  52429. * @param scene The scene containing the objects to blur according to their velocity.
  52430. * @param options The required width/height ratio to downsize to before computing the render pass.
  52431. * @param camera The camera to apply the render pass to.
  52432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52433. * @param engine The engine which the post process will be applied. (default: current engine)
  52434. * @param reusable If the post process can be reused on the same frame. (default: false)
  52435. * @param textureType Type of textures used when performing the post process. (default: 0)
  52436. * @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)
  52437. */
  52438. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52439. /**
  52440. * Disposes the post process.
  52441. * @param camera The camera to dispose the post process on.
  52442. */
  52443. dispose(camera?: Camera): void;
  52444. }
  52445. }
  52446. declare module "babylonjs/Shaders/refraction.fragment" {
  52447. /** @hidden */
  52448. export var refractionPixelShader: {
  52449. name: string;
  52450. shader: string;
  52451. };
  52452. }
  52453. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52454. import { Color3 } from "babylonjs/Maths/math";
  52455. import { Camera } from "babylonjs/Cameras/camera";
  52456. import { Texture } from "babylonjs/Materials/Textures/texture";
  52457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52458. import { Engine } from "babylonjs/Engines/engine";
  52459. import "babylonjs/Shaders/refraction.fragment";
  52460. /**
  52461. * Post process which applies a refractin texture
  52462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52463. */
  52464. export class RefractionPostProcess extends PostProcess {
  52465. /** the base color of the refraction (used to taint the rendering) */
  52466. color: Color3;
  52467. /** simulated refraction depth */
  52468. depth: number;
  52469. /** the coefficient of the base color (0 to remove base color tainting) */
  52470. colorLevel: number;
  52471. private _refTexture;
  52472. private _ownRefractionTexture;
  52473. /**
  52474. * Gets or sets the refraction texture
  52475. * Please note that you are responsible for disposing the texture if you set it manually
  52476. */
  52477. refractionTexture: Texture;
  52478. /**
  52479. * Initializes the RefractionPostProcess
  52480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52481. * @param name The name of the effect.
  52482. * @param refractionTextureUrl Url of the refraction texture to use
  52483. * @param color the base color of the refraction (used to taint the rendering)
  52484. * @param depth simulated refraction depth
  52485. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52486. * @param camera The camera to apply the render pass to.
  52487. * @param options The required width/height ratio to downsize to before computing the render pass.
  52488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52489. * @param engine The engine which the post process will be applied. (default: current engine)
  52490. * @param reusable If the post process can be reused on the same frame. (default: false)
  52491. */
  52492. constructor(name: string, refractionTextureUrl: string,
  52493. /** the base color of the refraction (used to taint the rendering) */
  52494. color: Color3,
  52495. /** simulated refraction depth */
  52496. depth: number,
  52497. /** the coefficient of the base color (0 to remove base color tainting) */
  52498. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52499. /**
  52500. * Disposes of the post process
  52501. * @param camera Camera to dispose post process on
  52502. */
  52503. dispose(camera: Camera): void;
  52504. }
  52505. }
  52506. declare module "babylonjs/Shaders/sharpen.fragment" {
  52507. /** @hidden */
  52508. export var sharpenPixelShader: {
  52509. name: string;
  52510. shader: string;
  52511. };
  52512. }
  52513. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52514. import { Nullable } from "babylonjs/types";
  52515. import { Camera } from "babylonjs/Cameras/camera";
  52516. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52517. import "babylonjs/Shaders/sharpen.fragment";
  52518. import { Engine } from "babylonjs/Engines/engine";
  52519. /**
  52520. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52521. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52522. */
  52523. export class SharpenPostProcess extends PostProcess {
  52524. /**
  52525. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52526. */
  52527. colorAmount: number;
  52528. /**
  52529. * How much sharpness should be applied (default: 0.3)
  52530. */
  52531. edgeAmount: number;
  52532. /**
  52533. * Creates a new instance ConvolutionPostProcess
  52534. * @param name The name of the effect.
  52535. * @param options The required width/height ratio to downsize to before computing the render pass.
  52536. * @param camera The camera to apply the render pass to.
  52537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52538. * @param engine The engine which the post process will be applied. (default: current engine)
  52539. * @param reusable If the post process can be reused on the same frame. (default: false)
  52540. * @param textureType Type of textures used when performing the post process. (default: 0)
  52541. * @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)
  52542. */
  52543. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52544. }
  52545. }
  52546. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52547. import { Nullable } from "babylonjs/types";
  52548. import { Camera } from "babylonjs/Cameras/camera";
  52549. import { Engine } from "babylonjs/Engines/engine";
  52550. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52551. /**
  52552. * PostProcessRenderPipeline
  52553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52554. */
  52555. export class PostProcessRenderPipeline {
  52556. private engine;
  52557. private _renderEffects;
  52558. private _renderEffectsForIsolatedPass;
  52559. /**
  52560. * @hidden
  52561. */
  52562. protected _cameras: Camera[];
  52563. /** @hidden */
  52564. _name: string;
  52565. /**
  52566. * Initializes a PostProcessRenderPipeline
  52567. * @param engine engine to add the pipeline to
  52568. * @param name name of the pipeline
  52569. */
  52570. constructor(engine: Engine, name: string);
  52571. /**
  52572. * "PostProcessRenderPipeline"
  52573. * @returns "PostProcessRenderPipeline"
  52574. */
  52575. getClassName(): string;
  52576. /**
  52577. * If all the render effects in the pipeline are support
  52578. */
  52579. readonly isSupported: boolean;
  52580. /**
  52581. * Adds an effect to the pipeline
  52582. * @param renderEffect the effect to add
  52583. */
  52584. addEffect(renderEffect: PostProcessRenderEffect): void;
  52585. /** @hidden */
  52586. _rebuild(): void;
  52587. /** @hidden */
  52588. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52589. /** @hidden */
  52590. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52591. /** @hidden */
  52592. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52593. /** @hidden */
  52594. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52595. /** @hidden */
  52596. _attachCameras(cameras: Camera, unique: boolean): void;
  52597. /** @hidden */
  52598. _attachCameras(cameras: Camera[], unique: boolean): void;
  52599. /** @hidden */
  52600. _detachCameras(cameras: Camera): void;
  52601. /** @hidden */
  52602. _detachCameras(cameras: Nullable<Camera[]>): void;
  52603. /** @hidden */
  52604. _update(): void;
  52605. /** @hidden */
  52606. _reset(): void;
  52607. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52608. /**
  52609. * Disposes of the pipeline
  52610. */
  52611. dispose(): void;
  52612. }
  52613. }
  52614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52615. import { IAnimatable } from "babylonjs/Misc/tools";
  52616. import { Camera } from "babylonjs/Cameras/camera";
  52617. import { IDisposable } from "babylonjs/scene";
  52618. import { Scene } from "babylonjs/scene";
  52619. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52620. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52621. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52622. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52623. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52624. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52625. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52626. import { Animation } from "babylonjs/Animations/animation";
  52627. /**
  52628. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52629. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52630. */
  52631. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52632. private _scene;
  52633. private _camerasToBeAttached;
  52634. /**
  52635. * ID of the sharpen post process,
  52636. */
  52637. private readonly SharpenPostProcessId;
  52638. /**
  52639. * @ignore
  52640. * ID of the image processing post process;
  52641. */
  52642. readonly ImageProcessingPostProcessId: string;
  52643. /**
  52644. * @ignore
  52645. * ID of the Fast Approximate Anti-Aliasing post process;
  52646. */
  52647. readonly FxaaPostProcessId: string;
  52648. /**
  52649. * ID of the chromatic aberration post process,
  52650. */
  52651. private readonly ChromaticAberrationPostProcessId;
  52652. /**
  52653. * ID of the grain post process
  52654. */
  52655. private readonly GrainPostProcessId;
  52656. /**
  52657. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52658. */
  52659. sharpen: SharpenPostProcess;
  52660. private _sharpenEffect;
  52661. private bloom;
  52662. /**
  52663. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52664. */
  52665. depthOfField: DepthOfFieldEffect;
  52666. /**
  52667. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52668. */
  52669. fxaa: FxaaPostProcess;
  52670. /**
  52671. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52672. */
  52673. imageProcessing: ImageProcessingPostProcess;
  52674. /**
  52675. * Chromatic aberration post process which will shift rgb colors in the image
  52676. */
  52677. chromaticAberration: ChromaticAberrationPostProcess;
  52678. private _chromaticAberrationEffect;
  52679. /**
  52680. * Grain post process which add noise to the image
  52681. */
  52682. grain: GrainPostProcess;
  52683. private _grainEffect;
  52684. /**
  52685. * Glow post process which adds a glow to emmisive areas of the image
  52686. */
  52687. private _glowLayer;
  52688. /**
  52689. * Animations which can be used to tweak settings over a period of time
  52690. */
  52691. animations: Animation[];
  52692. private _imageProcessingConfigurationObserver;
  52693. private _sharpenEnabled;
  52694. private _bloomEnabled;
  52695. private _depthOfFieldEnabled;
  52696. private _depthOfFieldBlurLevel;
  52697. private _fxaaEnabled;
  52698. private _imageProcessingEnabled;
  52699. private _defaultPipelineTextureType;
  52700. private _bloomScale;
  52701. private _chromaticAberrationEnabled;
  52702. private _grainEnabled;
  52703. private _buildAllowed;
  52704. /**
  52705. * Enable or disable the sharpen process from the pipeline
  52706. */
  52707. sharpenEnabled: boolean;
  52708. private _resizeObserver;
  52709. private _hardwareScaleLevel;
  52710. private _bloomKernel;
  52711. /**
  52712. * Specifies the size of the bloom blur kernel, relative to the final output size
  52713. */
  52714. bloomKernel: number;
  52715. /**
  52716. * Specifies the weight of the bloom in the final rendering
  52717. */
  52718. private _bloomWeight;
  52719. /**
  52720. * Specifies the luma threshold for the area that will be blurred by the bloom
  52721. */
  52722. private _bloomThreshold;
  52723. private _hdr;
  52724. /**
  52725. * The strength of the bloom.
  52726. */
  52727. bloomWeight: number;
  52728. /**
  52729. * The strength of the bloom.
  52730. */
  52731. bloomThreshold: number;
  52732. /**
  52733. * The scale of the bloom, lower value will provide better performance.
  52734. */
  52735. bloomScale: number;
  52736. /**
  52737. * Enable or disable the bloom from the pipeline
  52738. */
  52739. bloomEnabled: boolean;
  52740. private _rebuildBloom;
  52741. /**
  52742. * If the depth of field is enabled.
  52743. */
  52744. depthOfFieldEnabled: boolean;
  52745. /**
  52746. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52747. */
  52748. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52749. /**
  52750. * If the anti aliasing is enabled.
  52751. */
  52752. fxaaEnabled: boolean;
  52753. private _samples;
  52754. /**
  52755. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52756. */
  52757. samples: number;
  52758. /**
  52759. * If image processing is enabled.
  52760. */
  52761. imageProcessingEnabled: boolean;
  52762. /**
  52763. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52764. */
  52765. glowLayerEnabled: boolean;
  52766. /**
  52767. * Enable or disable the chromaticAberration process from the pipeline
  52768. */
  52769. chromaticAberrationEnabled: boolean;
  52770. /**
  52771. * Enable or disable the grain process from the pipeline
  52772. */
  52773. grainEnabled: boolean;
  52774. /**
  52775. * @constructor
  52776. * @param name - The rendering pipeline name (default: "")
  52777. * @param hdr - If high dynamic range textures should be used (default: true)
  52778. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52779. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52780. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52781. */
  52782. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52783. /**
  52784. * Force the compilation of the entire pipeline.
  52785. */
  52786. prepare(): void;
  52787. private _hasCleared;
  52788. private _prevPostProcess;
  52789. private _prevPrevPostProcess;
  52790. private _setAutoClearAndTextureSharing;
  52791. private _depthOfFieldSceneObserver;
  52792. private _buildPipeline;
  52793. private _disposePostProcesses;
  52794. /**
  52795. * Adds a camera to the pipeline
  52796. * @param camera the camera to be added
  52797. */
  52798. addCamera(camera: Camera): void;
  52799. /**
  52800. * Removes a camera from the pipeline
  52801. * @param camera the camera to remove
  52802. */
  52803. removeCamera(camera: Camera): void;
  52804. /**
  52805. * Dispose of the pipeline and stop all post processes
  52806. */
  52807. dispose(): void;
  52808. /**
  52809. * Serialize the rendering pipeline (Used when exporting)
  52810. * @returns the serialized object
  52811. */
  52812. serialize(): any;
  52813. /**
  52814. * Parse the serialized pipeline
  52815. * @param source Source pipeline.
  52816. * @param scene The scene to load the pipeline to.
  52817. * @param rootUrl The URL of the serialized pipeline.
  52818. * @returns An instantiated pipeline from the serialized object.
  52819. */
  52820. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52821. }
  52822. }
  52823. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52824. /** @hidden */
  52825. export var lensHighlightsPixelShader: {
  52826. name: string;
  52827. shader: string;
  52828. };
  52829. }
  52830. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52831. /** @hidden */
  52832. export var depthOfFieldPixelShader: {
  52833. name: string;
  52834. shader: string;
  52835. };
  52836. }
  52837. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52838. import { Camera } from "babylonjs/Cameras/camera";
  52839. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52840. import { Scene } from "babylonjs/scene";
  52841. import "babylonjs/Shaders/chromaticAberration.fragment";
  52842. import "babylonjs/Shaders/lensHighlights.fragment";
  52843. import "babylonjs/Shaders/depthOfField.fragment";
  52844. /**
  52845. * BABYLON.JS Chromatic Aberration GLSL Shader
  52846. * Author: Olivier Guyot
  52847. * Separates very slightly R, G and B colors on the edges of the screen
  52848. * Inspired by Francois Tarlier & Martins Upitis
  52849. */
  52850. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52851. /**
  52852. * @ignore
  52853. * The chromatic aberration PostProcess id in the pipeline
  52854. */
  52855. LensChromaticAberrationEffect: string;
  52856. /**
  52857. * @ignore
  52858. * The highlights enhancing PostProcess id in the pipeline
  52859. */
  52860. HighlightsEnhancingEffect: string;
  52861. /**
  52862. * @ignore
  52863. * The depth-of-field PostProcess id in the pipeline
  52864. */
  52865. LensDepthOfFieldEffect: string;
  52866. private _scene;
  52867. private _depthTexture;
  52868. private _grainTexture;
  52869. private _chromaticAberrationPostProcess;
  52870. private _highlightsPostProcess;
  52871. private _depthOfFieldPostProcess;
  52872. private _edgeBlur;
  52873. private _grainAmount;
  52874. private _chromaticAberration;
  52875. private _distortion;
  52876. private _highlightsGain;
  52877. private _highlightsThreshold;
  52878. private _dofDistance;
  52879. private _dofAperture;
  52880. private _dofDarken;
  52881. private _dofPentagon;
  52882. private _blurNoise;
  52883. /**
  52884. * @constructor
  52885. *
  52886. * Effect parameters are as follow:
  52887. * {
  52888. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52889. * edge_blur: number; // from 0 to x (1 for realism)
  52890. * distortion: number; // from 0 to x (1 for realism)
  52891. * grain_amount: number; // from 0 to 1
  52892. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52893. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52894. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52895. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52896. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52897. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52898. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52899. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52900. * }
  52901. * Note: if an effect parameter is unset, effect is disabled
  52902. *
  52903. * @param name The rendering pipeline name
  52904. * @param parameters - An object containing all parameters (see above)
  52905. * @param scene The scene linked to this pipeline
  52906. * @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)
  52907. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52908. */
  52909. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52910. /**
  52911. * Sets the amount of blur at the edges
  52912. * @param amount blur amount
  52913. */
  52914. setEdgeBlur(amount: number): void;
  52915. /**
  52916. * Sets edge blur to 0
  52917. */
  52918. disableEdgeBlur(): void;
  52919. /**
  52920. * Sets the amout of grain
  52921. * @param amount Amount of grain
  52922. */
  52923. setGrainAmount(amount: number): void;
  52924. /**
  52925. * Set grain amount to 0
  52926. */
  52927. disableGrain(): void;
  52928. /**
  52929. * Sets the chromatic aberration amount
  52930. * @param amount amount of chromatic aberration
  52931. */
  52932. setChromaticAberration(amount: number): void;
  52933. /**
  52934. * Sets chromatic aberration amount to 0
  52935. */
  52936. disableChromaticAberration(): void;
  52937. /**
  52938. * Sets the EdgeDistortion amount
  52939. * @param amount amount of EdgeDistortion
  52940. */
  52941. setEdgeDistortion(amount: number): void;
  52942. /**
  52943. * Sets edge distortion to 0
  52944. */
  52945. disableEdgeDistortion(): void;
  52946. /**
  52947. * Sets the FocusDistance amount
  52948. * @param amount amount of FocusDistance
  52949. */
  52950. setFocusDistance(amount: number): void;
  52951. /**
  52952. * Disables depth of field
  52953. */
  52954. disableDepthOfField(): void;
  52955. /**
  52956. * Sets the Aperture amount
  52957. * @param amount amount of Aperture
  52958. */
  52959. setAperture(amount: number): void;
  52960. /**
  52961. * Sets the DarkenOutOfFocus amount
  52962. * @param amount amount of DarkenOutOfFocus
  52963. */
  52964. setDarkenOutOfFocus(amount: number): void;
  52965. /**
  52966. * Creates a pentagon bokeh effect
  52967. */
  52968. enablePentagonBokeh(): void;
  52969. /**
  52970. * Disables the pentagon bokeh effect
  52971. */
  52972. disablePentagonBokeh(): void;
  52973. /**
  52974. * Enables noise blur
  52975. */
  52976. enableNoiseBlur(): void;
  52977. /**
  52978. * Disables noise blur
  52979. */
  52980. disableNoiseBlur(): void;
  52981. /**
  52982. * Sets the HighlightsGain amount
  52983. * @param amount amount of HighlightsGain
  52984. */
  52985. setHighlightsGain(amount: number): void;
  52986. /**
  52987. * Sets the HighlightsThreshold amount
  52988. * @param amount amount of HighlightsThreshold
  52989. */
  52990. setHighlightsThreshold(amount: number): void;
  52991. /**
  52992. * Disables highlights
  52993. */
  52994. disableHighlights(): void;
  52995. /**
  52996. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52997. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52998. */
  52999. dispose(disableDepthRender?: boolean): void;
  53000. private _createChromaticAberrationPostProcess;
  53001. private _createHighlightsPostProcess;
  53002. private _createDepthOfFieldPostProcess;
  53003. private _createGrainTexture;
  53004. }
  53005. }
  53006. declare module "babylonjs/Shaders/ssao2.fragment" {
  53007. /** @hidden */
  53008. export var ssao2PixelShader: {
  53009. name: string;
  53010. shader: string;
  53011. };
  53012. }
  53013. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53014. /** @hidden */
  53015. export var ssaoCombinePixelShader: {
  53016. name: string;
  53017. shader: string;
  53018. };
  53019. }
  53020. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53021. import { Camera } from "babylonjs/Cameras/camera";
  53022. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53023. import { Scene } from "babylonjs/scene";
  53024. import "babylonjs/Shaders/ssao2.fragment";
  53025. import "babylonjs/Shaders/ssaoCombine.fragment";
  53026. /**
  53027. * Render pipeline to produce ssao effect
  53028. */
  53029. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53030. /**
  53031. * @ignore
  53032. * The PassPostProcess id in the pipeline that contains the original scene color
  53033. */
  53034. SSAOOriginalSceneColorEffect: string;
  53035. /**
  53036. * @ignore
  53037. * The SSAO PostProcess id in the pipeline
  53038. */
  53039. SSAORenderEffect: string;
  53040. /**
  53041. * @ignore
  53042. * The horizontal blur PostProcess id in the pipeline
  53043. */
  53044. SSAOBlurHRenderEffect: string;
  53045. /**
  53046. * @ignore
  53047. * The vertical blur PostProcess id in the pipeline
  53048. */
  53049. SSAOBlurVRenderEffect: string;
  53050. /**
  53051. * @ignore
  53052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53053. */
  53054. SSAOCombineRenderEffect: string;
  53055. /**
  53056. * The output strength of the SSAO post-process. Default value is 1.0.
  53057. */
  53058. totalStrength: number;
  53059. /**
  53060. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53061. */
  53062. maxZ: number;
  53063. /**
  53064. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53065. */
  53066. minZAspect: number;
  53067. private _samples;
  53068. /**
  53069. * Number of samples used for the SSAO calculations. Default value is 8
  53070. */
  53071. samples: number;
  53072. private _textureSamples;
  53073. /**
  53074. * Number of samples to use for antialiasing
  53075. */
  53076. textureSamples: number;
  53077. /**
  53078. * Ratio object used for SSAO ratio and blur ratio
  53079. */
  53080. private _ratio;
  53081. /**
  53082. * Dynamically generated sphere sampler.
  53083. */
  53084. private _sampleSphere;
  53085. /**
  53086. * Blur filter offsets
  53087. */
  53088. private _samplerOffsets;
  53089. private _expensiveBlur;
  53090. /**
  53091. * If bilateral blur should be used
  53092. */
  53093. expensiveBlur: boolean;
  53094. /**
  53095. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53096. */
  53097. radius: number;
  53098. /**
  53099. * The base color of the SSAO post-process
  53100. * The final result is "base + ssao" between [0, 1]
  53101. */
  53102. base: number;
  53103. /**
  53104. * Support test.
  53105. */
  53106. static readonly IsSupported: boolean;
  53107. private _scene;
  53108. private _depthTexture;
  53109. private _normalTexture;
  53110. private _randomTexture;
  53111. private _originalColorPostProcess;
  53112. private _ssaoPostProcess;
  53113. private _blurHPostProcess;
  53114. private _blurVPostProcess;
  53115. private _ssaoCombinePostProcess;
  53116. private _firstUpdate;
  53117. /**
  53118. * @constructor
  53119. * @param name The rendering pipeline name
  53120. * @param scene The scene linked to this pipeline
  53121. * @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 }
  53122. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53123. */
  53124. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53125. /**
  53126. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53127. */
  53128. dispose(disableGeometryBufferRenderer?: boolean): void;
  53129. private _createBlurPostProcess;
  53130. /** @hidden */
  53131. _rebuild(): void;
  53132. private _bits;
  53133. private _radicalInverse_VdC;
  53134. private _hammersley;
  53135. private _hemisphereSample_uniform;
  53136. private _generateHemisphere;
  53137. private _createSSAOPostProcess;
  53138. private _createSSAOCombinePostProcess;
  53139. private _createRandomTexture;
  53140. /**
  53141. * Serialize the rendering pipeline (Used when exporting)
  53142. * @returns the serialized object
  53143. */
  53144. serialize(): any;
  53145. /**
  53146. * Parse the serialized pipeline
  53147. * @param source Source pipeline.
  53148. * @param scene The scene to load the pipeline to.
  53149. * @param rootUrl The URL of the serialized pipeline.
  53150. * @returns An instantiated pipeline from the serialized object.
  53151. */
  53152. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53153. }
  53154. }
  53155. declare module "babylonjs/Shaders/ssao.fragment" {
  53156. /** @hidden */
  53157. export var ssaoPixelShader: {
  53158. name: string;
  53159. shader: string;
  53160. };
  53161. }
  53162. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53163. import { Camera } from "babylonjs/Cameras/camera";
  53164. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53165. import { Scene } from "babylonjs/scene";
  53166. import "babylonjs/Shaders/ssao.fragment";
  53167. import "babylonjs/Shaders/ssaoCombine.fragment";
  53168. /**
  53169. * Render pipeline to produce ssao effect
  53170. */
  53171. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53172. /**
  53173. * @ignore
  53174. * The PassPostProcess id in the pipeline that contains the original scene color
  53175. */
  53176. SSAOOriginalSceneColorEffect: string;
  53177. /**
  53178. * @ignore
  53179. * The SSAO PostProcess id in the pipeline
  53180. */
  53181. SSAORenderEffect: string;
  53182. /**
  53183. * @ignore
  53184. * The horizontal blur PostProcess id in the pipeline
  53185. */
  53186. SSAOBlurHRenderEffect: string;
  53187. /**
  53188. * @ignore
  53189. * The vertical blur PostProcess id in the pipeline
  53190. */
  53191. SSAOBlurVRenderEffect: string;
  53192. /**
  53193. * @ignore
  53194. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53195. */
  53196. SSAOCombineRenderEffect: string;
  53197. /**
  53198. * The output strength of the SSAO post-process. Default value is 1.0.
  53199. */
  53200. totalStrength: number;
  53201. /**
  53202. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53203. */
  53204. radius: number;
  53205. /**
  53206. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53207. * Must not be equal to fallOff and superior to fallOff.
  53208. * Default value is 0.975
  53209. */
  53210. area: number;
  53211. /**
  53212. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53213. * Must not be equal to area and inferior to area.
  53214. * Default value is 0.0
  53215. */
  53216. fallOff: number;
  53217. /**
  53218. * The base color of the SSAO post-process
  53219. * The final result is "base + ssao" between [0, 1]
  53220. */
  53221. base: number;
  53222. private _scene;
  53223. private _depthTexture;
  53224. private _randomTexture;
  53225. private _originalColorPostProcess;
  53226. private _ssaoPostProcess;
  53227. private _blurHPostProcess;
  53228. private _blurVPostProcess;
  53229. private _ssaoCombinePostProcess;
  53230. private _firstUpdate;
  53231. /**
  53232. * @constructor
  53233. * @param name - The rendering pipeline name
  53234. * @param scene - The scene linked to this pipeline
  53235. * @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 }
  53236. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53237. */
  53238. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53239. /**
  53240. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53241. */
  53242. dispose(disableDepthRender?: boolean): void;
  53243. private _createBlurPostProcess;
  53244. /** @hidden */
  53245. _rebuild(): void;
  53246. private _createSSAOPostProcess;
  53247. private _createSSAOCombinePostProcess;
  53248. private _createRandomTexture;
  53249. }
  53250. }
  53251. declare module "babylonjs/Shaders/standard.fragment" {
  53252. /** @hidden */
  53253. export var standardPixelShader: {
  53254. name: string;
  53255. shader: string;
  53256. };
  53257. }
  53258. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53259. import { Nullable } from "babylonjs/types";
  53260. import { IAnimatable } from "babylonjs/Misc/tools";
  53261. import { Camera } from "babylonjs/Cameras/camera";
  53262. import { Texture } from "babylonjs/Materials/Textures/texture";
  53263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53264. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53265. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53266. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53267. import { IDisposable } from "babylonjs/scene";
  53268. import { SpotLight } from "babylonjs/Lights/spotLight";
  53269. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53270. import { Scene } from "babylonjs/scene";
  53271. import { Animation } from "babylonjs/Animations/animation";
  53272. import "babylonjs/Shaders/standard.fragment";
  53273. /**
  53274. * Standard rendering pipeline
  53275. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53276. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53277. */
  53278. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53279. /**
  53280. * Public members
  53281. */
  53282. /**
  53283. * Post-process which contains the original scene color before the pipeline applies all the effects
  53284. */
  53285. originalPostProcess: Nullable<PostProcess>;
  53286. /**
  53287. * Post-process used to down scale an image x4
  53288. */
  53289. downSampleX4PostProcess: Nullable<PostProcess>;
  53290. /**
  53291. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53292. */
  53293. brightPassPostProcess: Nullable<PostProcess>;
  53294. /**
  53295. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53296. */
  53297. blurHPostProcesses: PostProcess[];
  53298. /**
  53299. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53300. */
  53301. blurVPostProcesses: PostProcess[];
  53302. /**
  53303. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53304. */
  53305. textureAdderPostProcess: Nullable<PostProcess>;
  53306. /**
  53307. * Post-process used to create volumetric lighting effect
  53308. */
  53309. volumetricLightPostProcess: Nullable<PostProcess>;
  53310. /**
  53311. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53312. */
  53313. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53314. /**
  53315. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53316. */
  53317. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53318. /**
  53319. * Post-process used to merge the volumetric light effect and the real scene color
  53320. */
  53321. volumetricLightMergePostProces: Nullable<PostProcess>;
  53322. /**
  53323. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53324. */
  53325. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53326. /**
  53327. * Base post-process used to calculate the average luminance of the final image for HDR
  53328. */
  53329. luminancePostProcess: Nullable<PostProcess>;
  53330. /**
  53331. * Post-processes used to create down sample post-processes in order to get
  53332. * the average luminance of the final image for HDR
  53333. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53334. */
  53335. luminanceDownSamplePostProcesses: PostProcess[];
  53336. /**
  53337. * Post-process used to create a HDR effect (light adaptation)
  53338. */
  53339. hdrPostProcess: Nullable<PostProcess>;
  53340. /**
  53341. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53342. */
  53343. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53344. /**
  53345. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53346. */
  53347. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53348. /**
  53349. * Post-process used to merge the final HDR post-process and the real scene color
  53350. */
  53351. hdrFinalPostProcess: Nullable<PostProcess>;
  53352. /**
  53353. * Post-process used to create a lens flare effect
  53354. */
  53355. lensFlarePostProcess: Nullable<PostProcess>;
  53356. /**
  53357. * Post-process that merges the result of the lens flare post-process and the real scene color
  53358. */
  53359. lensFlareComposePostProcess: Nullable<PostProcess>;
  53360. /**
  53361. * Post-process used to create a motion blur effect
  53362. */
  53363. motionBlurPostProcess: Nullable<PostProcess>;
  53364. /**
  53365. * Post-process used to create a depth of field effect
  53366. */
  53367. depthOfFieldPostProcess: Nullable<PostProcess>;
  53368. /**
  53369. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53370. */
  53371. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53372. /**
  53373. * Represents the brightness threshold in order to configure the illuminated surfaces
  53374. */
  53375. brightThreshold: number;
  53376. /**
  53377. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53378. */
  53379. blurWidth: number;
  53380. /**
  53381. * Sets if the blur for highlighted surfaces must be only horizontal
  53382. */
  53383. horizontalBlur: boolean;
  53384. /**
  53385. * Sets the overall exposure used by the pipeline
  53386. */
  53387. exposure: number;
  53388. /**
  53389. * Texture used typically to simulate "dirty" on camera lens
  53390. */
  53391. lensTexture: Nullable<Texture>;
  53392. /**
  53393. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53394. */
  53395. volumetricLightCoefficient: number;
  53396. /**
  53397. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53398. */
  53399. volumetricLightPower: number;
  53400. /**
  53401. * Used the set the blur intensity to smooth the volumetric lights
  53402. */
  53403. volumetricLightBlurScale: number;
  53404. /**
  53405. * Light (spot or directional) used to generate the volumetric lights rays
  53406. * The source light must have a shadow generate so the pipeline can get its
  53407. * depth map
  53408. */
  53409. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53410. /**
  53411. * For eye adaptation, represents the minimum luminance the eye can see
  53412. */
  53413. hdrMinimumLuminance: number;
  53414. /**
  53415. * For eye adaptation, represents the decrease luminance speed
  53416. */
  53417. hdrDecreaseRate: number;
  53418. /**
  53419. * For eye adaptation, represents the increase luminance speed
  53420. */
  53421. hdrIncreaseRate: number;
  53422. /**
  53423. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53424. */
  53425. lensColorTexture: Nullable<Texture>;
  53426. /**
  53427. * The overall strengh for the lens flare effect
  53428. */
  53429. lensFlareStrength: number;
  53430. /**
  53431. * Dispersion coefficient for lens flare ghosts
  53432. */
  53433. lensFlareGhostDispersal: number;
  53434. /**
  53435. * Main lens flare halo width
  53436. */
  53437. lensFlareHaloWidth: number;
  53438. /**
  53439. * Based on the lens distortion effect, defines how much the lens flare result
  53440. * is distorted
  53441. */
  53442. lensFlareDistortionStrength: number;
  53443. /**
  53444. * Lens star texture must be used to simulate rays on the flares and is available
  53445. * in the documentation
  53446. */
  53447. lensStarTexture: Nullable<Texture>;
  53448. /**
  53449. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53450. * flare effect by taking account of the dirt texture
  53451. */
  53452. lensFlareDirtTexture: Nullable<Texture>;
  53453. /**
  53454. * Represents the focal length for the depth of field effect
  53455. */
  53456. depthOfFieldDistance: number;
  53457. /**
  53458. * Represents the blur intensity for the blurred part of the depth of field effect
  53459. */
  53460. depthOfFieldBlurWidth: number;
  53461. /**
  53462. * For motion blur, defines how much the image is blurred by the movement
  53463. */
  53464. motionStrength: number;
  53465. /**
  53466. * List of animations for the pipeline (IAnimatable implementation)
  53467. */
  53468. animations: Animation[];
  53469. /**
  53470. * Private members
  53471. */
  53472. private _scene;
  53473. private _currentDepthOfFieldSource;
  53474. private _basePostProcess;
  53475. private _hdrCurrentLuminance;
  53476. private _floatTextureType;
  53477. private _ratio;
  53478. private _bloomEnabled;
  53479. private _depthOfFieldEnabled;
  53480. private _vlsEnabled;
  53481. private _lensFlareEnabled;
  53482. private _hdrEnabled;
  53483. private _motionBlurEnabled;
  53484. private _fxaaEnabled;
  53485. private _motionBlurSamples;
  53486. private _volumetricLightStepsCount;
  53487. private _samples;
  53488. /**
  53489. * @ignore
  53490. * Specifies if the bloom pipeline is enabled
  53491. */
  53492. BloomEnabled: boolean;
  53493. /**
  53494. * @ignore
  53495. * Specifies if the depth of field pipeline is enabed
  53496. */
  53497. DepthOfFieldEnabled: boolean;
  53498. /**
  53499. * @ignore
  53500. * Specifies if the lens flare pipeline is enabed
  53501. */
  53502. LensFlareEnabled: boolean;
  53503. /**
  53504. * @ignore
  53505. * Specifies if the HDR pipeline is enabled
  53506. */
  53507. HDREnabled: boolean;
  53508. /**
  53509. * @ignore
  53510. * Specifies if the volumetric lights scattering effect is enabled
  53511. */
  53512. VLSEnabled: boolean;
  53513. /**
  53514. * @ignore
  53515. * Specifies if the motion blur effect is enabled
  53516. */
  53517. MotionBlurEnabled: boolean;
  53518. /**
  53519. * Specifies if anti-aliasing is enabled
  53520. */
  53521. fxaaEnabled: boolean;
  53522. /**
  53523. * Specifies the number of steps used to calculate the volumetric lights
  53524. * Typically in interval [50, 200]
  53525. */
  53526. volumetricLightStepsCount: number;
  53527. /**
  53528. * Specifies the number of samples used for the motion blur effect
  53529. * Typically in interval [16, 64]
  53530. */
  53531. motionBlurSamples: number;
  53532. /**
  53533. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53534. */
  53535. samples: number;
  53536. /**
  53537. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53538. * @constructor
  53539. * @param name The rendering pipeline name
  53540. * @param scene The scene linked to this pipeline
  53541. * @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)
  53542. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53543. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53544. */
  53545. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53546. private _buildPipeline;
  53547. private _createDownSampleX4PostProcess;
  53548. private _createBrightPassPostProcess;
  53549. private _createBlurPostProcesses;
  53550. private _createTextureAdderPostProcess;
  53551. private _createVolumetricLightPostProcess;
  53552. private _createLuminancePostProcesses;
  53553. private _createHdrPostProcess;
  53554. private _createLensFlarePostProcess;
  53555. private _createDepthOfFieldPostProcess;
  53556. private _createMotionBlurPostProcess;
  53557. private _getDepthTexture;
  53558. private _disposePostProcesses;
  53559. /**
  53560. * Dispose of the pipeline and stop all post processes
  53561. */
  53562. dispose(): void;
  53563. /**
  53564. * Serialize the rendering pipeline (Used when exporting)
  53565. * @returns the serialized object
  53566. */
  53567. serialize(): any;
  53568. /**
  53569. * Parse the serialized pipeline
  53570. * @param source Source pipeline.
  53571. * @param scene The scene to load the pipeline to.
  53572. * @param rootUrl The URL of the serialized pipeline.
  53573. * @returns An instantiated pipeline from the serialized object.
  53574. */
  53575. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53576. /**
  53577. * Luminance steps
  53578. */
  53579. static LuminanceSteps: number;
  53580. }
  53581. }
  53582. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53583. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53584. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53585. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53586. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53587. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53588. }
  53589. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53590. import { Camera } from "babylonjs/Cameras/camera";
  53591. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53592. /**
  53593. * PostProcessRenderPipelineManager class
  53594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53595. */
  53596. export class PostProcessRenderPipelineManager {
  53597. private _renderPipelines;
  53598. /**
  53599. * Initializes a PostProcessRenderPipelineManager
  53600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53601. */
  53602. constructor();
  53603. /**
  53604. * Adds a pipeline to the manager
  53605. * @param renderPipeline The pipeline to add
  53606. */
  53607. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53608. /**
  53609. * Attaches a camera to the pipeline
  53610. * @param renderPipelineName The name of the pipeline to attach to
  53611. * @param cameras the camera to attach
  53612. * @param unique if the camera can be attached multiple times to the pipeline
  53613. */
  53614. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53615. /**
  53616. * Detaches a camera from the pipeline
  53617. * @param renderPipelineName The name of the pipeline to detach from
  53618. * @param cameras the camera to detach
  53619. */
  53620. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53621. /**
  53622. * Enables an effect by name on a pipeline
  53623. * @param renderPipelineName the name of the pipeline to enable the effect in
  53624. * @param renderEffectName the name of the effect to enable
  53625. * @param cameras the cameras that the effect should be enabled on
  53626. */
  53627. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53628. /**
  53629. * Disables an effect by name on a pipeline
  53630. * @param renderPipelineName the name of the pipeline to disable the effect in
  53631. * @param renderEffectName the name of the effect to disable
  53632. * @param cameras the cameras that the effect should be disabled on
  53633. */
  53634. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53635. /**
  53636. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53637. */
  53638. update(): void;
  53639. /** @hidden */
  53640. _rebuild(): void;
  53641. /**
  53642. * Disposes of the manager and pipelines
  53643. */
  53644. dispose(): void;
  53645. }
  53646. }
  53647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53648. import { ISceneComponent } from "babylonjs/sceneComponent";
  53649. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53650. import { Scene } from "babylonjs/scene";
  53651. module "babylonjs/scene" {
  53652. interface Scene {
  53653. /** @hidden (Backing field) */
  53654. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53655. /**
  53656. * Gets the postprocess render pipeline manager
  53657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53658. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53659. */
  53660. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53661. }
  53662. }
  53663. /**
  53664. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53665. */
  53666. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53667. /**
  53668. * The component name helpfull to identify the component in the list of scene components.
  53669. */
  53670. readonly name: string;
  53671. /**
  53672. * The scene the component belongs to.
  53673. */
  53674. scene: Scene;
  53675. /**
  53676. * Creates a new instance of the component for the given scene
  53677. * @param scene Defines the scene to register the component in
  53678. */
  53679. constructor(scene: Scene);
  53680. /**
  53681. * Registers the component in a given scene
  53682. */
  53683. register(): void;
  53684. /**
  53685. * Rebuilds the elements related to this component in case of
  53686. * context lost for instance.
  53687. */
  53688. rebuild(): void;
  53689. /**
  53690. * Disposes the component and the associated ressources
  53691. */
  53692. dispose(): void;
  53693. private _gatherRenderTargets;
  53694. }
  53695. }
  53696. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53697. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53698. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53699. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53700. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53701. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53702. }
  53703. declare module "babylonjs/Shaders/tonemap.fragment" {
  53704. /** @hidden */
  53705. export var tonemapPixelShader: {
  53706. name: string;
  53707. shader: string;
  53708. };
  53709. }
  53710. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53711. import { Camera } from "babylonjs/Cameras/camera";
  53712. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53713. import "babylonjs/Shaders/tonemap.fragment";
  53714. import { Engine } from "babylonjs/Engines/engine";
  53715. /** Defines operator used for tonemapping */
  53716. export enum TonemappingOperator {
  53717. /** Hable */
  53718. Hable = 0,
  53719. /** Reinhard */
  53720. Reinhard = 1,
  53721. /** HejiDawson */
  53722. HejiDawson = 2,
  53723. /** Photographic */
  53724. Photographic = 3
  53725. }
  53726. /**
  53727. * Defines a post process to apply tone mapping
  53728. */
  53729. export class TonemapPostProcess extends PostProcess {
  53730. private _operator;
  53731. /** Defines the required exposure adjustement */
  53732. exposureAdjustment: number;
  53733. /**
  53734. * Creates a new TonemapPostProcess
  53735. * @param name defines the name of the postprocess
  53736. * @param _operator defines the operator to use
  53737. * @param exposureAdjustment defines the required exposure adjustement
  53738. * @param camera defines the camera to use (can be null)
  53739. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53740. * @param engine defines the hosting engine (can be ignore if camera is set)
  53741. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53742. */
  53743. constructor(name: string, _operator: TonemappingOperator,
  53744. /** Defines the required exposure adjustement */
  53745. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53746. }
  53747. }
  53748. declare module "babylonjs/Shaders/depth.vertex" {
  53749. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53750. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53751. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53752. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53753. /** @hidden */
  53754. export var depthVertexShader: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53760. /** @hidden */
  53761. export var volumetricLightScatteringPixelShader: {
  53762. name: string;
  53763. shader: string;
  53764. };
  53765. }
  53766. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53767. /** @hidden */
  53768. export var volumetricLightScatteringPassPixelShader: {
  53769. name: string;
  53770. shader: string;
  53771. };
  53772. }
  53773. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53774. import { Vector3 } from "babylonjs/Maths/math";
  53775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53776. import { Mesh } from "babylonjs/Meshes/mesh";
  53777. import { Camera } from "babylonjs/Cameras/camera";
  53778. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53779. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53780. import { Scene } from "babylonjs/scene";
  53781. import "babylonjs/Meshes/Builders/planeBuilder";
  53782. import "babylonjs/Shaders/depth.vertex";
  53783. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53784. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53785. import { Engine } from "babylonjs/Engines/engine";
  53786. /**
  53787. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53788. */
  53789. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53790. private _volumetricLightScatteringPass;
  53791. private _volumetricLightScatteringRTT;
  53792. private _viewPort;
  53793. private _screenCoordinates;
  53794. private _cachedDefines;
  53795. /**
  53796. * If not undefined, the mesh position is computed from the attached node position
  53797. */
  53798. attachedNode: {
  53799. position: Vector3;
  53800. };
  53801. /**
  53802. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53803. */
  53804. customMeshPosition: Vector3;
  53805. /**
  53806. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53807. */
  53808. useCustomMeshPosition: boolean;
  53809. /**
  53810. * If the post-process should inverse the light scattering direction
  53811. */
  53812. invert: boolean;
  53813. /**
  53814. * The internal mesh used by the post-process
  53815. */
  53816. mesh: Mesh;
  53817. /**
  53818. * @hidden
  53819. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53820. */
  53821. useDiffuseColor: boolean;
  53822. /**
  53823. * Array containing the excluded meshes not rendered in the internal pass
  53824. */
  53825. excludedMeshes: AbstractMesh[];
  53826. /**
  53827. * Controls the overall intensity of the post-process
  53828. */
  53829. exposure: number;
  53830. /**
  53831. * Dissipates each sample's contribution in range [0, 1]
  53832. */
  53833. decay: number;
  53834. /**
  53835. * Controls the overall intensity of each sample
  53836. */
  53837. weight: number;
  53838. /**
  53839. * Controls the density of each sample
  53840. */
  53841. density: number;
  53842. /**
  53843. * @constructor
  53844. * @param name The post-process name
  53845. * @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)
  53846. * @param camera The camera that the post-process will be attached to
  53847. * @param mesh The mesh used to create the light scattering
  53848. * @param samples The post-process quality, default 100
  53849. * @param samplingModeThe post-process filtering mode
  53850. * @param engine The babylon engine
  53851. * @param reusable If the post-process is reusable
  53852. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53853. */
  53854. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53855. /**
  53856. * Returns the string "VolumetricLightScatteringPostProcess"
  53857. * @returns "VolumetricLightScatteringPostProcess"
  53858. */
  53859. getClassName(): string;
  53860. private _isReady;
  53861. /**
  53862. * Sets the new light position for light scattering effect
  53863. * @param position The new custom light position
  53864. */
  53865. setCustomMeshPosition(position: Vector3): void;
  53866. /**
  53867. * Returns the light position for light scattering effect
  53868. * @return Vector3 The custom light position
  53869. */
  53870. getCustomMeshPosition(): Vector3;
  53871. /**
  53872. * Disposes the internal assets and detaches the post-process from the camera
  53873. */
  53874. dispose(camera: Camera): void;
  53875. /**
  53876. * Returns the render target texture used by the post-process
  53877. * @return the render target texture used by the post-process
  53878. */
  53879. getPass(): RenderTargetTexture;
  53880. private _meshExcluded;
  53881. private _createPass;
  53882. private _updateMeshScreenCoordinates;
  53883. /**
  53884. * Creates a default mesh for the Volumeric Light Scattering post-process
  53885. * @param name The mesh name
  53886. * @param scene The scene where to create the mesh
  53887. * @return the default mesh
  53888. */
  53889. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53890. }
  53891. }
  53892. declare module "babylonjs/PostProcesses/index" {
  53893. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53894. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53895. export * from "babylonjs/PostProcesses/bloomEffect";
  53896. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53897. export * from "babylonjs/PostProcesses/blurPostProcess";
  53898. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53899. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53900. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53901. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53902. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53903. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53904. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53905. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53906. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53907. export * from "babylonjs/PostProcesses/filterPostProcess";
  53908. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53909. export * from "babylonjs/PostProcesses/grainPostProcess";
  53910. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53911. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53912. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53913. export * from "babylonjs/PostProcesses/passPostProcess";
  53914. export * from "babylonjs/PostProcesses/postProcess";
  53915. export * from "babylonjs/PostProcesses/postProcessManager";
  53916. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53917. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53918. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53919. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53920. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53921. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53922. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53923. }
  53924. declare module "babylonjs/Probes/index" {
  53925. export * from "babylonjs/Probes/reflectionProbe";
  53926. }
  53927. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53928. import { Scene } from "babylonjs/scene";
  53929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53930. import { Color3 } from "babylonjs/Maths/math";
  53931. import { SmartArray } from "babylonjs/Misc/smartArray";
  53932. import { ISceneComponent } from "babylonjs/sceneComponent";
  53933. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53934. import "babylonjs/Meshes/Builders/boxBuilder";
  53935. import "babylonjs/Shaders/color.fragment";
  53936. import "babylonjs/Shaders/color.vertex";
  53937. module "babylonjs/scene" {
  53938. interface Scene {
  53939. /** @hidden (Backing field) */
  53940. _boundingBoxRenderer: BoundingBoxRenderer;
  53941. /** @hidden (Backing field) */
  53942. _forceShowBoundingBoxes: boolean;
  53943. /**
  53944. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53945. */
  53946. forceShowBoundingBoxes: boolean;
  53947. /**
  53948. * Gets the bounding box renderer associated with the scene
  53949. * @returns a BoundingBoxRenderer
  53950. */
  53951. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53952. }
  53953. }
  53954. module "babylonjs/Meshes/abstractMesh" {
  53955. interface AbstractMesh {
  53956. /** @hidden (Backing field) */
  53957. _showBoundingBox: boolean;
  53958. /**
  53959. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53960. */
  53961. showBoundingBox: boolean;
  53962. }
  53963. }
  53964. /**
  53965. * Component responsible of rendering the bounding box of the meshes in a scene.
  53966. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53967. */
  53968. export class BoundingBoxRenderer implements ISceneComponent {
  53969. /**
  53970. * The component name helpfull to identify the component in the list of scene components.
  53971. */
  53972. readonly name: string;
  53973. /**
  53974. * The scene the component belongs to.
  53975. */
  53976. scene: Scene;
  53977. /**
  53978. * Color of the bounding box lines placed in front of an object
  53979. */
  53980. frontColor: Color3;
  53981. /**
  53982. * Color of the bounding box lines placed behind an object
  53983. */
  53984. backColor: Color3;
  53985. /**
  53986. * Defines if the renderer should show the back lines or not
  53987. */
  53988. showBackLines: boolean;
  53989. /**
  53990. * @hidden
  53991. */
  53992. renderList: SmartArray<BoundingBox>;
  53993. private _colorShader;
  53994. private _vertexBuffers;
  53995. private _indexBuffer;
  53996. /**
  53997. * Instantiates a new bounding box renderer in a scene.
  53998. * @param scene the scene the renderer renders in
  53999. */
  54000. constructor(scene: Scene);
  54001. /**
  54002. * Registers the component in a given scene
  54003. */
  54004. register(): void;
  54005. private _evaluateSubMesh;
  54006. private _activeMesh;
  54007. private _prepareRessources;
  54008. private _createIndexBuffer;
  54009. /**
  54010. * Rebuilds the elements related to this component in case of
  54011. * context lost for instance.
  54012. */
  54013. rebuild(): void;
  54014. /**
  54015. * @hidden
  54016. */
  54017. reset(): void;
  54018. /**
  54019. * Render the bounding boxes of a specific rendering group
  54020. * @param renderingGroupId defines the rendering group to render
  54021. */
  54022. render(renderingGroupId: number): void;
  54023. /**
  54024. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54025. * @param mesh Define the mesh to render the occlusion bounding box for
  54026. */
  54027. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54028. /**
  54029. * Dispose and release the resources attached to this renderer.
  54030. */
  54031. dispose(): void;
  54032. }
  54033. }
  54034. declare module "babylonjs/Shaders/depth.fragment" {
  54035. /** @hidden */
  54036. export var depthPixelShader: {
  54037. name: string;
  54038. shader: string;
  54039. };
  54040. }
  54041. declare module "babylonjs/Rendering/depthRenderer" {
  54042. import { Nullable } from "babylonjs/types";
  54043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54044. import { Scene } from "babylonjs/scene";
  54045. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54046. import { Camera } from "babylonjs/Cameras/camera";
  54047. import "babylonjs/Shaders/depth.fragment";
  54048. import "babylonjs/Shaders/depth.vertex";
  54049. /**
  54050. * This represents a depth renderer in Babylon.
  54051. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54052. */
  54053. export class DepthRenderer {
  54054. private _scene;
  54055. private _depthMap;
  54056. private _effect;
  54057. private _cachedDefines;
  54058. private _camera;
  54059. /**
  54060. * Specifiess that the depth renderer will only be used within
  54061. * the camera it is created for.
  54062. * This can help forcing its rendering during the camera processing.
  54063. */
  54064. useOnlyInActiveCamera: boolean;
  54065. /** @hidden */
  54066. static _SceneComponentInitialization: (scene: Scene) => void;
  54067. /**
  54068. * Instantiates a depth renderer
  54069. * @param scene The scene the renderer belongs to
  54070. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54071. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54072. */
  54073. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54074. /**
  54075. * Creates the depth rendering effect and checks if the effect is ready.
  54076. * @param subMesh The submesh to be used to render the depth map of
  54077. * @param useInstances If multiple world instances should be used
  54078. * @returns if the depth renderer is ready to render the depth map
  54079. */
  54080. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54081. /**
  54082. * Gets the texture which the depth map will be written to.
  54083. * @returns The depth map texture
  54084. */
  54085. getDepthMap(): RenderTargetTexture;
  54086. /**
  54087. * Disposes of the depth renderer.
  54088. */
  54089. dispose(): void;
  54090. }
  54091. }
  54092. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54093. import { Nullable } from "babylonjs/types";
  54094. import { Scene } from "babylonjs/scene";
  54095. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54096. import { Camera } from "babylonjs/Cameras/camera";
  54097. import { ISceneComponent } from "babylonjs/sceneComponent";
  54098. module "babylonjs/scene" {
  54099. interface Scene {
  54100. /** @hidden (Backing field) */
  54101. _depthRenderer: {
  54102. [id: string]: DepthRenderer;
  54103. };
  54104. /**
  54105. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54106. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54107. * @returns the created depth renderer
  54108. */
  54109. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54110. /**
  54111. * Disables a depth renderer for a given camera
  54112. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54113. */
  54114. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54115. }
  54116. }
  54117. /**
  54118. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54119. * in several rendering techniques.
  54120. */
  54121. export class DepthRendererSceneComponent implements ISceneComponent {
  54122. /**
  54123. * The component name helpfull to identify the component in the list of scene components.
  54124. */
  54125. readonly name: string;
  54126. /**
  54127. * The scene the component belongs to.
  54128. */
  54129. scene: Scene;
  54130. /**
  54131. * Creates a new instance of the component for the given scene
  54132. * @param scene Defines the scene to register the component in
  54133. */
  54134. constructor(scene: Scene);
  54135. /**
  54136. * Registers the component in a given scene
  54137. */
  54138. register(): void;
  54139. /**
  54140. * Rebuilds the elements related to this component in case of
  54141. * context lost for instance.
  54142. */
  54143. rebuild(): void;
  54144. /**
  54145. * Disposes the component and the associated ressources
  54146. */
  54147. dispose(): void;
  54148. private _gatherRenderTargets;
  54149. private _gatherActiveCameraRenderTargets;
  54150. }
  54151. }
  54152. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54153. import { Nullable } from "babylonjs/types";
  54154. import { Scene } from "babylonjs/scene";
  54155. import { ISceneComponent } from "babylonjs/sceneComponent";
  54156. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54157. module "babylonjs/scene" {
  54158. interface Scene {
  54159. /** @hidden (Backing field) */
  54160. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54161. /**
  54162. * Gets or Sets the current geometry buffer associated to the scene.
  54163. */
  54164. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54165. /**
  54166. * Enables a GeometryBufferRender and associates it with the scene
  54167. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54168. * @returns the GeometryBufferRenderer
  54169. */
  54170. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54171. /**
  54172. * Disables the GeometryBufferRender associated with the scene
  54173. */
  54174. disableGeometryBufferRenderer(): void;
  54175. }
  54176. }
  54177. /**
  54178. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54179. * in several rendering techniques.
  54180. */
  54181. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54182. /**
  54183. * The component name helpful to identify the component in the list of scene components.
  54184. */
  54185. readonly name: string;
  54186. /**
  54187. * The scene the component belongs to.
  54188. */
  54189. scene: Scene;
  54190. /**
  54191. * Creates a new instance of the component for the given scene
  54192. * @param scene Defines the scene to register the component in
  54193. */
  54194. constructor(scene: Scene);
  54195. /**
  54196. * Registers the component in a given scene
  54197. */
  54198. register(): void;
  54199. /**
  54200. * Rebuilds the elements related to this component in case of
  54201. * context lost for instance.
  54202. */
  54203. rebuild(): void;
  54204. /**
  54205. * Disposes the component and the associated ressources
  54206. */
  54207. dispose(): void;
  54208. private _gatherRenderTargets;
  54209. }
  54210. }
  54211. declare module "babylonjs/Shaders/outline.fragment" {
  54212. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54213. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54214. /** @hidden */
  54215. export var outlinePixelShader: {
  54216. name: string;
  54217. shader: string;
  54218. };
  54219. }
  54220. declare module "babylonjs/Shaders/outline.vertex" {
  54221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54223. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54224. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54225. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54226. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54227. /** @hidden */
  54228. export var outlineVertexShader: {
  54229. name: string;
  54230. shader: string;
  54231. };
  54232. }
  54233. declare module "babylonjs/Rendering/outlineRenderer" {
  54234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54235. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54236. import { Scene } from "babylonjs/scene";
  54237. import { ISceneComponent } from "babylonjs/sceneComponent";
  54238. import "babylonjs/Shaders/outline.fragment";
  54239. import "babylonjs/Shaders/outline.vertex";
  54240. module "babylonjs/scene" {
  54241. interface Scene {
  54242. /** @hidden */
  54243. _outlineRenderer: OutlineRenderer;
  54244. /**
  54245. * Gets the outline renderer associated with the scene
  54246. * @returns a OutlineRenderer
  54247. */
  54248. getOutlineRenderer(): OutlineRenderer;
  54249. }
  54250. }
  54251. module "babylonjs/Meshes/abstractMesh" {
  54252. interface AbstractMesh {
  54253. /** @hidden (Backing field) */
  54254. _renderOutline: boolean;
  54255. /**
  54256. * Gets or sets a boolean indicating if the outline must be rendered as well
  54257. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54258. */
  54259. renderOutline: boolean;
  54260. /** @hidden (Backing field) */
  54261. _renderOverlay: boolean;
  54262. /**
  54263. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54264. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54265. */
  54266. renderOverlay: boolean;
  54267. }
  54268. }
  54269. /**
  54270. * This class is responsible to draw bothe outline/overlay of meshes.
  54271. * It should not be used directly but through the available method on mesh.
  54272. */
  54273. export class OutlineRenderer implements ISceneComponent {
  54274. /**
  54275. * The name of the component. Each component must have a unique name.
  54276. */
  54277. name: string;
  54278. /**
  54279. * The scene the component belongs to.
  54280. */
  54281. scene: Scene;
  54282. /**
  54283. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54284. */
  54285. zOffset: number;
  54286. private _engine;
  54287. private _effect;
  54288. private _cachedDefines;
  54289. private _savedDepthWrite;
  54290. /**
  54291. * Instantiates a new outline renderer. (There could be only one per scene).
  54292. * @param scene Defines the scene it belongs to
  54293. */
  54294. constructor(scene: Scene);
  54295. /**
  54296. * Register the component to one instance of a scene.
  54297. */
  54298. register(): void;
  54299. /**
  54300. * Rebuilds the elements related to this component in case of
  54301. * context lost for instance.
  54302. */
  54303. rebuild(): void;
  54304. /**
  54305. * Disposes the component and the associated ressources.
  54306. */
  54307. dispose(): void;
  54308. /**
  54309. * Renders the outline in the canvas.
  54310. * @param subMesh Defines the sumesh to render
  54311. * @param batch Defines the batch of meshes in case of instances
  54312. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54313. */
  54314. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54315. /**
  54316. * Returns whether or not the outline renderer is ready for a given submesh.
  54317. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54318. * @param subMesh Defines the submesh to check readyness for
  54319. * @param useInstances Defines wheter wee are trying to render instances or not
  54320. * @returns true if ready otherwise false
  54321. */
  54322. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54323. private _beforeRenderingMesh;
  54324. private _afterRenderingMesh;
  54325. }
  54326. }
  54327. declare module "babylonjs/Rendering/index" {
  54328. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54329. export * from "babylonjs/Rendering/depthRenderer";
  54330. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54331. export * from "babylonjs/Rendering/edgesRenderer";
  54332. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54333. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54334. export * from "babylonjs/Rendering/outlineRenderer";
  54335. export * from "babylonjs/Rendering/renderingGroup";
  54336. export * from "babylonjs/Rendering/renderingManager";
  54337. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54338. }
  54339. declare module "babylonjs/Sprites/index" {
  54340. export * from "babylonjs/Sprites/sprite";
  54341. export * from "babylonjs/Sprites/spriteManager";
  54342. export * from "babylonjs/Sprites/spriteSceneComponent";
  54343. }
  54344. declare module "babylonjs/Misc/assetsManager" {
  54345. import { Scene } from "babylonjs/scene";
  54346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54347. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54348. import { Skeleton } from "babylonjs/Bones/skeleton";
  54349. import { Observable } from "babylonjs/Misc/observable";
  54350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54351. import { Texture } from "babylonjs/Materials/Textures/texture";
  54352. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54353. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54354. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54355. /**
  54356. * Defines the list of states available for a task inside a AssetsManager
  54357. */
  54358. export enum AssetTaskState {
  54359. /**
  54360. * Initialization
  54361. */
  54362. INIT = 0,
  54363. /**
  54364. * Running
  54365. */
  54366. RUNNING = 1,
  54367. /**
  54368. * Done
  54369. */
  54370. DONE = 2,
  54371. /**
  54372. * Error
  54373. */
  54374. ERROR = 3
  54375. }
  54376. /**
  54377. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54378. */
  54379. export abstract class AbstractAssetTask {
  54380. /**
  54381. * Task name
  54382. */ name: string;
  54383. /**
  54384. * Callback called when the task is successful
  54385. */
  54386. onSuccess: (task: any) => void;
  54387. /**
  54388. * Callback called when the task is not successful
  54389. */
  54390. onError: (task: any, message?: string, exception?: any) => void;
  54391. /**
  54392. * Creates a new AssetsManager
  54393. * @param name defines the name of the task
  54394. */
  54395. constructor(
  54396. /**
  54397. * Task name
  54398. */ name: string);
  54399. private _isCompleted;
  54400. private _taskState;
  54401. private _errorObject;
  54402. /**
  54403. * Get if the task is completed
  54404. */
  54405. readonly isCompleted: boolean;
  54406. /**
  54407. * Gets the current state of the task
  54408. */
  54409. readonly taskState: AssetTaskState;
  54410. /**
  54411. * Gets the current error object (if task is in error)
  54412. */
  54413. readonly errorObject: {
  54414. message?: string;
  54415. exception?: any;
  54416. };
  54417. /**
  54418. * Internal only
  54419. * @hidden
  54420. */
  54421. _setErrorObject(message?: string, exception?: any): void;
  54422. /**
  54423. * Execute the current task
  54424. * @param scene defines the scene where you want your assets to be loaded
  54425. * @param onSuccess is a callback called when the task is successfully executed
  54426. * @param onError is a callback called if an error occurs
  54427. */
  54428. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54429. /**
  54430. * Execute the current task
  54431. * @param scene defines the scene where you want your assets to be loaded
  54432. * @param onSuccess is a callback called when the task is successfully executed
  54433. * @param onError is a callback called if an error occurs
  54434. */
  54435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54436. /**
  54437. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54438. * This can be used with failed tasks that have the reason for failure fixed.
  54439. */
  54440. reset(): void;
  54441. private onErrorCallback;
  54442. private onDoneCallback;
  54443. }
  54444. /**
  54445. * Define the interface used by progress events raised during assets loading
  54446. */
  54447. export interface IAssetsProgressEvent {
  54448. /**
  54449. * Defines the number of remaining tasks to process
  54450. */
  54451. remainingCount: number;
  54452. /**
  54453. * Defines the total number of tasks
  54454. */
  54455. totalCount: number;
  54456. /**
  54457. * Defines the task that was just processed
  54458. */
  54459. task: AbstractAssetTask;
  54460. }
  54461. /**
  54462. * Class used to share progress information about assets loading
  54463. */
  54464. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54465. /**
  54466. * Defines the number of remaining tasks to process
  54467. */
  54468. remainingCount: number;
  54469. /**
  54470. * Defines the total number of tasks
  54471. */
  54472. totalCount: number;
  54473. /**
  54474. * Defines the task that was just processed
  54475. */
  54476. task: AbstractAssetTask;
  54477. /**
  54478. * Creates a AssetsProgressEvent
  54479. * @param remainingCount defines the number of remaining tasks to process
  54480. * @param totalCount defines the total number of tasks
  54481. * @param task defines the task that was just processed
  54482. */
  54483. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54484. }
  54485. /**
  54486. * Define a task used by AssetsManager to load meshes
  54487. */
  54488. export class MeshAssetTask extends AbstractAssetTask {
  54489. /**
  54490. * Defines the name of the task
  54491. */
  54492. name: string;
  54493. /**
  54494. * Defines the list of mesh's names you want to load
  54495. */
  54496. meshesNames: any;
  54497. /**
  54498. * Defines the root url to use as a base to load your meshes and associated resources
  54499. */
  54500. rootUrl: string;
  54501. /**
  54502. * Defines the filename of the scene to load from
  54503. */
  54504. sceneFilename: string;
  54505. /**
  54506. * Gets the list of loaded meshes
  54507. */
  54508. loadedMeshes: Array<AbstractMesh>;
  54509. /**
  54510. * Gets the list of loaded particle systems
  54511. */
  54512. loadedParticleSystems: Array<IParticleSystem>;
  54513. /**
  54514. * Gets the list of loaded skeletons
  54515. */
  54516. loadedSkeletons: Array<Skeleton>;
  54517. /**
  54518. * Gets the list of loaded animation groups
  54519. */
  54520. loadedAnimationGroups: Array<AnimationGroup>;
  54521. /**
  54522. * Callback called when the task is successful
  54523. */
  54524. onSuccess: (task: MeshAssetTask) => void;
  54525. /**
  54526. * Callback called when the task is successful
  54527. */
  54528. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54529. /**
  54530. * Creates a new MeshAssetTask
  54531. * @param name defines the name of the task
  54532. * @param meshesNames defines the list of mesh's names you want to load
  54533. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54534. * @param sceneFilename defines the filename of the scene to load from
  54535. */
  54536. constructor(
  54537. /**
  54538. * Defines the name of the task
  54539. */
  54540. name: string,
  54541. /**
  54542. * Defines the list of mesh's names you want to load
  54543. */
  54544. meshesNames: any,
  54545. /**
  54546. * Defines the root url to use as a base to load your meshes and associated resources
  54547. */
  54548. rootUrl: string,
  54549. /**
  54550. * Defines the filename of the scene to load from
  54551. */
  54552. sceneFilename: string);
  54553. /**
  54554. * Execute the current task
  54555. * @param scene defines the scene where you want your assets to be loaded
  54556. * @param onSuccess is a callback called when the task is successfully executed
  54557. * @param onError is a callback called if an error occurs
  54558. */
  54559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54560. }
  54561. /**
  54562. * Define a task used by AssetsManager to load text content
  54563. */
  54564. export class TextFileAssetTask extends AbstractAssetTask {
  54565. /**
  54566. * Defines the name of the task
  54567. */
  54568. name: string;
  54569. /**
  54570. * Defines the location of the file to load
  54571. */
  54572. url: string;
  54573. /**
  54574. * Gets the loaded text string
  54575. */
  54576. text: string;
  54577. /**
  54578. * Callback called when the task is successful
  54579. */
  54580. onSuccess: (task: TextFileAssetTask) => void;
  54581. /**
  54582. * Callback called when the task is successful
  54583. */
  54584. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54585. /**
  54586. * Creates a new TextFileAssetTask object
  54587. * @param name defines the name of the task
  54588. * @param url defines the location of the file to load
  54589. */
  54590. constructor(
  54591. /**
  54592. * Defines the name of the task
  54593. */
  54594. name: string,
  54595. /**
  54596. * Defines the location of the file to load
  54597. */
  54598. url: string);
  54599. /**
  54600. * Execute the current task
  54601. * @param scene defines the scene where you want your assets to be loaded
  54602. * @param onSuccess is a callback called when the task is successfully executed
  54603. * @param onError is a callback called if an error occurs
  54604. */
  54605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54606. }
  54607. /**
  54608. * Define a task used by AssetsManager to load binary data
  54609. */
  54610. export class BinaryFileAssetTask extends AbstractAssetTask {
  54611. /**
  54612. * Defines the name of the task
  54613. */
  54614. name: string;
  54615. /**
  54616. * Defines the location of the file to load
  54617. */
  54618. url: string;
  54619. /**
  54620. * Gets the lodaded data (as an array buffer)
  54621. */
  54622. data: ArrayBuffer;
  54623. /**
  54624. * Callback called when the task is successful
  54625. */
  54626. onSuccess: (task: BinaryFileAssetTask) => void;
  54627. /**
  54628. * Callback called when the task is successful
  54629. */
  54630. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54631. /**
  54632. * Creates a new BinaryFileAssetTask object
  54633. * @param name defines the name of the new task
  54634. * @param url defines the location of the file to load
  54635. */
  54636. constructor(
  54637. /**
  54638. * Defines the name of the task
  54639. */
  54640. name: string,
  54641. /**
  54642. * Defines the location of the file to load
  54643. */
  54644. url: string);
  54645. /**
  54646. * Execute the current task
  54647. * @param scene defines the scene where you want your assets to be loaded
  54648. * @param onSuccess is a callback called when the task is successfully executed
  54649. * @param onError is a callback called if an error occurs
  54650. */
  54651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54652. }
  54653. /**
  54654. * Define a task used by AssetsManager to load images
  54655. */
  54656. export class ImageAssetTask extends AbstractAssetTask {
  54657. /**
  54658. * Defines the name of the task
  54659. */
  54660. name: string;
  54661. /**
  54662. * Defines the location of the image to load
  54663. */
  54664. url: string;
  54665. /**
  54666. * Gets the loaded images
  54667. */
  54668. image: HTMLImageElement;
  54669. /**
  54670. * Callback called when the task is successful
  54671. */
  54672. onSuccess: (task: ImageAssetTask) => void;
  54673. /**
  54674. * Callback called when the task is successful
  54675. */
  54676. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54677. /**
  54678. * Creates a new ImageAssetTask
  54679. * @param name defines the name of the task
  54680. * @param url defines the location of the image to load
  54681. */
  54682. constructor(
  54683. /**
  54684. * Defines the name of the task
  54685. */
  54686. name: string,
  54687. /**
  54688. * Defines the location of the image to load
  54689. */
  54690. url: string);
  54691. /**
  54692. * Execute the current task
  54693. * @param scene defines the scene where you want your assets to be loaded
  54694. * @param onSuccess is a callback called when the task is successfully executed
  54695. * @param onError is a callback called if an error occurs
  54696. */
  54697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54698. }
  54699. /**
  54700. * Defines the interface used by texture loading tasks
  54701. */
  54702. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54703. /**
  54704. * Gets the loaded texture
  54705. */
  54706. texture: TEX;
  54707. }
  54708. /**
  54709. * Define a task used by AssetsManager to load 2D textures
  54710. */
  54711. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54712. /**
  54713. * Defines the name of the task
  54714. */
  54715. name: string;
  54716. /**
  54717. * Defines the location of the file to load
  54718. */
  54719. url: string;
  54720. /**
  54721. * Defines if mipmap should not be generated (default is false)
  54722. */
  54723. noMipmap?: boolean | undefined;
  54724. /**
  54725. * Defines if texture must be inverted on Y axis (default is false)
  54726. */
  54727. invertY?: boolean | undefined;
  54728. /**
  54729. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54730. */
  54731. samplingMode: number;
  54732. /**
  54733. * Gets the loaded texture
  54734. */
  54735. texture: Texture;
  54736. /**
  54737. * Callback called when the task is successful
  54738. */
  54739. onSuccess: (task: TextureAssetTask) => void;
  54740. /**
  54741. * Callback called when the task is successful
  54742. */
  54743. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54744. /**
  54745. * Creates a new TextureAssetTask object
  54746. * @param name defines the name of the task
  54747. * @param url defines the location of the file to load
  54748. * @param noMipmap defines if mipmap should not be generated (default is false)
  54749. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54750. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54751. */
  54752. constructor(
  54753. /**
  54754. * Defines the name of the task
  54755. */
  54756. name: string,
  54757. /**
  54758. * Defines the location of the file to load
  54759. */
  54760. url: string,
  54761. /**
  54762. * Defines if mipmap should not be generated (default is false)
  54763. */
  54764. noMipmap?: boolean | undefined,
  54765. /**
  54766. * Defines if texture must be inverted on Y axis (default is false)
  54767. */
  54768. invertY?: boolean | undefined,
  54769. /**
  54770. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54771. */
  54772. samplingMode?: number);
  54773. /**
  54774. * Execute the current task
  54775. * @param scene defines the scene where you want your assets to be loaded
  54776. * @param onSuccess is a callback called when the task is successfully executed
  54777. * @param onError is a callback called if an error occurs
  54778. */
  54779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54780. }
  54781. /**
  54782. * Define a task used by AssetsManager to load cube textures
  54783. */
  54784. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54785. /**
  54786. * Defines the name of the task
  54787. */
  54788. name: string;
  54789. /**
  54790. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54791. */
  54792. url: string;
  54793. /**
  54794. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54795. */
  54796. extensions?: string[] | undefined;
  54797. /**
  54798. * Defines if mipmaps should not be generated (default is false)
  54799. */
  54800. noMipmap?: boolean | undefined;
  54801. /**
  54802. * Defines the explicit list of files (undefined by default)
  54803. */
  54804. files?: string[] | undefined;
  54805. /**
  54806. * Gets the loaded texture
  54807. */
  54808. texture: CubeTexture;
  54809. /**
  54810. * Callback called when the task is successful
  54811. */
  54812. onSuccess: (task: CubeTextureAssetTask) => void;
  54813. /**
  54814. * Callback called when the task is successful
  54815. */
  54816. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54817. /**
  54818. * Creates a new CubeTextureAssetTask
  54819. * @param name defines the name of the task
  54820. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54821. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54822. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54823. * @param files defines the explicit list of files (undefined by default)
  54824. */
  54825. constructor(
  54826. /**
  54827. * Defines the name of the task
  54828. */
  54829. name: string,
  54830. /**
  54831. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54832. */
  54833. url: string,
  54834. /**
  54835. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54836. */
  54837. extensions?: string[] | undefined,
  54838. /**
  54839. * Defines if mipmaps should not be generated (default is false)
  54840. */
  54841. noMipmap?: boolean | undefined,
  54842. /**
  54843. * Defines the explicit list of files (undefined by default)
  54844. */
  54845. files?: string[] | undefined);
  54846. /**
  54847. * Execute the current task
  54848. * @param scene defines the scene where you want your assets to be loaded
  54849. * @param onSuccess is a callback called when the task is successfully executed
  54850. * @param onError is a callback called if an error occurs
  54851. */
  54852. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54853. }
  54854. /**
  54855. * Define a task used by AssetsManager to load HDR cube textures
  54856. */
  54857. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54858. /**
  54859. * Defines the name of the task
  54860. */
  54861. name: string;
  54862. /**
  54863. * Defines the location of the file to load
  54864. */
  54865. url: string;
  54866. /**
  54867. * Defines the desired size (the more it increases the longer the generation will be)
  54868. */
  54869. size: number;
  54870. /**
  54871. * Defines if mipmaps should not be generated (default is false)
  54872. */
  54873. noMipmap: boolean;
  54874. /**
  54875. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54876. */
  54877. generateHarmonics: boolean;
  54878. /**
  54879. * 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)
  54880. */
  54881. gammaSpace: boolean;
  54882. /**
  54883. * Internal Use Only
  54884. */
  54885. reserved: boolean;
  54886. /**
  54887. * Gets the loaded texture
  54888. */
  54889. texture: HDRCubeTexture;
  54890. /**
  54891. * Callback called when the task is successful
  54892. */
  54893. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54894. /**
  54895. * Callback called when the task is successful
  54896. */
  54897. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54898. /**
  54899. * Creates a new HDRCubeTextureAssetTask object
  54900. * @param name defines the name of the task
  54901. * @param url defines the location of the file to load
  54902. * @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.
  54903. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54904. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54905. * @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)
  54906. * @param reserved Internal use only
  54907. */
  54908. constructor(
  54909. /**
  54910. * Defines the name of the task
  54911. */
  54912. name: string,
  54913. /**
  54914. * Defines the location of the file to load
  54915. */
  54916. url: string,
  54917. /**
  54918. * Defines the desired size (the more it increases the longer the generation will be)
  54919. */
  54920. size: number,
  54921. /**
  54922. * Defines if mipmaps should not be generated (default is false)
  54923. */
  54924. noMipmap?: boolean,
  54925. /**
  54926. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54927. */
  54928. generateHarmonics?: boolean,
  54929. /**
  54930. * 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)
  54931. */
  54932. gammaSpace?: boolean,
  54933. /**
  54934. * Internal Use Only
  54935. */
  54936. reserved?: boolean);
  54937. /**
  54938. * Execute the current task
  54939. * @param scene defines the scene where you want your assets to be loaded
  54940. * @param onSuccess is a callback called when the task is successfully executed
  54941. * @param onError is a callback called if an error occurs
  54942. */
  54943. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54944. }
  54945. /**
  54946. * This class can be used to easily import assets into a scene
  54947. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54948. */
  54949. export class AssetsManager {
  54950. private _scene;
  54951. private _isLoading;
  54952. protected _tasks: AbstractAssetTask[];
  54953. protected _waitingTasksCount: number;
  54954. protected _totalTasksCount: number;
  54955. /**
  54956. * Callback called when all tasks are processed
  54957. */
  54958. onFinish: (tasks: AbstractAssetTask[]) => void;
  54959. /**
  54960. * Callback called when a task is successful
  54961. */
  54962. onTaskSuccess: (task: AbstractAssetTask) => void;
  54963. /**
  54964. * Callback called when a task had an error
  54965. */
  54966. onTaskError: (task: AbstractAssetTask) => void;
  54967. /**
  54968. * Callback called when a task is done (whatever the result is)
  54969. */
  54970. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54971. /**
  54972. * Observable called when all tasks are processed
  54973. */
  54974. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54975. /**
  54976. * Observable called when a task had an error
  54977. */
  54978. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54979. /**
  54980. * Observable called when a task is successful
  54981. */
  54982. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54983. /**
  54984. * Observable called when a task is done (whatever the result is)
  54985. */
  54986. onProgressObservable: Observable<IAssetsProgressEvent>;
  54987. /**
  54988. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54990. */
  54991. useDefaultLoadingScreen: boolean;
  54992. /**
  54993. * Creates a new AssetsManager
  54994. * @param scene defines the scene to work on
  54995. */
  54996. constructor(scene: Scene);
  54997. /**
  54998. * Add a MeshAssetTask to the list of active tasks
  54999. * @param taskName defines the name of the new task
  55000. * @param meshesNames defines the name of meshes to load
  55001. * @param rootUrl defines the root url to use to locate files
  55002. * @param sceneFilename defines the filename of the scene file
  55003. * @returns a new MeshAssetTask object
  55004. */
  55005. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55006. /**
  55007. * Add a TextFileAssetTask to the list of active tasks
  55008. * @param taskName defines the name of the new task
  55009. * @param url defines the url of the file to load
  55010. * @returns a new TextFileAssetTask object
  55011. */
  55012. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55013. /**
  55014. * Add a BinaryFileAssetTask to the list of active tasks
  55015. * @param taskName defines the name of the new task
  55016. * @param url defines the url of the file to load
  55017. * @returns a new BinaryFileAssetTask object
  55018. */
  55019. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55020. /**
  55021. * Add a ImageAssetTask to the list of active tasks
  55022. * @param taskName defines the name of the new task
  55023. * @param url defines the url of the file to load
  55024. * @returns a new ImageAssetTask object
  55025. */
  55026. addImageTask(taskName: string, url: string): ImageAssetTask;
  55027. /**
  55028. * Add a TextureAssetTask to the list of active tasks
  55029. * @param taskName defines the name of the new task
  55030. * @param url defines the url of the file to load
  55031. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55032. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55033. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55034. * @returns a new TextureAssetTask object
  55035. */
  55036. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55037. /**
  55038. * Add a CubeTextureAssetTask to the list of active tasks
  55039. * @param taskName defines the name of the new task
  55040. * @param url defines the url of the file to load
  55041. * @param extensions defines the extension to use to load the cube map (can be null)
  55042. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55043. * @param files defines the list of files to load (can be null)
  55044. * @returns a new CubeTextureAssetTask object
  55045. */
  55046. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55047. /**
  55048. *
  55049. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55050. * @param taskName defines the name of the new task
  55051. * @param url defines the url of the file to load
  55052. * @param size defines the size you want for the cubemap (can be null)
  55053. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55054. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55055. * @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)
  55056. * @param reserved Internal use only
  55057. * @returns a new HDRCubeTextureAssetTask object
  55058. */
  55059. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55060. /**
  55061. * Remove a task from the assets manager.
  55062. * @param task the task to remove
  55063. */
  55064. removeTask(task: AbstractAssetTask): void;
  55065. private _decreaseWaitingTasksCount;
  55066. private _runTask;
  55067. /**
  55068. * Reset the AssetsManager and remove all tasks
  55069. * @return the current instance of the AssetsManager
  55070. */
  55071. reset(): AssetsManager;
  55072. /**
  55073. * Start the loading process
  55074. * @return the current instance of the AssetsManager
  55075. */
  55076. load(): AssetsManager;
  55077. }
  55078. }
  55079. declare module "babylonjs/Misc/deferred" {
  55080. /**
  55081. * Wrapper class for promise with external resolve and reject.
  55082. */
  55083. export class Deferred<T> {
  55084. /**
  55085. * The promise associated with this deferred object.
  55086. */
  55087. readonly promise: Promise<T>;
  55088. private _resolve;
  55089. private _reject;
  55090. /**
  55091. * The resolve method of the promise associated with this deferred object.
  55092. */
  55093. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55094. /**
  55095. * The reject method of the promise associated with this deferred object.
  55096. */
  55097. readonly reject: (reason?: any) => void;
  55098. /**
  55099. * Constructor for this deferred object.
  55100. */
  55101. constructor();
  55102. }
  55103. }
  55104. declare module "babylonjs/Misc/filesInput" {
  55105. import { Engine } from "babylonjs/Engines/engine";
  55106. import { Scene } from "babylonjs/scene";
  55107. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55108. /**
  55109. * Class used to help managing file picking and drag'n'drop
  55110. */
  55111. export class FilesInput {
  55112. /**
  55113. * List of files ready to be loaded
  55114. */
  55115. static readonly FilesToLoad: {
  55116. [key: string]: File;
  55117. };
  55118. /**
  55119. * Callback called when a file is processed
  55120. */
  55121. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55122. private _engine;
  55123. private _currentScene;
  55124. private _sceneLoadedCallback;
  55125. private _progressCallback;
  55126. private _additionalRenderLoopLogicCallback;
  55127. private _textureLoadingCallback;
  55128. private _startingProcessingFilesCallback;
  55129. private _onReloadCallback;
  55130. private _errorCallback;
  55131. private _elementToMonitor;
  55132. private _sceneFileToLoad;
  55133. private _filesToLoad;
  55134. /**
  55135. * Creates a new FilesInput
  55136. * @param engine defines the rendering engine
  55137. * @param scene defines the hosting scene
  55138. * @param sceneLoadedCallback callback called when scene is loaded
  55139. * @param progressCallback callback called to track progress
  55140. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55141. * @param textureLoadingCallback callback called when a texture is loading
  55142. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55143. * @param onReloadCallback callback called when a reload is requested
  55144. * @param errorCallback callback call if an error occurs
  55145. */
  55146. 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);
  55147. private _dragEnterHandler;
  55148. private _dragOverHandler;
  55149. private _dropHandler;
  55150. /**
  55151. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55152. * @param elementToMonitor defines the DOM element to track
  55153. */
  55154. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55155. /**
  55156. * Release all associated resources
  55157. */
  55158. dispose(): void;
  55159. private renderFunction;
  55160. private drag;
  55161. private drop;
  55162. private _traverseFolder;
  55163. private _processFiles;
  55164. /**
  55165. * Load files from a drop event
  55166. * @param event defines the drop event to use as source
  55167. */
  55168. loadFiles(event: any): void;
  55169. private _processReload;
  55170. /**
  55171. * Reload the current scene from the loaded files
  55172. */
  55173. reload(): void;
  55174. }
  55175. }
  55176. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55177. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55178. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55179. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55180. }
  55181. declare module "babylonjs/Misc/sceneOptimizer" {
  55182. import { Scene, IDisposable } from "babylonjs/scene";
  55183. import { Observable } from "babylonjs/Misc/observable";
  55184. /**
  55185. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55187. */
  55188. export class SceneOptimization {
  55189. /**
  55190. * Defines the priority of this optimization (0 by default which means first in the list)
  55191. */
  55192. priority: number;
  55193. /**
  55194. * Gets a string describing the action executed by the current optimization
  55195. * @returns description string
  55196. */
  55197. getDescription(): string;
  55198. /**
  55199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55200. * @param scene defines the current scene where to apply this optimization
  55201. * @param optimizer defines the current optimizer
  55202. * @returns true if everything that can be done was applied
  55203. */
  55204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55205. /**
  55206. * Creates the SceneOptimization object
  55207. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55208. * @param desc defines the description associated with the optimization
  55209. */
  55210. constructor(
  55211. /**
  55212. * Defines the priority of this optimization (0 by default which means first in the list)
  55213. */
  55214. priority?: number);
  55215. }
  55216. /**
  55217. * Defines an optimization used to reduce the size of render target textures
  55218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55219. */
  55220. export class TextureOptimization extends SceneOptimization {
  55221. /**
  55222. * Defines the priority of this optimization (0 by default which means first in the list)
  55223. */
  55224. priority: number;
  55225. /**
  55226. * 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
  55227. */
  55228. maximumSize: number;
  55229. /**
  55230. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55231. */
  55232. step: number;
  55233. /**
  55234. * Gets a string describing the action executed by the current optimization
  55235. * @returns description string
  55236. */
  55237. getDescription(): string;
  55238. /**
  55239. * Creates the TextureOptimization object
  55240. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55241. * @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
  55242. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55243. */
  55244. constructor(
  55245. /**
  55246. * Defines the priority of this optimization (0 by default which means first in the list)
  55247. */
  55248. priority?: number,
  55249. /**
  55250. * 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
  55251. */
  55252. maximumSize?: number,
  55253. /**
  55254. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55255. */
  55256. step?: number);
  55257. /**
  55258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55259. * @param scene defines the current scene where to apply this optimization
  55260. * @param optimizer defines the current optimizer
  55261. * @returns true if everything that can be done was applied
  55262. */
  55263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55264. }
  55265. /**
  55266. * Defines an optimization used to increase or decrease the rendering resolution
  55267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55268. */
  55269. export class HardwareScalingOptimization extends SceneOptimization {
  55270. /**
  55271. * Defines the priority of this optimization (0 by default which means first in the list)
  55272. */
  55273. priority: number;
  55274. /**
  55275. * Defines the maximum scale to use (2 by default)
  55276. */
  55277. maximumScale: number;
  55278. /**
  55279. * Defines the step to use between two passes (0.5 by default)
  55280. */
  55281. step: number;
  55282. private _currentScale;
  55283. private _directionOffset;
  55284. /**
  55285. * Gets a string describing the action executed by the current optimization
  55286. * @return description string
  55287. */
  55288. getDescription(): string;
  55289. /**
  55290. * Creates the HardwareScalingOptimization object
  55291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55292. * @param maximumScale defines the maximum scale to use (2 by default)
  55293. * @param step defines the step to use between two passes (0.5 by default)
  55294. */
  55295. constructor(
  55296. /**
  55297. * Defines the priority of this optimization (0 by default which means first in the list)
  55298. */
  55299. priority?: number,
  55300. /**
  55301. * Defines the maximum scale to use (2 by default)
  55302. */
  55303. maximumScale?: number,
  55304. /**
  55305. * Defines the step to use between two passes (0.5 by default)
  55306. */
  55307. step?: number);
  55308. /**
  55309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55310. * @param scene defines the current scene where to apply this optimization
  55311. * @param optimizer defines the current optimizer
  55312. * @returns true if everything that can be done was applied
  55313. */
  55314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55315. }
  55316. /**
  55317. * Defines an optimization used to remove shadows
  55318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55319. */
  55320. export class ShadowsOptimization extends SceneOptimization {
  55321. /**
  55322. * Gets a string describing the action executed by the current optimization
  55323. * @return description string
  55324. */
  55325. getDescription(): string;
  55326. /**
  55327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55328. * @param scene defines the current scene where to apply this optimization
  55329. * @param optimizer defines the current optimizer
  55330. * @returns true if everything that can be done was applied
  55331. */
  55332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55333. }
  55334. /**
  55335. * Defines an optimization used to turn post-processes off
  55336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55337. */
  55338. export class PostProcessesOptimization extends SceneOptimization {
  55339. /**
  55340. * Gets a string describing the action executed by the current optimization
  55341. * @return description string
  55342. */
  55343. getDescription(): string;
  55344. /**
  55345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55346. * @param scene defines the current scene where to apply this optimization
  55347. * @param optimizer defines the current optimizer
  55348. * @returns true if everything that can be done was applied
  55349. */
  55350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55351. }
  55352. /**
  55353. * Defines an optimization used to turn lens flares off
  55354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55355. */
  55356. export class LensFlaresOptimization extends SceneOptimization {
  55357. /**
  55358. * Gets a string describing the action executed by the current optimization
  55359. * @return description string
  55360. */
  55361. getDescription(): string;
  55362. /**
  55363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55364. * @param scene defines the current scene where to apply this optimization
  55365. * @param optimizer defines the current optimizer
  55366. * @returns true if everything that can be done was applied
  55367. */
  55368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55369. }
  55370. /**
  55371. * Defines an optimization based on user defined callback.
  55372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55373. */
  55374. export class CustomOptimization extends SceneOptimization {
  55375. /**
  55376. * Callback called to apply the custom optimization.
  55377. */
  55378. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55379. /**
  55380. * Callback called to get custom description
  55381. */
  55382. onGetDescription: () => string;
  55383. /**
  55384. * Gets a string describing the action executed by the current optimization
  55385. * @returns description string
  55386. */
  55387. getDescription(): string;
  55388. /**
  55389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55390. * @param scene defines the current scene where to apply this optimization
  55391. * @param optimizer defines the current optimizer
  55392. * @returns true if everything that can be done was applied
  55393. */
  55394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55395. }
  55396. /**
  55397. * Defines an optimization used to turn particles off
  55398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55399. */
  55400. export class ParticlesOptimization extends SceneOptimization {
  55401. /**
  55402. * Gets a string describing the action executed by the current optimization
  55403. * @return description string
  55404. */
  55405. getDescription(): string;
  55406. /**
  55407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55408. * @param scene defines the current scene where to apply this optimization
  55409. * @param optimizer defines the current optimizer
  55410. * @returns true if everything that can be done was applied
  55411. */
  55412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55413. }
  55414. /**
  55415. * Defines an optimization used to turn render targets off
  55416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55417. */
  55418. export class RenderTargetsOptimization extends SceneOptimization {
  55419. /**
  55420. * Gets a string describing the action executed by the current optimization
  55421. * @return description string
  55422. */
  55423. getDescription(): string;
  55424. /**
  55425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55426. * @param scene defines the current scene where to apply this optimization
  55427. * @param optimizer defines the current optimizer
  55428. * @returns true if everything that can be done was applied
  55429. */
  55430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55431. }
  55432. /**
  55433. * Defines an optimization used to merge meshes with compatible materials
  55434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55435. */
  55436. export class MergeMeshesOptimization extends SceneOptimization {
  55437. private static _UpdateSelectionTree;
  55438. /**
  55439. * Gets or sets a boolean which defines if optimization octree has to be updated
  55440. */
  55441. /**
  55442. * Gets or sets a boolean which defines if optimization octree has to be updated
  55443. */
  55444. static UpdateSelectionTree: boolean;
  55445. /**
  55446. * Gets a string describing the action executed by the current optimization
  55447. * @return description string
  55448. */
  55449. getDescription(): string;
  55450. private _canBeMerged;
  55451. /**
  55452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55453. * @param scene defines the current scene where to apply this optimization
  55454. * @param optimizer defines the current optimizer
  55455. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55456. * @returns true if everything that can be done was applied
  55457. */
  55458. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55459. }
  55460. /**
  55461. * Defines a list of options used by SceneOptimizer
  55462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55463. */
  55464. export class SceneOptimizerOptions {
  55465. /**
  55466. * Defines the target frame rate to reach (60 by default)
  55467. */
  55468. targetFrameRate: number;
  55469. /**
  55470. * Defines the interval between two checkes (2000ms by default)
  55471. */
  55472. trackerDuration: number;
  55473. /**
  55474. * Gets the list of optimizations to apply
  55475. */
  55476. optimizations: SceneOptimization[];
  55477. /**
  55478. * Creates a new list of options used by SceneOptimizer
  55479. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55480. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55481. */
  55482. constructor(
  55483. /**
  55484. * Defines the target frame rate to reach (60 by default)
  55485. */
  55486. targetFrameRate?: number,
  55487. /**
  55488. * Defines the interval between two checkes (2000ms by default)
  55489. */
  55490. trackerDuration?: number);
  55491. /**
  55492. * Add a new optimization
  55493. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55494. * @returns the current SceneOptimizerOptions
  55495. */
  55496. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55497. /**
  55498. * Add a new custom optimization
  55499. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55500. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55501. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55502. * @returns the current SceneOptimizerOptions
  55503. */
  55504. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55505. /**
  55506. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55507. * @param targetFrameRate defines the target frame rate (60 by default)
  55508. * @returns a SceneOptimizerOptions object
  55509. */
  55510. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55511. /**
  55512. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55513. * @param targetFrameRate defines the target frame rate (60 by default)
  55514. * @returns a SceneOptimizerOptions object
  55515. */
  55516. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55517. /**
  55518. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55519. * @param targetFrameRate defines the target frame rate (60 by default)
  55520. * @returns a SceneOptimizerOptions object
  55521. */
  55522. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55523. }
  55524. /**
  55525. * Class used to run optimizations in order to reach a target frame rate
  55526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55527. */
  55528. export class SceneOptimizer implements IDisposable {
  55529. private _isRunning;
  55530. private _options;
  55531. private _scene;
  55532. private _currentPriorityLevel;
  55533. private _targetFrameRate;
  55534. private _trackerDuration;
  55535. private _currentFrameRate;
  55536. private _sceneDisposeObserver;
  55537. private _improvementMode;
  55538. /**
  55539. * Defines an observable called when the optimizer reaches the target frame rate
  55540. */
  55541. onSuccessObservable: Observable<SceneOptimizer>;
  55542. /**
  55543. * Defines an observable called when the optimizer enables an optimization
  55544. */
  55545. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55546. /**
  55547. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55548. */
  55549. onFailureObservable: Observable<SceneOptimizer>;
  55550. /**
  55551. * Gets a boolean indicating if the optimizer is in improvement mode
  55552. */
  55553. readonly isInImprovementMode: boolean;
  55554. /**
  55555. * Gets the current priority level (0 at start)
  55556. */
  55557. readonly currentPriorityLevel: number;
  55558. /**
  55559. * Gets the current frame rate checked by the SceneOptimizer
  55560. */
  55561. readonly currentFrameRate: number;
  55562. /**
  55563. * Gets or sets the current target frame rate (60 by default)
  55564. */
  55565. /**
  55566. * Gets or sets the current target frame rate (60 by default)
  55567. */
  55568. targetFrameRate: number;
  55569. /**
  55570. * Gets or sets the current interval between two checks (every 2000ms by default)
  55571. */
  55572. /**
  55573. * Gets or sets the current interval between two checks (every 2000ms by default)
  55574. */
  55575. trackerDuration: number;
  55576. /**
  55577. * Gets the list of active optimizations
  55578. */
  55579. readonly optimizations: SceneOptimization[];
  55580. /**
  55581. * Creates a new SceneOptimizer
  55582. * @param scene defines the scene to work on
  55583. * @param options defines the options to use with the SceneOptimizer
  55584. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55585. * @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)
  55586. */
  55587. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55588. /**
  55589. * Stops the current optimizer
  55590. */
  55591. stop(): void;
  55592. /**
  55593. * Reset the optimizer to initial step (current priority level = 0)
  55594. */
  55595. reset(): void;
  55596. /**
  55597. * Start the optimizer. By default it will try to reach a specific framerate
  55598. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55599. */
  55600. start(): void;
  55601. private _checkCurrentState;
  55602. /**
  55603. * Release all resources
  55604. */
  55605. dispose(): void;
  55606. /**
  55607. * Helper function to create a SceneOptimizer with one single line of code
  55608. * @param scene defines the scene to work on
  55609. * @param options defines the options to use with the SceneOptimizer
  55610. * @param onSuccess defines a callback to call on success
  55611. * @param onFailure defines a callback to call on failure
  55612. * @returns the new SceneOptimizer object
  55613. */
  55614. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55615. }
  55616. }
  55617. declare module "babylonjs/Misc/sceneSerializer" {
  55618. import { Scene } from "babylonjs/scene";
  55619. /**
  55620. * Class used to serialize a scene into a string
  55621. */
  55622. export class SceneSerializer {
  55623. /**
  55624. * Clear cache used by a previous serialization
  55625. */
  55626. static ClearCache(): void;
  55627. /**
  55628. * Serialize a scene into a JSON compatible object
  55629. * @param scene defines the scene to serialize
  55630. * @returns a JSON compatible object
  55631. */
  55632. static Serialize(scene: Scene): any;
  55633. /**
  55634. * Serialize a mesh into a JSON compatible object
  55635. * @param toSerialize defines the mesh to serialize
  55636. * @param withParents defines if parents must be serialized as well
  55637. * @param withChildren defines if children must be serialized as well
  55638. * @returns a JSON compatible object
  55639. */
  55640. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55641. }
  55642. }
  55643. declare module "babylonjs/Misc/videoRecorder" {
  55644. import { Nullable } from "babylonjs/types";
  55645. import { Engine } from "babylonjs/Engines/engine";
  55646. /**
  55647. * This represents the different options avilable for the video capture.
  55648. */
  55649. export interface VideoRecorderOptions {
  55650. /** Defines the mime type of the video */
  55651. mimeType: string;
  55652. /** Defines the video the video should be recorded at */
  55653. fps: number;
  55654. /** Defines the chunk size for the recording data */
  55655. recordChunckSize: number;
  55656. }
  55657. /**
  55658. * This can helps recording videos from BabylonJS.
  55659. * This is based on the available WebRTC functionalities of the browser.
  55660. *
  55661. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55662. */
  55663. export class VideoRecorder {
  55664. private static readonly _defaultOptions;
  55665. /**
  55666. * Returns wehther or not the VideoRecorder is available in your browser.
  55667. * @param engine Defines the Babylon Engine to check the support for
  55668. * @returns true if supported otherwise false
  55669. */
  55670. static IsSupported(engine: Engine): boolean;
  55671. private readonly _options;
  55672. private _canvas;
  55673. private _mediaRecorder;
  55674. private _recordedChunks;
  55675. private _fileName;
  55676. private _resolve;
  55677. private _reject;
  55678. /**
  55679. * True wether a recording is already in progress.
  55680. */
  55681. readonly isRecording: boolean;
  55682. /**
  55683. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55684. * a video file.
  55685. * @param engine Defines the BabylonJS Engine you wish to record
  55686. * @param options Defines options that can be used to customized the capture
  55687. */
  55688. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55689. /**
  55690. * Stops the current recording before the default capture timeout passed in the startRecording
  55691. * functions.
  55692. */
  55693. stopRecording(): void;
  55694. /**
  55695. * Starts recording the canvas for a max duration specified in parameters.
  55696. * @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.
  55697. * @param maxDuration Defines the maximum recording time in seconds.
  55698. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55699. * @return a promise callback at the end of the recording with the video data in Blob.
  55700. */
  55701. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55702. /**
  55703. * Releases internal resources used during the recording.
  55704. */
  55705. dispose(): void;
  55706. private _handleDataAvailable;
  55707. private _handleError;
  55708. private _handleStop;
  55709. }
  55710. }
  55711. declare module "babylonjs/Misc/workerPool" {
  55712. import { IDisposable } from "babylonjs/scene";
  55713. /**
  55714. * Helper class to push actions to a pool of workers.
  55715. */
  55716. export class WorkerPool implements IDisposable {
  55717. private _workerInfos;
  55718. private _pendingActions;
  55719. /**
  55720. * Constructor
  55721. * @param workers Array of workers to use for actions
  55722. */
  55723. constructor(workers: Array<Worker>);
  55724. /**
  55725. * Terminates all workers and clears any pending actions.
  55726. */
  55727. dispose(): void;
  55728. /**
  55729. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55730. * pended until a worker has completed its action.
  55731. * @param action The action to perform. Call onComplete when the action is complete.
  55732. */
  55733. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55734. private _execute;
  55735. }
  55736. }
  55737. declare module "babylonjs/Misc/screenshotTools" {
  55738. import { Camera } from "babylonjs/Cameras/camera";
  55739. import { Engine } from "babylonjs/Engines/engine";
  55740. /**
  55741. * Class containing a set of static utilities functions for screenshots
  55742. */
  55743. export class ScreenshotTools {
  55744. /**
  55745. * Captures a screenshot of the current rendering
  55746. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55747. * @param engine defines the rendering engine
  55748. * @param camera defines the source camera
  55749. * @param size This parameter can be set to a single number or to an object with the
  55750. * following (optional) properties: precision, width, height. If a single number is passed,
  55751. * it will be used for both width and height. If an object is passed, the screenshot size
  55752. * will be derived from the parameters. The precision property is a multiplier allowing
  55753. * rendering at a higher or lower resolution
  55754. * @param successCallback defines the callback receives a single parameter which contains the
  55755. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55756. * src parameter of an <img> to display it
  55757. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55758. * Check your browser for supported MIME types
  55759. */
  55760. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55761. /**
  55762. * Generates an image screenshot from the specified camera.
  55763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55764. * @param engine The engine to use for rendering
  55765. * @param camera The camera to use for rendering
  55766. * @param size This parameter can be set to a single number or to an object with the
  55767. * following (optional) properties: precision, width, height. If a single number is passed,
  55768. * it will be used for both width and height. If an object is passed, the screenshot size
  55769. * will be derived from the parameters. The precision property is a multiplier allowing
  55770. * rendering at a higher or lower resolution
  55771. * @param successCallback The callback receives a single parameter which contains the
  55772. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55773. * src parameter of an <img> to display it
  55774. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55775. * Check your browser for supported MIME types
  55776. * @param samples Texture samples (default: 1)
  55777. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55778. * @param fileName A name for for the downloaded file.
  55779. */
  55780. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55781. }
  55782. }
  55783. declare module "babylonjs/Misc/index" {
  55784. export * from "babylonjs/Misc/andOrNotEvaluator";
  55785. export * from "babylonjs/Misc/assetsManager";
  55786. export * from "babylonjs/Misc/dds";
  55787. export * from "babylonjs/Misc/decorators";
  55788. export * from "babylonjs/Misc/deferred";
  55789. export * from "babylonjs/Misc/environmentTextureTools";
  55790. export * from "babylonjs/Misc/filesInput";
  55791. export * from "babylonjs/Misc/HighDynamicRange/index";
  55792. export * from "babylonjs/Misc/khronosTextureContainer";
  55793. export * from "babylonjs/Misc/observable";
  55794. export * from "babylonjs/Misc/performanceMonitor";
  55795. export * from "babylonjs/Misc/promise";
  55796. export * from "babylonjs/Misc/sceneOptimizer";
  55797. export * from "babylonjs/Misc/sceneSerializer";
  55798. export * from "babylonjs/Misc/smartArray";
  55799. export * from "babylonjs/Misc/stringDictionary";
  55800. export * from "babylonjs/Misc/tags";
  55801. export * from "babylonjs/Misc/textureTools";
  55802. export * from "babylonjs/Misc/tga";
  55803. export * from "babylonjs/Misc/tools";
  55804. export * from "babylonjs/Misc/videoRecorder";
  55805. export * from "babylonjs/Misc/virtualJoystick";
  55806. export * from "babylonjs/Misc/workerPool";
  55807. export * from "babylonjs/Misc/logger";
  55808. export * from "babylonjs/Misc/typeStore";
  55809. export * from "babylonjs/Misc/filesInputStore";
  55810. export * from "babylonjs/Misc/deepCopier";
  55811. export * from "babylonjs/Misc/pivotTools";
  55812. export * from "babylonjs/Misc/precisionDate";
  55813. export * from "babylonjs/Misc/screenshotTools";
  55814. export * from "babylonjs/Misc/typeStore";
  55815. }
  55816. declare module "babylonjs/index" {
  55817. export * from "babylonjs/abstractScene";
  55818. export * from "babylonjs/Actions/index";
  55819. export * from "babylonjs/Animations/index";
  55820. export * from "babylonjs/assetContainer";
  55821. export * from "babylonjs/Audio/index";
  55822. export * from "babylonjs/Behaviors/index";
  55823. export * from "babylonjs/Bones/index";
  55824. export * from "babylonjs/Cameras/index";
  55825. export * from "babylonjs/Collisions/index";
  55826. export * from "babylonjs/Culling/index";
  55827. export * from "babylonjs/Debug/index";
  55828. export * from "babylonjs/Engines/index";
  55829. export * from "babylonjs/Events/index";
  55830. export * from "babylonjs/Gamepads/index";
  55831. export * from "babylonjs/Gizmos/index";
  55832. export * from "babylonjs/Helpers/index";
  55833. export * from "babylonjs/Instrumentation/index";
  55834. export * from "babylonjs/Layers/index";
  55835. export * from "babylonjs/LensFlares/index";
  55836. export * from "babylonjs/Lights/index";
  55837. export * from "babylonjs/Loading/index";
  55838. export * from "babylonjs/Materials/index";
  55839. export * from "babylonjs/Maths/index";
  55840. export * from "babylonjs/Meshes/index";
  55841. export * from "babylonjs/Morph/index";
  55842. export * from "babylonjs/node";
  55843. export * from "babylonjs/Offline/index";
  55844. export * from "babylonjs/Particles/index";
  55845. export * from "babylonjs/Physics/index";
  55846. export * from "babylonjs/PostProcesses/index";
  55847. export * from "babylonjs/Probes/index";
  55848. export * from "babylonjs/Rendering/index";
  55849. export * from "babylonjs/scene";
  55850. export * from "babylonjs/sceneComponent";
  55851. export * from "babylonjs/Sprites/index";
  55852. export * from "babylonjs/States/index";
  55853. export * from "babylonjs/Misc/index";
  55854. export * from "babylonjs/types";
  55855. }
  55856. declare module "babylonjs/Animations/pathCursor" {
  55857. import { Path2, Vector3 } from "babylonjs/Maths/math";
  55858. /**
  55859. * A cursor which tracks a point on a path
  55860. */
  55861. export class PathCursor {
  55862. private path;
  55863. /**
  55864. * Stores path cursor callbacks for when an onchange event is triggered
  55865. */
  55866. private _onchange;
  55867. /**
  55868. * The value of the path cursor
  55869. */
  55870. value: number;
  55871. /**
  55872. * The animation array of the path cursor
  55873. */
  55874. animations: Animation[];
  55875. /**
  55876. * Initializes the path cursor
  55877. * @param path The path to track
  55878. */
  55879. constructor(path: Path2);
  55880. /**
  55881. * Gets the cursor point on the path
  55882. * @returns A point on the path cursor at the cursor location
  55883. */
  55884. getPoint(): Vector3;
  55885. /**
  55886. * Moves the cursor ahead by the step amount
  55887. * @param step The amount to move the cursor forward
  55888. * @returns This path cursor
  55889. */
  55890. moveAhead(step?: number): PathCursor;
  55891. /**
  55892. * Moves the cursor behind by the step amount
  55893. * @param step The amount to move the cursor back
  55894. * @returns This path cursor
  55895. */
  55896. moveBack(step?: number): PathCursor;
  55897. /**
  55898. * Moves the cursor by the step amount
  55899. * If the step amount is greater than one, an exception is thrown
  55900. * @param step The amount to move the cursor
  55901. * @returns This path cursor
  55902. */
  55903. move(step: number): PathCursor;
  55904. /**
  55905. * Ensures that the value is limited between zero and one
  55906. * @returns This path cursor
  55907. */
  55908. private ensureLimits;
  55909. /**
  55910. * Runs onchange callbacks on change (used by the animation engine)
  55911. * @returns This path cursor
  55912. */
  55913. private raiseOnChange;
  55914. /**
  55915. * Executes a function on change
  55916. * @param f A path cursor onchange callback
  55917. * @returns This path cursor
  55918. */
  55919. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55920. }
  55921. }
  55922. declare module "babylonjs/Legacy/legacy" {
  55923. export * from "babylonjs/index";
  55924. }
  55925. declare module "babylonjs/Shaders/blur.fragment" {
  55926. /** @hidden */
  55927. export var blurPixelShader: {
  55928. name: string;
  55929. shader: string;
  55930. };
  55931. }
  55932. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55933. /** @hidden */
  55934. export var bones300Declaration: {
  55935. name: string;
  55936. shader: string;
  55937. };
  55938. }
  55939. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55940. /** @hidden */
  55941. export var instances300Declaration: {
  55942. name: string;
  55943. shader: string;
  55944. };
  55945. }
  55946. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55947. /** @hidden */
  55948. export var pointCloudVertexDeclaration: {
  55949. name: string;
  55950. shader: string;
  55951. };
  55952. }
  55953. // Mixins
  55954. interface Window {
  55955. mozIndexedDB: IDBFactory;
  55956. webkitIndexedDB: IDBFactory;
  55957. msIndexedDB: IDBFactory;
  55958. webkitURL: typeof URL;
  55959. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55960. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55961. WebGLRenderingContext: WebGLRenderingContext;
  55962. MSGesture: MSGesture;
  55963. CANNON: any;
  55964. AudioContext: AudioContext;
  55965. webkitAudioContext: AudioContext;
  55966. PointerEvent: any;
  55967. Math: Math;
  55968. Uint8Array: Uint8ArrayConstructor;
  55969. Float32Array: Float32ArrayConstructor;
  55970. mozURL: typeof URL;
  55971. msURL: typeof URL;
  55972. VRFrameData: any; // WebVR, from specs 1.1
  55973. DracoDecoderModule: any;
  55974. setImmediate(handler: (...args: any[]) => void): number;
  55975. }
  55976. interface Document {
  55977. mozCancelFullScreen(): void;
  55978. msCancelFullScreen(): void;
  55979. webkitCancelFullScreen(): void;
  55980. requestPointerLock(): void;
  55981. exitPointerLock(): void;
  55982. mozFullScreen: boolean;
  55983. msIsFullScreen: boolean;
  55984. readonly webkitIsFullScreen: boolean;
  55985. readonly pointerLockElement: Element;
  55986. mozPointerLockElement: HTMLElement;
  55987. msPointerLockElement: HTMLElement;
  55988. webkitPointerLockElement: HTMLElement;
  55989. }
  55990. interface HTMLCanvasElement {
  55991. requestPointerLock(): void;
  55992. msRequestPointerLock?(): void;
  55993. mozRequestPointerLock?(): void;
  55994. webkitRequestPointerLock?(): void;
  55995. /** Track wether a record is in progress */
  55996. isRecording: boolean;
  55997. /** Capture Stream method defined by some browsers */
  55998. captureStream(fps?: number): MediaStream;
  55999. }
  56000. interface CanvasRenderingContext2D {
  56001. msImageSmoothingEnabled: boolean;
  56002. }
  56003. interface MouseEvent {
  56004. mozMovementX: number;
  56005. mozMovementY: number;
  56006. webkitMovementX: number;
  56007. webkitMovementY: number;
  56008. msMovementX: number;
  56009. msMovementY: number;
  56010. }
  56011. interface Navigator {
  56012. mozGetVRDevices: (any: any) => any;
  56013. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56014. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56015. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56016. webkitGetGamepads(): Gamepad[];
  56017. msGetGamepads(): Gamepad[];
  56018. webkitGamepads(): Gamepad[];
  56019. }
  56020. interface HTMLVideoElement {
  56021. mozSrcObject: any;
  56022. }
  56023. interface Math {
  56024. fround(x: number): number;
  56025. imul(a: number, b: number): number;
  56026. }
  56027. interface WebGLProgram {
  56028. context?: WebGLRenderingContext;
  56029. vertexShader?: WebGLShader;
  56030. fragmentShader?: WebGLShader;
  56031. isParallelCompiled: boolean;
  56032. onCompiled?: () => void;
  56033. }
  56034. interface WebGLRenderingContext {
  56035. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56036. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56037. vertexAttribDivisor(index: number, divisor: number): void;
  56038. createVertexArray(): any;
  56039. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56040. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56041. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56042. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56043. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56044. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56045. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56046. // Queries
  56047. createQuery(): WebGLQuery;
  56048. deleteQuery(query: WebGLQuery): void;
  56049. beginQuery(target: number, query: WebGLQuery): void;
  56050. endQuery(target: number): void;
  56051. getQueryParameter(query: WebGLQuery, pname: number): any;
  56052. getQuery(target: number, pname: number): any;
  56053. MAX_SAMPLES: number;
  56054. RGBA8: number;
  56055. READ_FRAMEBUFFER: number;
  56056. DRAW_FRAMEBUFFER: number;
  56057. UNIFORM_BUFFER: number;
  56058. HALF_FLOAT_OES: number;
  56059. RGBA16F: number;
  56060. RGBA32F: number;
  56061. R32F: number;
  56062. RG32F: number;
  56063. RGB32F: number;
  56064. R16F: number;
  56065. RG16F: number;
  56066. RGB16F: number;
  56067. RED: number;
  56068. RG: number;
  56069. R8: number;
  56070. RG8: number;
  56071. UNSIGNED_INT_24_8: number;
  56072. DEPTH24_STENCIL8: number;
  56073. /* Multiple Render Targets */
  56074. drawBuffers(buffers: number[]): void;
  56075. readBuffer(src: number): void;
  56076. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56077. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56078. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56079. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56080. // Occlusion Query
  56081. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56082. ANY_SAMPLES_PASSED: number;
  56083. QUERY_RESULT_AVAILABLE: number;
  56084. QUERY_RESULT: number;
  56085. }
  56086. interface WebGLBuffer {
  56087. references: number;
  56088. capacity: number;
  56089. is32Bits: boolean;
  56090. }
  56091. interface WebGLProgram {
  56092. transformFeedback?: WebGLTransformFeedback | null;
  56093. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56094. }
  56095. interface EXT_disjoint_timer_query {
  56096. QUERY_COUNTER_BITS_EXT: number;
  56097. TIME_ELAPSED_EXT: number;
  56098. TIMESTAMP_EXT: number;
  56099. GPU_DISJOINT_EXT: number;
  56100. QUERY_RESULT_EXT: number;
  56101. QUERY_RESULT_AVAILABLE_EXT: number;
  56102. queryCounterEXT(query: WebGLQuery, target: number): void;
  56103. createQueryEXT(): WebGLQuery;
  56104. beginQueryEXT(target: number, query: WebGLQuery): void;
  56105. endQueryEXT(target: number): void;
  56106. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56107. deleteQueryEXT(query: WebGLQuery): void;
  56108. }
  56109. interface WebGLUniformLocation {
  56110. _currentState: any;
  56111. }
  56112. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56113. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56114. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56115. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56116. interface WebGLRenderingContext {
  56117. readonly RASTERIZER_DISCARD: number;
  56118. readonly DEPTH_COMPONENT24: number;
  56119. readonly TEXTURE_3D: number;
  56120. readonly TEXTURE_2D_ARRAY: number;
  56121. readonly TEXTURE_COMPARE_FUNC: number;
  56122. readonly TEXTURE_COMPARE_MODE: number;
  56123. readonly COMPARE_REF_TO_TEXTURE: number;
  56124. readonly TEXTURE_WRAP_R: number;
  56125. readonly HALF_FLOAT: number;
  56126. readonly RGB8: number;
  56127. readonly RED_INTEGER: number;
  56128. readonly RG_INTEGER: number;
  56129. readonly RGB_INTEGER: number;
  56130. readonly RGBA_INTEGER: number;
  56131. readonly R8_SNORM: number;
  56132. readonly RG8_SNORM: number;
  56133. readonly RGB8_SNORM: number;
  56134. readonly RGBA8_SNORM: number;
  56135. readonly R8I: number;
  56136. readonly RG8I: number;
  56137. readonly RGB8I: number;
  56138. readonly RGBA8I: number;
  56139. readonly R8UI: number;
  56140. readonly RG8UI: number;
  56141. readonly RGB8UI: number;
  56142. readonly RGBA8UI: number;
  56143. readonly R16I: number;
  56144. readonly RG16I: number;
  56145. readonly RGB16I: number;
  56146. readonly RGBA16I: number;
  56147. readonly R16UI: number;
  56148. readonly RG16UI: number;
  56149. readonly RGB16UI: number;
  56150. readonly RGBA16UI: number;
  56151. readonly R32I: number;
  56152. readonly RG32I: number;
  56153. readonly RGB32I: number;
  56154. readonly RGBA32I: number;
  56155. readonly R32UI: number;
  56156. readonly RG32UI: number;
  56157. readonly RGB32UI: number;
  56158. readonly RGBA32UI: number;
  56159. readonly RGB10_A2UI: number;
  56160. readonly R11F_G11F_B10F: number;
  56161. readonly RGB9_E5: number;
  56162. readonly RGB10_A2: number;
  56163. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56164. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56165. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56166. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56167. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56168. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56169. 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;
  56170. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56171. readonly TRANSFORM_FEEDBACK: number;
  56172. readonly INTERLEAVED_ATTRIBS: number;
  56173. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56174. createTransformFeedback(): WebGLTransformFeedback;
  56175. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56176. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56177. beginTransformFeedback(primitiveMode: number): void;
  56178. endTransformFeedback(): void;
  56179. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56180. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56181. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56182. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56183. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56184. }
  56185. interface ImageBitmap {
  56186. readonly width: number;
  56187. readonly height: number;
  56188. close(): void;
  56189. }
  56190. interface WebGLQuery extends WebGLObject {
  56191. }
  56192. declare var WebGLQuery: {
  56193. prototype: WebGLQuery;
  56194. new(): WebGLQuery;
  56195. };
  56196. interface WebGLSampler extends WebGLObject {
  56197. }
  56198. declare var WebGLSampler: {
  56199. prototype: WebGLSampler;
  56200. new(): WebGLSampler;
  56201. };
  56202. interface WebGLSync extends WebGLObject {
  56203. }
  56204. declare var WebGLSync: {
  56205. prototype: WebGLSync;
  56206. new(): WebGLSync;
  56207. };
  56208. interface WebGLTransformFeedback extends WebGLObject {
  56209. }
  56210. declare var WebGLTransformFeedback: {
  56211. prototype: WebGLTransformFeedback;
  56212. new(): WebGLTransformFeedback;
  56213. };
  56214. interface WebGLVertexArrayObject extends WebGLObject {
  56215. }
  56216. declare var WebGLVertexArrayObject: {
  56217. prototype: WebGLVertexArrayObject;
  56218. new(): WebGLVertexArrayObject;
  56219. };
  56220. // Type definitions for WebVR API
  56221. // Project: https://w3c.github.io/webvr/
  56222. // Definitions by: six a <https://github.com/lostfictions>
  56223. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56224. interface VRDisplay extends EventTarget {
  56225. /**
  56226. * Dictionary of capabilities describing the VRDisplay.
  56227. */
  56228. readonly capabilities: VRDisplayCapabilities;
  56229. /**
  56230. * z-depth defining the far plane of the eye view frustum
  56231. * enables mapping of values in the render target depth
  56232. * attachment to scene coordinates. Initially set to 10000.0.
  56233. */
  56234. depthFar: number;
  56235. /**
  56236. * z-depth defining the near plane of the eye view frustum
  56237. * enables mapping of values in the render target depth
  56238. * attachment to scene coordinates. Initially set to 0.01.
  56239. */
  56240. depthNear: number;
  56241. /**
  56242. * An identifier for this distinct VRDisplay. Used as an
  56243. * association point in the Gamepad API.
  56244. */
  56245. readonly displayId: number;
  56246. /**
  56247. * A display name, a user-readable name identifying it.
  56248. */
  56249. readonly displayName: string;
  56250. readonly isConnected: boolean;
  56251. readonly isPresenting: boolean;
  56252. /**
  56253. * If this VRDisplay supports room-scale experiences, the optional
  56254. * stage attribute contains details on the room-scale parameters.
  56255. */
  56256. readonly stageParameters: VRStageParameters | null;
  56257. /**
  56258. * Passing the value returned by `requestAnimationFrame` to
  56259. * `cancelAnimationFrame` will unregister the callback.
  56260. * @param handle Define the hanle of the request to cancel
  56261. */
  56262. cancelAnimationFrame(handle: number): void;
  56263. /**
  56264. * Stops presenting to the VRDisplay.
  56265. * @returns a promise to know when it stopped
  56266. */
  56267. exitPresent(): Promise<void>;
  56268. /**
  56269. * Return the current VREyeParameters for the given eye.
  56270. * @param whichEye Define the eye we want the parameter for
  56271. * @returns the eye parameters
  56272. */
  56273. getEyeParameters(whichEye: string): VREyeParameters;
  56274. /**
  56275. * Populates the passed VRFrameData with the information required to render
  56276. * the current frame.
  56277. * @param frameData Define the data structure to populate
  56278. * @returns true if ok otherwise false
  56279. */
  56280. getFrameData(frameData: VRFrameData): boolean;
  56281. /**
  56282. * Get the layers currently being presented.
  56283. * @returns the list of VR layers
  56284. */
  56285. getLayers(): VRLayer[];
  56286. /**
  56287. * Return a VRPose containing the future predicted pose of the VRDisplay
  56288. * when the current frame will be presented. The value returned will not
  56289. * change until JavaScript has returned control to the browser.
  56290. *
  56291. * The VRPose will contain the position, orientation, velocity,
  56292. * and acceleration of each of these properties.
  56293. * @returns the pose object
  56294. */
  56295. getPose(): VRPose;
  56296. /**
  56297. * Return the current instantaneous pose of the VRDisplay, with no
  56298. * prediction applied.
  56299. * @returns the current instantaneous pose
  56300. */
  56301. getImmediatePose(): VRPose;
  56302. /**
  56303. * The callback passed to `requestAnimationFrame` will be called
  56304. * any time a new frame should be rendered. When the VRDisplay is
  56305. * presenting the callback will be called at the native refresh
  56306. * rate of the HMD. When not presenting this function acts
  56307. * identically to how window.requestAnimationFrame acts. Content should
  56308. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56309. * asynchronously from other displays and at differing refresh rates.
  56310. * @param callback Define the eaction to run next frame
  56311. * @returns the request handle it
  56312. */
  56313. requestAnimationFrame(callback: FrameRequestCallback): number;
  56314. /**
  56315. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56316. * Repeat calls while already presenting will update the VRLayers being displayed.
  56317. * @param layers Define the list of layer to present
  56318. * @returns a promise to know when the request has been fulfilled
  56319. */
  56320. requestPresent(layers: VRLayer[]): Promise<void>;
  56321. /**
  56322. * Reset the pose for this display, treating its current position and
  56323. * orientation as the "origin/zero" values. VRPose.position,
  56324. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56325. * updated when calling resetPose(). This should be called in only
  56326. * sitting-space experiences.
  56327. */
  56328. resetPose(): void;
  56329. /**
  56330. * The VRLayer provided to the VRDisplay will be captured and presented
  56331. * in the HMD. Calling this function has the same effect on the source
  56332. * canvas as any other operation that uses its source image, and canvases
  56333. * created without preserveDrawingBuffer set to true will be cleared.
  56334. * @param pose Define the pose to submit
  56335. */
  56336. submitFrame(pose?: VRPose): void;
  56337. }
  56338. declare var VRDisplay: {
  56339. prototype: VRDisplay;
  56340. new(): VRDisplay;
  56341. };
  56342. interface VRLayer {
  56343. leftBounds?: number[] | Float32Array | null;
  56344. rightBounds?: number[] | Float32Array | null;
  56345. source?: HTMLCanvasElement | null;
  56346. }
  56347. interface VRDisplayCapabilities {
  56348. readonly canPresent: boolean;
  56349. readonly hasExternalDisplay: boolean;
  56350. readonly hasOrientation: boolean;
  56351. readonly hasPosition: boolean;
  56352. readonly maxLayers: number;
  56353. }
  56354. interface VREyeParameters {
  56355. /** @deprecated */
  56356. readonly fieldOfView: VRFieldOfView;
  56357. readonly offset: Float32Array;
  56358. readonly renderHeight: number;
  56359. readonly renderWidth: number;
  56360. }
  56361. interface VRFieldOfView {
  56362. readonly downDegrees: number;
  56363. readonly leftDegrees: number;
  56364. readonly rightDegrees: number;
  56365. readonly upDegrees: number;
  56366. }
  56367. interface VRFrameData {
  56368. readonly leftProjectionMatrix: Float32Array;
  56369. readonly leftViewMatrix: Float32Array;
  56370. readonly pose: VRPose;
  56371. readonly rightProjectionMatrix: Float32Array;
  56372. readonly rightViewMatrix: Float32Array;
  56373. readonly timestamp: number;
  56374. }
  56375. interface VRPose {
  56376. readonly angularAcceleration: Float32Array | null;
  56377. readonly angularVelocity: Float32Array | null;
  56378. readonly linearAcceleration: Float32Array | null;
  56379. readonly linearVelocity: Float32Array | null;
  56380. readonly orientation: Float32Array | null;
  56381. readonly position: Float32Array | null;
  56382. readonly timestamp: number;
  56383. }
  56384. interface VRStageParameters {
  56385. sittingToStandingTransform?: Float32Array;
  56386. sizeX?: number;
  56387. sizeY?: number;
  56388. }
  56389. interface Navigator {
  56390. getVRDisplays(): Promise<VRDisplay[]>;
  56391. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56392. }
  56393. interface Window {
  56394. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56395. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56396. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56397. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56398. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56399. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56400. }
  56401. interface Gamepad {
  56402. readonly displayId: number;
  56403. }
  56404. interface XRDevice {
  56405. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56406. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56407. }
  56408. interface XRSession {
  56409. getInputSources(): Array<any>;
  56410. baseLayer: XRWebGLLayer;
  56411. requestFrameOfReference(type: string): Promise<void>;
  56412. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56413. end(): Promise<void>;
  56414. requestAnimationFrame: Function;
  56415. addEventListener: Function;
  56416. }
  56417. interface XRSessionCreationOptions {
  56418. outputContext?: WebGLRenderingContext | null;
  56419. immersive?: boolean;
  56420. environmentIntegration?: boolean;
  56421. }
  56422. interface XRLayer {
  56423. getViewport: Function;
  56424. framebufferWidth: number;
  56425. framebufferHeight: number;
  56426. }
  56427. interface XRView {
  56428. projectionMatrix: Float32Array;
  56429. }
  56430. interface XRFrame {
  56431. getDevicePose: Function;
  56432. getInputPose: Function;
  56433. views: Array<XRView>;
  56434. baseLayer: XRLayer;
  56435. }
  56436. interface XRFrameOfReference {
  56437. }
  56438. interface XRWebGLLayer extends XRLayer {
  56439. framebuffer: WebGLFramebuffer;
  56440. }
  56441. declare var XRWebGLLayer: {
  56442. prototype: XRWebGLLayer;
  56443. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56444. };
  56445. declare module "babylonjs" {
  56446. export * from "babylonjs/Legacy/legacy";
  56447. }
  56448. declare module BABYLON {
  56449. /** Alias type for value that can be null */
  56450. export type Nullable<T> = T | null;
  56451. /**
  56452. * Alias type for number that are floats
  56453. * @ignorenaming
  56454. */
  56455. export type float = number;
  56456. /**
  56457. * Alias type for number that are doubles.
  56458. * @ignorenaming
  56459. */
  56460. export type double = number;
  56461. /**
  56462. * Alias type for number that are integer
  56463. * @ignorenaming
  56464. */
  56465. export type int = number;
  56466. /** Alias type for number array or Float32Array */
  56467. export type FloatArray = number[] | Float32Array;
  56468. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56469. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56470. /**
  56471. * Alias for types that can be used by a Buffer or VertexBuffer.
  56472. */
  56473. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56474. /**
  56475. * Alias type for primitive types
  56476. * @ignorenaming
  56477. */
  56478. type Primitive = undefined | null | boolean | string | number | Function;
  56479. /**
  56480. * Type modifier to make all the properties of an object Readonly
  56481. */
  56482. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56483. /**
  56484. * Type modifier to make all the properties of an object Readonly recursively
  56485. */
  56486. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56487. /** @hidden */
  56488. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56489. }
  56490. /** @hidden */
  56491. /** @hidden */
  56492. type DeepImmutableObject<T> = {
  56493. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56494. };
  56495. }
  56496. declare module BABYLON {
  56497. /**
  56498. * Class containing a set of static utilities functions for arrays.
  56499. */
  56500. export class ArrayTools {
  56501. /**
  56502. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56503. * @param size the number of element to construct and put in the array
  56504. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56505. * @returns a new array filled with new objects
  56506. */
  56507. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56508. }
  56509. }
  56510. declare module BABYLON {
  56511. /**
  56512. * Scalar computation library
  56513. */
  56514. export class Scalar {
  56515. /**
  56516. * Two pi constants convenient for computation.
  56517. */
  56518. static TwoPi: number;
  56519. /**
  56520. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56521. * @param a number
  56522. * @param b number
  56523. * @param epsilon (default = 1.401298E-45)
  56524. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56525. */
  56526. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56527. /**
  56528. * Returns a string : the upper case translation of the number i to hexadecimal.
  56529. * @param i number
  56530. * @returns the upper case translation of the number i to hexadecimal.
  56531. */
  56532. static ToHex(i: number): string;
  56533. /**
  56534. * Returns -1 if value is negative and +1 is value is positive.
  56535. * @param value the value
  56536. * @returns the value itself if it's equal to zero.
  56537. */
  56538. static Sign(value: number): number;
  56539. /**
  56540. * Returns the value itself if it's between min and max.
  56541. * Returns min if the value is lower than min.
  56542. * Returns max if the value is greater than max.
  56543. * @param value the value to clmap
  56544. * @param min the min value to clamp to (default: 0)
  56545. * @param max the max value to clamp to (default: 1)
  56546. * @returns the clamped value
  56547. */
  56548. static Clamp(value: number, min?: number, max?: number): number;
  56549. /**
  56550. * the log2 of value.
  56551. * @param value the value to compute log2 of
  56552. * @returns the log2 of value.
  56553. */
  56554. static Log2(value: number): number;
  56555. /**
  56556. * Loops the value, so that it is never larger than length and never smaller than 0.
  56557. *
  56558. * This is similar to the modulo operator but it works with floating point numbers.
  56559. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56560. * With t = 5 and length = 2.5, the result would be 0.0.
  56561. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56562. * @param value the value
  56563. * @param length the length
  56564. * @returns the looped value
  56565. */
  56566. static Repeat(value: number, length: number): number;
  56567. /**
  56568. * Normalize the value between 0.0 and 1.0 using min and max values
  56569. * @param value value to normalize
  56570. * @param min max to normalize between
  56571. * @param max min to normalize between
  56572. * @returns the normalized value
  56573. */
  56574. static Normalize(value: number, min: number, max: number): number;
  56575. /**
  56576. * Denormalize the value from 0.0 and 1.0 using min and max values
  56577. * @param normalized value to denormalize
  56578. * @param min max to denormalize between
  56579. * @param max min to denormalize between
  56580. * @returns the denormalized value
  56581. */
  56582. static Denormalize(normalized: number, min: number, max: number): number;
  56583. /**
  56584. * Calculates the shortest difference between two given angles given in degrees.
  56585. * @param current current angle in degrees
  56586. * @param target target angle in degrees
  56587. * @returns the delta
  56588. */
  56589. static DeltaAngle(current: number, target: number): number;
  56590. /**
  56591. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56592. * @param tx value
  56593. * @param length length
  56594. * @returns The returned value will move back and forth between 0 and length
  56595. */
  56596. static PingPong(tx: number, length: number): number;
  56597. /**
  56598. * Interpolates between min and max with smoothing at the limits.
  56599. *
  56600. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56601. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56602. * @param from from
  56603. * @param to to
  56604. * @param tx value
  56605. * @returns the smooth stepped value
  56606. */
  56607. static SmoothStep(from: number, to: number, tx: number): number;
  56608. /**
  56609. * Moves a value current towards target.
  56610. *
  56611. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56612. * Negative values of maxDelta pushes the value away from target.
  56613. * @param current current value
  56614. * @param target target value
  56615. * @param maxDelta max distance to move
  56616. * @returns resulting value
  56617. */
  56618. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56619. /**
  56620. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56621. *
  56622. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56623. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56624. * @param current current value
  56625. * @param target target value
  56626. * @param maxDelta max distance to move
  56627. * @returns resulting angle
  56628. */
  56629. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56630. /**
  56631. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56632. * @param start start value
  56633. * @param end target value
  56634. * @param amount amount to lerp between
  56635. * @returns the lerped value
  56636. */
  56637. static Lerp(start: number, end: number, amount: number): number;
  56638. /**
  56639. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56640. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56641. * @param start start value
  56642. * @param end target value
  56643. * @param amount amount to lerp between
  56644. * @returns the lerped value
  56645. */
  56646. static LerpAngle(start: number, end: number, amount: number): number;
  56647. /**
  56648. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56649. * @param a start value
  56650. * @param b target value
  56651. * @param value value between a and b
  56652. * @returns the inverseLerp value
  56653. */
  56654. static InverseLerp(a: number, b: number, value: number): number;
  56655. /**
  56656. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56657. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56658. * @param value1 spline value
  56659. * @param tangent1 spline value
  56660. * @param value2 spline value
  56661. * @param tangent2 spline value
  56662. * @param amount input value
  56663. * @returns hermite result
  56664. */
  56665. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56666. /**
  56667. * Returns a random float number between and min and max values
  56668. * @param min min value of random
  56669. * @param max max value of random
  56670. * @returns random value
  56671. */
  56672. static RandomRange(min: number, max: number): number;
  56673. /**
  56674. * This function returns percentage of a number in a given range.
  56675. *
  56676. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56677. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56678. * @param number to convert to percentage
  56679. * @param min min range
  56680. * @param max max range
  56681. * @returns the percentage
  56682. */
  56683. static RangeToPercent(number: number, min: number, max: number): number;
  56684. /**
  56685. * This function returns number that corresponds to the percentage in a given range.
  56686. *
  56687. * PercentToRange(0.34,0,100) will return 34.
  56688. * @param percent to convert to number
  56689. * @param min min range
  56690. * @param max max range
  56691. * @returns the number
  56692. */
  56693. static PercentToRange(percent: number, min: number, max: number): number;
  56694. /**
  56695. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56696. * @param angle The angle to normalize in radian.
  56697. * @return The converted angle.
  56698. */
  56699. static NormalizeRadians(angle: number): number;
  56700. }
  56701. }
  56702. declare module BABYLON {
  56703. /**
  56704. * Constant used to convert a value to gamma space
  56705. * @ignorenaming
  56706. */
  56707. export const ToGammaSpace: number;
  56708. /**
  56709. * Constant used to convert a value to linear space
  56710. * @ignorenaming
  56711. */
  56712. export const ToLinearSpace = 2.2;
  56713. /**
  56714. * Constant used to define the minimal number value in Babylon.js
  56715. * @ignorenaming
  56716. */
  56717. export const Epsilon = 0.001;
  56718. /**
  56719. * Class used to hold a RBG color
  56720. */
  56721. export class Color3 {
  56722. /**
  56723. * Defines the red component (between 0 and 1, default is 0)
  56724. */
  56725. r: number;
  56726. /**
  56727. * Defines the green component (between 0 and 1, default is 0)
  56728. */
  56729. g: number;
  56730. /**
  56731. * Defines the blue component (between 0 and 1, default is 0)
  56732. */
  56733. b: number;
  56734. /**
  56735. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56736. * @param r defines the red component (between 0 and 1, default is 0)
  56737. * @param g defines the green component (between 0 and 1, default is 0)
  56738. * @param b defines the blue component (between 0 and 1, default is 0)
  56739. */
  56740. constructor(
  56741. /**
  56742. * Defines the red component (between 0 and 1, default is 0)
  56743. */
  56744. r?: number,
  56745. /**
  56746. * Defines the green component (between 0 and 1, default is 0)
  56747. */
  56748. g?: number,
  56749. /**
  56750. * Defines the blue component (between 0 and 1, default is 0)
  56751. */
  56752. b?: number);
  56753. /**
  56754. * Creates a string with the Color3 current values
  56755. * @returns the string representation of the Color3 object
  56756. */
  56757. toString(): string;
  56758. /**
  56759. * Returns the string "Color3"
  56760. * @returns "Color3"
  56761. */
  56762. getClassName(): string;
  56763. /**
  56764. * Compute the Color3 hash code
  56765. * @returns an unique number that can be used to hash Color3 objects
  56766. */
  56767. getHashCode(): number;
  56768. /**
  56769. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56770. * @param array defines the array where to store the r,g,b components
  56771. * @param index defines an optional index in the target array to define where to start storing values
  56772. * @returns the current Color3 object
  56773. */
  56774. toArray(array: FloatArray, index?: number): Color3;
  56775. /**
  56776. * Returns a new Color4 object from the current Color3 and the given alpha
  56777. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56778. * @returns a new Color4 object
  56779. */
  56780. toColor4(alpha?: number): Color4;
  56781. /**
  56782. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56783. * @returns the new array
  56784. */
  56785. asArray(): number[];
  56786. /**
  56787. * Returns the luminance value
  56788. * @returns a float value
  56789. */
  56790. toLuminance(): number;
  56791. /**
  56792. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56793. * @param otherColor defines the second operand
  56794. * @returns the new Color3 object
  56795. */
  56796. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56797. /**
  56798. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56799. * @param otherColor defines the second operand
  56800. * @param result defines the Color3 object where to store the result
  56801. * @returns the current Color3
  56802. */
  56803. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56804. /**
  56805. * Determines equality between Color3 objects
  56806. * @param otherColor defines the second operand
  56807. * @returns true if the rgb values are equal to the given ones
  56808. */
  56809. equals(otherColor: DeepImmutable<Color3>): boolean;
  56810. /**
  56811. * Determines equality between the current Color3 object and a set of r,b,g values
  56812. * @param r defines the red component to check
  56813. * @param g defines the green component to check
  56814. * @param b defines the blue component to check
  56815. * @returns true if the rgb values are equal to the given ones
  56816. */
  56817. equalsFloats(r: number, g: number, b: number): boolean;
  56818. /**
  56819. * Multiplies in place each rgb value by scale
  56820. * @param scale defines the scaling factor
  56821. * @returns the updated Color3
  56822. */
  56823. scale(scale: number): Color3;
  56824. /**
  56825. * Multiplies the rgb values by scale and stores the result into "result"
  56826. * @param scale defines the scaling factor
  56827. * @param result defines the Color3 object where to store the result
  56828. * @returns the unmodified current Color3
  56829. */
  56830. scaleToRef(scale: number, result: Color3): Color3;
  56831. /**
  56832. * Scale the current Color3 values by a factor and add the result to a given Color3
  56833. * @param scale defines the scale factor
  56834. * @param result defines color to store the result into
  56835. * @returns the unmodified current Color3
  56836. */
  56837. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56838. /**
  56839. * Clamps the rgb values by the min and max values and stores the result into "result"
  56840. * @param min defines minimum clamping value (default is 0)
  56841. * @param max defines maximum clamping value (default is 1)
  56842. * @param result defines color to store the result into
  56843. * @returns the original Color3
  56844. */
  56845. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56846. /**
  56847. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56848. * @param otherColor defines the second operand
  56849. * @returns the new Color3
  56850. */
  56851. add(otherColor: DeepImmutable<Color3>): Color3;
  56852. /**
  56853. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56854. * @param otherColor defines the second operand
  56855. * @param result defines Color3 object to store the result into
  56856. * @returns the unmodified current Color3
  56857. */
  56858. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56859. /**
  56860. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56861. * @param otherColor defines the second operand
  56862. * @returns the new Color3
  56863. */
  56864. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56865. /**
  56866. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56867. * @param otherColor defines the second operand
  56868. * @param result defines Color3 object to store the result into
  56869. * @returns the unmodified current Color3
  56870. */
  56871. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56872. /**
  56873. * Copy the current object
  56874. * @returns a new Color3 copied the current one
  56875. */
  56876. clone(): Color3;
  56877. /**
  56878. * Copies the rgb values from the source in the current Color3
  56879. * @param source defines the source Color3 object
  56880. * @returns the updated Color3 object
  56881. */
  56882. copyFrom(source: DeepImmutable<Color3>): Color3;
  56883. /**
  56884. * Updates the Color3 rgb values from the given floats
  56885. * @param r defines the red component to read from
  56886. * @param g defines the green component to read from
  56887. * @param b defines the blue component to read from
  56888. * @returns the current Color3 object
  56889. */
  56890. copyFromFloats(r: number, g: number, b: number): Color3;
  56891. /**
  56892. * Updates the Color3 rgb values from the given floats
  56893. * @param r defines the red component to read from
  56894. * @param g defines the green component to read from
  56895. * @param b defines the blue component to read from
  56896. * @returns the current Color3 object
  56897. */
  56898. set(r: number, g: number, b: number): Color3;
  56899. /**
  56900. * Compute the Color3 hexadecimal code as a string
  56901. * @returns a string containing the hexadecimal representation of the Color3 object
  56902. */
  56903. toHexString(): string;
  56904. /**
  56905. * Computes a new Color3 converted from the current one to linear space
  56906. * @returns a new Color3 object
  56907. */
  56908. toLinearSpace(): Color3;
  56909. /**
  56910. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56911. * @param convertedColor defines the Color3 object where to store the linear space version
  56912. * @returns the unmodified Color3
  56913. */
  56914. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56915. /**
  56916. * Computes a new Color3 converted from the current one to gamma space
  56917. * @returns a new Color3 object
  56918. */
  56919. toGammaSpace(): Color3;
  56920. /**
  56921. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56922. * @param convertedColor defines the Color3 object where to store the gamma space version
  56923. * @returns the unmodified Color3
  56924. */
  56925. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56926. private static _BlackReadOnly;
  56927. /**
  56928. * Creates a new Color3 from the string containing valid hexadecimal values
  56929. * @param hex defines a string containing valid hexadecimal values
  56930. * @returns a new Color3 object
  56931. */
  56932. static FromHexString(hex: string): Color3;
  56933. /**
  56934. * Creates a new Vector3 from the starting index of the given array
  56935. * @param array defines the source array
  56936. * @param offset defines an offset in the source array
  56937. * @returns a new Color3 object
  56938. */
  56939. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56940. /**
  56941. * Creates a new Color3 from integer values (< 256)
  56942. * @param r defines the red component to read from (value between 0 and 255)
  56943. * @param g defines the green component to read from (value between 0 and 255)
  56944. * @param b defines the blue component to read from (value between 0 and 255)
  56945. * @returns a new Color3 object
  56946. */
  56947. static FromInts(r: number, g: number, b: number): Color3;
  56948. /**
  56949. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56950. * @param start defines the start Color3 value
  56951. * @param end defines the end Color3 value
  56952. * @param amount defines the gradient value between start and end
  56953. * @returns a new Color3 object
  56954. */
  56955. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56956. /**
  56957. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56958. * @param left defines the start value
  56959. * @param right defines the end value
  56960. * @param amount defines the gradient factor
  56961. * @param result defines the Color3 object where to store the result
  56962. */
  56963. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  56964. /**
  56965. * Returns a Color3 value containing a red color
  56966. * @returns a new Color3 object
  56967. */
  56968. static Red(): Color3;
  56969. /**
  56970. * Returns a Color3 value containing a green color
  56971. * @returns a new Color3 object
  56972. */
  56973. static Green(): Color3;
  56974. /**
  56975. * Returns a Color3 value containing a blue color
  56976. * @returns a new Color3 object
  56977. */
  56978. static Blue(): Color3;
  56979. /**
  56980. * Returns a Color3 value containing a black color
  56981. * @returns a new Color3 object
  56982. */
  56983. static Black(): Color3;
  56984. /**
  56985. * Gets a Color3 value containing a black color that must not be updated
  56986. */
  56987. static readonly BlackReadOnly: DeepImmutable<Color3>;
  56988. /**
  56989. * Returns a Color3 value containing a white color
  56990. * @returns a new Color3 object
  56991. */
  56992. static White(): Color3;
  56993. /**
  56994. * Returns a Color3 value containing a purple color
  56995. * @returns a new Color3 object
  56996. */
  56997. static Purple(): Color3;
  56998. /**
  56999. * Returns a Color3 value containing a magenta color
  57000. * @returns a new Color3 object
  57001. */
  57002. static Magenta(): Color3;
  57003. /**
  57004. * Returns a Color3 value containing a yellow color
  57005. * @returns a new Color3 object
  57006. */
  57007. static Yellow(): Color3;
  57008. /**
  57009. * Returns a Color3 value containing a gray color
  57010. * @returns a new Color3 object
  57011. */
  57012. static Gray(): Color3;
  57013. /**
  57014. * Returns a Color3 value containing a teal color
  57015. * @returns a new Color3 object
  57016. */
  57017. static Teal(): Color3;
  57018. /**
  57019. * Returns a Color3 value containing a random color
  57020. * @returns a new Color3 object
  57021. */
  57022. static Random(): Color3;
  57023. }
  57024. /**
  57025. * Class used to hold a RBGA color
  57026. */
  57027. export class Color4 {
  57028. /**
  57029. * Defines the red component (between 0 and 1, default is 0)
  57030. */
  57031. r: number;
  57032. /**
  57033. * Defines the green component (between 0 and 1, default is 0)
  57034. */
  57035. g: number;
  57036. /**
  57037. * Defines the blue component (between 0 and 1, default is 0)
  57038. */
  57039. b: number;
  57040. /**
  57041. * Defines the alpha component (between 0 and 1, default is 1)
  57042. */
  57043. a: number;
  57044. /**
  57045. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57046. * @param r defines the red component (between 0 and 1, default is 0)
  57047. * @param g defines the green component (between 0 and 1, default is 0)
  57048. * @param b defines the blue component (between 0 and 1, default is 0)
  57049. * @param a defines the alpha component (between 0 and 1, default is 1)
  57050. */
  57051. constructor(
  57052. /**
  57053. * Defines the red component (between 0 and 1, default is 0)
  57054. */
  57055. r?: number,
  57056. /**
  57057. * Defines the green component (between 0 and 1, default is 0)
  57058. */
  57059. g?: number,
  57060. /**
  57061. * Defines the blue component (between 0 and 1, default is 0)
  57062. */
  57063. b?: number,
  57064. /**
  57065. * Defines the alpha component (between 0 and 1, default is 1)
  57066. */
  57067. a?: number);
  57068. /**
  57069. * Adds in place the given Color4 values to the current Color4 object
  57070. * @param right defines the second operand
  57071. * @returns the current updated Color4 object
  57072. */
  57073. addInPlace(right: DeepImmutable<Color4>): Color4;
  57074. /**
  57075. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57076. * @returns the new array
  57077. */
  57078. asArray(): number[];
  57079. /**
  57080. * Stores from the starting index in the given array the Color4 successive values
  57081. * @param array defines the array where to store the r,g,b components
  57082. * @param index defines an optional index in the target array to define where to start storing values
  57083. * @returns the current Color4 object
  57084. */
  57085. toArray(array: number[], index?: number): Color4;
  57086. /**
  57087. * Determines equality between Color4 objects
  57088. * @param otherColor defines the second operand
  57089. * @returns true if the rgba values are equal to the given ones
  57090. */
  57091. equals(otherColor: DeepImmutable<Color4>): boolean;
  57092. /**
  57093. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57094. * @param right defines the second operand
  57095. * @returns a new Color4 object
  57096. */
  57097. add(right: DeepImmutable<Color4>): Color4;
  57098. /**
  57099. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57100. * @param right defines the second operand
  57101. * @returns a new Color4 object
  57102. */
  57103. subtract(right: DeepImmutable<Color4>): Color4;
  57104. /**
  57105. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57106. * @param right defines the second operand
  57107. * @param result defines the Color4 object where to store the result
  57108. * @returns the current Color4 object
  57109. */
  57110. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57111. /**
  57112. * Creates a new Color4 with the current Color4 values multiplied by scale
  57113. * @param scale defines the scaling factor to apply
  57114. * @returns a new Color4 object
  57115. */
  57116. scale(scale: number): Color4;
  57117. /**
  57118. * Multiplies the current Color4 values by scale and stores the result in "result"
  57119. * @param scale defines the scaling factor to apply
  57120. * @param result defines the Color4 object where to store the result
  57121. * @returns the current unmodified Color4
  57122. */
  57123. scaleToRef(scale: number, result: Color4): Color4;
  57124. /**
  57125. * Scale the current Color4 values by a factor and add the result to a given Color4
  57126. * @param scale defines the scale factor
  57127. * @param result defines the Color4 object where to store the result
  57128. * @returns the unmodified current Color4
  57129. */
  57130. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57131. /**
  57132. * Clamps the rgb values by the min and max values and stores the result into "result"
  57133. * @param min defines minimum clamping value (default is 0)
  57134. * @param max defines maximum clamping value (default is 1)
  57135. * @param result defines color to store the result into.
  57136. * @returns the cuurent Color4
  57137. */
  57138. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57139. /**
  57140. * Multipy an Color4 value by another and return a new Color4 object
  57141. * @param color defines the Color4 value to multiply by
  57142. * @returns a new Color4 object
  57143. */
  57144. multiply(color: Color4): Color4;
  57145. /**
  57146. * Multipy a Color4 value by another and push the result in a reference value
  57147. * @param color defines the Color4 value to multiply by
  57148. * @param result defines the Color4 to fill the result in
  57149. * @returns the result Color4
  57150. */
  57151. multiplyToRef(color: Color4, result: Color4): Color4;
  57152. /**
  57153. * Creates a string with the Color4 current values
  57154. * @returns the string representation of the Color4 object
  57155. */
  57156. toString(): string;
  57157. /**
  57158. * Returns the string "Color4"
  57159. * @returns "Color4"
  57160. */
  57161. getClassName(): string;
  57162. /**
  57163. * Compute the Color4 hash code
  57164. * @returns an unique number that can be used to hash Color4 objects
  57165. */
  57166. getHashCode(): number;
  57167. /**
  57168. * Creates a new Color4 copied from the current one
  57169. * @returns a new Color4 object
  57170. */
  57171. clone(): Color4;
  57172. /**
  57173. * Copies the given Color4 values into the current one
  57174. * @param source defines the source Color4 object
  57175. * @returns the current updated Color4 object
  57176. */
  57177. copyFrom(source: Color4): Color4;
  57178. /**
  57179. * Copies the given float values into the current one
  57180. * @param r defines the red component to read from
  57181. * @param g defines the green component to read from
  57182. * @param b defines the blue component to read from
  57183. * @param a defines the alpha component to read from
  57184. * @returns the current updated Color4 object
  57185. */
  57186. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57187. /**
  57188. * Copies the given float values into the current one
  57189. * @param r defines the red component to read from
  57190. * @param g defines the green component to read from
  57191. * @param b defines the blue component to read from
  57192. * @param a defines the alpha component to read from
  57193. * @returns the current updated Color4 object
  57194. */
  57195. set(r: number, g: number, b: number, a: number): Color4;
  57196. /**
  57197. * Compute the Color4 hexadecimal code as a string
  57198. * @returns a string containing the hexadecimal representation of the Color4 object
  57199. */
  57200. toHexString(): string;
  57201. /**
  57202. * Computes a new Color4 converted from the current one to linear space
  57203. * @returns a new Color4 object
  57204. */
  57205. toLinearSpace(): Color4;
  57206. /**
  57207. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57208. * @param convertedColor defines the Color4 object where to store the linear space version
  57209. * @returns the unmodified Color4
  57210. */
  57211. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57212. /**
  57213. * Computes a new Color4 converted from the current one to gamma space
  57214. * @returns a new Color4 object
  57215. */
  57216. toGammaSpace(): Color4;
  57217. /**
  57218. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57219. * @param convertedColor defines the Color4 object where to store the gamma space version
  57220. * @returns the unmodified Color4
  57221. */
  57222. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57223. /**
  57224. * Creates a new Color4 from the string containing valid hexadecimal values
  57225. * @param hex defines a string containing valid hexadecimal values
  57226. * @returns a new Color4 object
  57227. */
  57228. static FromHexString(hex: string): Color4;
  57229. /**
  57230. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57231. * @param left defines the start value
  57232. * @param right defines the end value
  57233. * @param amount defines the gradient factor
  57234. * @returns a new Color4 object
  57235. */
  57236. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57237. /**
  57238. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57239. * @param left defines the start value
  57240. * @param right defines the end value
  57241. * @param amount defines the gradient factor
  57242. * @param result defines the Color4 object where to store data
  57243. */
  57244. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57245. /**
  57246. * Creates a new Color4 from a Color3 and an alpha value
  57247. * @param color3 defines the source Color3 to read from
  57248. * @param alpha defines the alpha component (1.0 by default)
  57249. * @returns a new Color4 object
  57250. */
  57251. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57252. /**
  57253. * Creates a new Color4 from the starting index element of the given array
  57254. * @param array defines the source array to read from
  57255. * @param offset defines the offset in the source array
  57256. * @returns a new Color4 object
  57257. */
  57258. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57259. /**
  57260. * Creates a new Color3 from integer values (< 256)
  57261. * @param r defines the red component to read from (value between 0 and 255)
  57262. * @param g defines the green component to read from (value between 0 and 255)
  57263. * @param b defines the blue component to read from (value between 0 and 255)
  57264. * @param a defines the alpha component to read from (value between 0 and 255)
  57265. * @returns a new Color3 object
  57266. */
  57267. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57268. /**
  57269. * Check the content of a given array and convert it to an array containing RGBA data
  57270. * If the original array was already containing count * 4 values then it is returned directly
  57271. * @param colors defines the array to check
  57272. * @param count defines the number of RGBA data to expect
  57273. * @returns an array containing count * 4 values (RGBA)
  57274. */
  57275. static CheckColors4(colors: number[], count: number): number[];
  57276. }
  57277. /**
  57278. * Class representing a vector containing 2 coordinates
  57279. */
  57280. export class Vector2 {
  57281. /** defines the first coordinate */
  57282. x: number;
  57283. /** defines the second coordinate */
  57284. y: number;
  57285. /**
  57286. * Creates a new Vector2 from the given x and y coordinates
  57287. * @param x defines the first coordinate
  57288. * @param y defines the second coordinate
  57289. */
  57290. constructor(
  57291. /** defines the first coordinate */
  57292. x?: number,
  57293. /** defines the second coordinate */
  57294. y?: number);
  57295. /**
  57296. * Gets a string with the Vector2 coordinates
  57297. * @returns a string with the Vector2 coordinates
  57298. */
  57299. toString(): string;
  57300. /**
  57301. * Gets class name
  57302. * @returns the string "Vector2"
  57303. */
  57304. getClassName(): string;
  57305. /**
  57306. * Gets current vector hash code
  57307. * @returns the Vector2 hash code as a number
  57308. */
  57309. getHashCode(): number;
  57310. /**
  57311. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57312. * @param array defines the source array
  57313. * @param index defines the offset in source array
  57314. * @returns the current Vector2
  57315. */
  57316. toArray(array: FloatArray, index?: number): Vector2;
  57317. /**
  57318. * Copy the current vector to an array
  57319. * @returns a new array with 2 elements: the Vector2 coordinates.
  57320. */
  57321. asArray(): number[];
  57322. /**
  57323. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57324. * @param source defines the source Vector2
  57325. * @returns the current updated Vector2
  57326. */
  57327. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57328. /**
  57329. * Sets the Vector2 coordinates with the given floats
  57330. * @param x defines the first coordinate
  57331. * @param y defines the second coordinate
  57332. * @returns the current updated Vector2
  57333. */
  57334. copyFromFloats(x: number, y: number): Vector2;
  57335. /**
  57336. * Sets the Vector2 coordinates with the given floats
  57337. * @param x defines the first coordinate
  57338. * @param y defines the second coordinate
  57339. * @returns the current updated Vector2
  57340. */
  57341. set(x: number, y: number): Vector2;
  57342. /**
  57343. * Add another vector with the current one
  57344. * @param otherVector defines the other vector
  57345. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57346. */
  57347. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57348. /**
  57349. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57350. * @param otherVector defines the other vector
  57351. * @param result defines the target vector
  57352. * @returns the unmodified current Vector2
  57353. */
  57354. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57355. /**
  57356. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57357. * @param otherVector defines the other vector
  57358. * @returns the current updated Vector2
  57359. */
  57360. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57361. /**
  57362. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57363. * @param otherVector defines the other vector
  57364. * @returns a new Vector2
  57365. */
  57366. addVector3(otherVector: Vector3): Vector2;
  57367. /**
  57368. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57369. * @param otherVector defines the other vector
  57370. * @returns a new Vector2
  57371. */
  57372. subtract(otherVector: Vector2): Vector2;
  57373. /**
  57374. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57375. * @param otherVector defines the other vector
  57376. * @param result defines the target vector
  57377. * @returns the unmodified current Vector2
  57378. */
  57379. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57380. /**
  57381. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57382. * @param otherVector defines the other vector
  57383. * @returns the current updated Vector2
  57384. */
  57385. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57386. /**
  57387. * Multiplies in place the current Vector2 coordinates by the given ones
  57388. * @param otherVector defines the other vector
  57389. * @returns the current updated Vector2
  57390. */
  57391. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57392. /**
  57393. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57394. * @param otherVector defines the other vector
  57395. * @returns a new Vector2
  57396. */
  57397. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57398. /**
  57399. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57400. * @param otherVector defines the other vector
  57401. * @param result defines the target vector
  57402. * @returns the unmodified current Vector2
  57403. */
  57404. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57405. /**
  57406. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57407. * @param x defines the first coordinate
  57408. * @param y defines the second coordinate
  57409. * @returns a new Vector2
  57410. */
  57411. multiplyByFloats(x: number, y: number): Vector2;
  57412. /**
  57413. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57414. * @param otherVector defines the other vector
  57415. * @returns a new Vector2
  57416. */
  57417. divide(otherVector: Vector2): Vector2;
  57418. /**
  57419. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57420. * @param otherVector defines the other vector
  57421. * @param result defines the target vector
  57422. * @returns the unmodified current Vector2
  57423. */
  57424. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57425. /**
  57426. * Divides the current Vector2 coordinates by the given ones
  57427. * @param otherVector defines the other vector
  57428. * @returns the current updated Vector2
  57429. */
  57430. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57431. /**
  57432. * Gets a new Vector2 with current Vector2 negated coordinates
  57433. * @returns a new Vector2
  57434. */
  57435. negate(): Vector2;
  57436. /**
  57437. * Multiply the Vector2 coordinates by scale
  57438. * @param scale defines the scaling factor
  57439. * @returns the current updated Vector2
  57440. */
  57441. scaleInPlace(scale: number): Vector2;
  57442. /**
  57443. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57444. * @param scale defines the scaling factor
  57445. * @returns a new Vector2
  57446. */
  57447. scale(scale: number): Vector2;
  57448. /**
  57449. * Scale the current Vector2 values by a factor to a given Vector2
  57450. * @param scale defines the scale factor
  57451. * @param result defines the Vector2 object where to store the result
  57452. * @returns the unmodified current Vector2
  57453. */
  57454. scaleToRef(scale: number, result: Vector2): Vector2;
  57455. /**
  57456. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57457. * @param scale defines the scale factor
  57458. * @param result defines the Vector2 object where to store the result
  57459. * @returns the unmodified current Vector2
  57460. */
  57461. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57462. /**
  57463. * Gets a boolean if two vectors are equals
  57464. * @param otherVector defines the other vector
  57465. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57466. */
  57467. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57468. /**
  57469. * Gets a boolean if two vectors are equals (using an epsilon value)
  57470. * @param otherVector defines the other vector
  57471. * @param epsilon defines the minimal distance to consider equality
  57472. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57473. */
  57474. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57475. /**
  57476. * Gets a new Vector2 from current Vector2 floored values
  57477. * @returns a new Vector2
  57478. */
  57479. floor(): Vector2;
  57480. /**
  57481. * Gets a new Vector2 from current Vector2 floored values
  57482. * @returns a new Vector2
  57483. */
  57484. fract(): Vector2;
  57485. /**
  57486. * Gets the length of the vector
  57487. * @returns the vector length (float)
  57488. */
  57489. length(): number;
  57490. /**
  57491. * Gets the vector squared length
  57492. * @returns the vector squared length (float)
  57493. */
  57494. lengthSquared(): number;
  57495. /**
  57496. * Normalize the vector
  57497. * @returns the current updated Vector2
  57498. */
  57499. normalize(): Vector2;
  57500. /**
  57501. * Gets a new Vector2 copied from the Vector2
  57502. * @returns a new Vector2
  57503. */
  57504. clone(): Vector2;
  57505. /**
  57506. * Gets a new Vector2(0, 0)
  57507. * @returns a new Vector2
  57508. */
  57509. static Zero(): Vector2;
  57510. /**
  57511. * Gets a new Vector2(1, 1)
  57512. * @returns a new Vector2
  57513. */
  57514. static One(): Vector2;
  57515. /**
  57516. * Gets a new Vector2 set from the given index element of the given array
  57517. * @param array defines the data source
  57518. * @param offset defines the offset in the data source
  57519. * @returns a new Vector2
  57520. */
  57521. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57522. /**
  57523. * Sets "result" from the given index element of the given array
  57524. * @param array defines the data source
  57525. * @param offset defines the offset in the data source
  57526. * @param result defines the target vector
  57527. */
  57528. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57529. /**
  57530. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57531. * @param value1 defines 1st point of control
  57532. * @param value2 defines 2nd point of control
  57533. * @param value3 defines 3rd point of control
  57534. * @param value4 defines 4th point of control
  57535. * @param amount defines the interpolation factor
  57536. * @returns a new Vector2
  57537. */
  57538. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57539. /**
  57540. * 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".
  57541. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57542. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57543. * @param value defines the value to clamp
  57544. * @param min defines the lower limit
  57545. * @param max defines the upper limit
  57546. * @returns a new Vector2
  57547. */
  57548. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57549. /**
  57550. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57551. * @param value1 defines the 1st control point
  57552. * @param tangent1 defines the outgoing tangent
  57553. * @param value2 defines the 2nd control point
  57554. * @param tangent2 defines the incoming tangent
  57555. * @param amount defines the interpolation factor
  57556. * @returns a new Vector2
  57557. */
  57558. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57559. /**
  57560. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57561. * @param start defines the start vector
  57562. * @param end defines the end vector
  57563. * @param amount defines the interpolation factor
  57564. * @returns a new Vector2
  57565. */
  57566. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57567. /**
  57568. * Gets the dot product of the vector "left" and the vector "right"
  57569. * @param left defines first vector
  57570. * @param right defines second vector
  57571. * @returns the dot product (float)
  57572. */
  57573. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57574. /**
  57575. * Returns a new Vector2 equal to the normalized given vector
  57576. * @param vector defines the vector to normalize
  57577. * @returns a new Vector2
  57578. */
  57579. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57580. /**
  57581. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57582. * @param left defines 1st vector
  57583. * @param right defines 2nd vector
  57584. * @returns a new Vector2
  57585. */
  57586. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57587. /**
  57588. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57589. * @param left defines 1st vector
  57590. * @param right defines 2nd vector
  57591. * @returns a new Vector2
  57592. */
  57593. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57594. /**
  57595. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57596. * @param vector defines the vector to transform
  57597. * @param transformation defines the matrix to apply
  57598. * @returns a new Vector2
  57599. */
  57600. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57601. /**
  57602. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57603. * @param vector defines the vector to transform
  57604. * @param transformation defines the matrix to apply
  57605. * @param result defines the target vector
  57606. */
  57607. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57608. /**
  57609. * Determines if a given vector is included in a triangle
  57610. * @param p defines the vector to test
  57611. * @param p0 defines 1st triangle point
  57612. * @param p1 defines 2nd triangle point
  57613. * @param p2 defines 3rd triangle point
  57614. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57615. */
  57616. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57617. /**
  57618. * Gets the distance between the vectors "value1" and "value2"
  57619. * @param value1 defines first vector
  57620. * @param value2 defines second vector
  57621. * @returns the distance between vectors
  57622. */
  57623. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57624. /**
  57625. * Returns the squared distance between the vectors "value1" and "value2"
  57626. * @param value1 defines first vector
  57627. * @param value2 defines second vector
  57628. * @returns the squared distance between vectors
  57629. */
  57630. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57631. /**
  57632. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57633. * @param value1 defines first vector
  57634. * @param value2 defines second vector
  57635. * @returns a new Vector2
  57636. */
  57637. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57638. /**
  57639. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57640. * @param p defines the middle point
  57641. * @param segA defines one point of the segment
  57642. * @param segB defines the other point of the segment
  57643. * @returns the shortest distance
  57644. */
  57645. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57646. }
  57647. /**
  57648. * Classed used to store (x,y,z) vector representation
  57649. * A Vector3 is the main object used in 3D geometry
  57650. * It can represent etiher the coordinates of a point the space, either a direction
  57651. * Reminder: js uses a left handed forward facing system
  57652. */
  57653. export class Vector3 {
  57654. /**
  57655. * Defines the first coordinates (on X axis)
  57656. */
  57657. x: number;
  57658. /**
  57659. * Defines the second coordinates (on Y axis)
  57660. */
  57661. y: number;
  57662. /**
  57663. * Defines the third coordinates (on Z axis)
  57664. */
  57665. z: number;
  57666. private static _UpReadOnly;
  57667. /**
  57668. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57669. * @param x defines the first coordinates (on X axis)
  57670. * @param y defines the second coordinates (on Y axis)
  57671. * @param z defines the third coordinates (on Z axis)
  57672. */
  57673. constructor(
  57674. /**
  57675. * Defines the first coordinates (on X axis)
  57676. */
  57677. x?: number,
  57678. /**
  57679. * Defines the second coordinates (on Y axis)
  57680. */
  57681. y?: number,
  57682. /**
  57683. * Defines the third coordinates (on Z axis)
  57684. */
  57685. z?: number);
  57686. /**
  57687. * Creates a string representation of the Vector3
  57688. * @returns a string with the Vector3 coordinates.
  57689. */
  57690. toString(): string;
  57691. /**
  57692. * Gets the class name
  57693. * @returns the string "Vector3"
  57694. */
  57695. getClassName(): string;
  57696. /**
  57697. * Creates the Vector3 hash code
  57698. * @returns a number which tends to be unique between Vector3 instances
  57699. */
  57700. getHashCode(): number;
  57701. /**
  57702. * Creates an array containing three elements : the coordinates of the Vector3
  57703. * @returns a new array of numbers
  57704. */
  57705. asArray(): number[];
  57706. /**
  57707. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57708. * @param array defines the destination array
  57709. * @param index defines the offset in the destination array
  57710. * @returns the current Vector3
  57711. */
  57712. toArray(array: FloatArray, index?: number): Vector3;
  57713. /**
  57714. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57715. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57716. */
  57717. toQuaternion(): Quaternion;
  57718. /**
  57719. * Adds the given vector to the current Vector3
  57720. * @param otherVector defines the second operand
  57721. * @returns the current updated Vector3
  57722. */
  57723. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57724. /**
  57725. * Adds the given coordinates to the current Vector3
  57726. * @param x defines the x coordinate of the operand
  57727. * @param y defines the y coordinate of the operand
  57728. * @param z defines the z coordinate of the operand
  57729. * @returns the current updated Vector3
  57730. */
  57731. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57732. /**
  57733. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57734. * @param otherVector defines the second operand
  57735. * @returns the resulting Vector3
  57736. */
  57737. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57738. /**
  57739. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57740. * @param otherVector defines the second operand
  57741. * @param result defines the Vector3 object where to store the result
  57742. * @returns the current Vector3
  57743. */
  57744. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57745. /**
  57746. * Subtract the given vector from the current Vector3
  57747. * @param otherVector defines the second operand
  57748. * @returns the current updated Vector3
  57749. */
  57750. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57751. /**
  57752. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57753. * @param otherVector defines the second operand
  57754. * @returns the resulting Vector3
  57755. */
  57756. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57757. /**
  57758. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57759. * @param otherVector defines the second operand
  57760. * @param result defines the Vector3 object where to store the result
  57761. * @returns the current Vector3
  57762. */
  57763. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57764. /**
  57765. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57766. * @param x defines the x coordinate of the operand
  57767. * @param y defines the y coordinate of the operand
  57768. * @param z defines the z coordinate of the operand
  57769. * @returns the resulting Vector3
  57770. */
  57771. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57772. /**
  57773. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57774. * @param x defines the x coordinate of the operand
  57775. * @param y defines the y coordinate of the operand
  57776. * @param z defines the z coordinate of the operand
  57777. * @param result defines the Vector3 object where to store the result
  57778. * @returns the current Vector3
  57779. */
  57780. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57781. /**
  57782. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57783. * @returns a new Vector3
  57784. */
  57785. negate(): Vector3;
  57786. /**
  57787. * Multiplies the Vector3 coordinates by the float "scale"
  57788. * @param scale defines the multiplier factor
  57789. * @returns the current updated Vector3
  57790. */
  57791. scaleInPlace(scale: number): Vector3;
  57792. /**
  57793. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57794. * @param scale defines the multiplier factor
  57795. * @returns a new Vector3
  57796. */
  57797. scale(scale: number): Vector3;
  57798. /**
  57799. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57800. * @param scale defines the multiplier factor
  57801. * @param result defines the Vector3 object where to store the result
  57802. * @returns the current Vector3
  57803. */
  57804. scaleToRef(scale: number, result: Vector3): Vector3;
  57805. /**
  57806. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57807. * @param scale defines the scale factor
  57808. * @param result defines the Vector3 object where to store the result
  57809. * @returns the unmodified current Vector3
  57810. */
  57811. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57812. /**
  57813. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57814. * @param otherVector defines the second operand
  57815. * @returns true if both vectors are equals
  57816. */
  57817. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57818. /**
  57819. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57820. * @param otherVector defines the second operand
  57821. * @param epsilon defines the minimal distance to define values as equals
  57822. * @returns true if both vectors are distant less than epsilon
  57823. */
  57824. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57825. /**
  57826. * Returns true if the current Vector3 coordinates equals the given floats
  57827. * @param x defines the x coordinate of the operand
  57828. * @param y defines the y coordinate of the operand
  57829. * @param z defines the z coordinate of the operand
  57830. * @returns true if both vectors are equals
  57831. */
  57832. equalsToFloats(x: number, y: number, z: number): boolean;
  57833. /**
  57834. * Multiplies the current Vector3 coordinates by the given ones
  57835. * @param otherVector defines the second operand
  57836. * @returns the current updated Vector3
  57837. */
  57838. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57839. /**
  57840. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57841. * @param otherVector defines the second operand
  57842. * @returns the new Vector3
  57843. */
  57844. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57845. /**
  57846. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57847. * @param otherVector defines the second operand
  57848. * @param result defines the Vector3 object where to store the result
  57849. * @returns the current Vector3
  57850. */
  57851. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57852. /**
  57853. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57854. * @param x defines the x coordinate of the operand
  57855. * @param y defines the y coordinate of the operand
  57856. * @param z defines the z coordinate of the operand
  57857. * @returns the new Vector3
  57858. */
  57859. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57860. /**
  57861. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57862. * @param otherVector defines the second operand
  57863. * @returns the new Vector3
  57864. */
  57865. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57866. /**
  57867. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57868. * @param otherVector defines the second operand
  57869. * @param result defines the Vector3 object where to store the result
  57870. * @returns the current Vector3
  57871. */
  57872. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57873. /**
  57874. * Divides the current Vector3 coordinates by the given ones.
  57875. * @param otherVector defines the second operand
  57876. * @returns the current updated Vector3
  57877. */
  57878. divideInPlace(otherVector: Vector3): Vector3;
  57879. /**
  57880. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57881. * @param other defines the second operand
  57882. * @returns the current updated Vector3
  57883. */
  57884. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57885. /**
  57886. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57887. * @param other defines the second operand
  57888. * @returns the current updated Vector3
  57889. */
  57890. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57891. /**
  57892. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57893. * @param x defines the x coordinate of the operand
  57894. * @param y defines the y coordinate of the operand
  57895. * @param z defines the z coordinate of the operand
  57896. * @returns the current updated Vector3
  57897. */
  57898. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57899. /**
  57900. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57901. * @param x defines the x coordinate of the operand
  57902. * @param y defines the y coordinate of the operand
  57903. * @param z defines the z coordinate of the operand
  57904. * @returns the current updated Vector3
  57905. */
  57906. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57907. /**
  57908. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57909. * Check if is non uniform within a certain amount of decimal places to account for this
  57910. * @param epsilon the amount the values can differ
  57911. * @returns if the the vector is non uniform to a certain number of decimal places
  57912. */
  57913. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57914. /**
  57915. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57916. */
  57917. readonly isNonUniform: boolean;
  57918. /**
  57919. * Gets a new Vector3 from current Vector3 floored values
  57920. * @returns a new Vector3
  57921. */
  57922. floor(): Vector3;
  57923. /**
  57924. * Gets a new Vector3 from current Vector3 floored values
  57925. * @returns a new Vector3
  57926. */
  57927. fract(): Vector3;
  57928. /**
  57929. * Gets the length of the Vector3
  57930. * @returns the length of the Vecto3
  57931. */
  57932. length(): number;
  57933. /**
  57934. * Gets the squared length of the Vector3
  57935. * @returns squared length of the Vector3
  57936. */
  57937. lengthSquared(): number;
  57938. /**
  57939. * Normalize the current Vector3.
  57940. * Please note that this is an in place operation.
  57941. * @returns the current updated Vector3
  57942. */
  57943. normalize(): Vector3;
  57944. /**
  57945. * Reorders the x y z properties of the vector in place
  57946. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57947. * @returns the current updated vector
  57948. */
  57949. reorderInPlace(order: string): this;
  57950. /**
  57951. * Rotates the vector around 0,0,0 by a quaternion
  57952. * @param quaternion the rotation quaternion
  57953. * @param result vector to store the result
  57954. * @returns the resulting vector
  57955. */
  57956. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57957. /**
  57958. * Rotates a vector around a given point
  57959. * @param quaternion the rotation quaternion
  57960. * @param point the point to rotate around
  57961. * @param result vector to store the result
  57962. * @returns the resulting vector
  57963. */
  57964. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  57965. /**
  57966. * Normalize the current Vector3 with the given input length.
  57967. * Please note that this is an in place operation.
  57968. * @param len the length of the vector
  57969. * @returns the current updated Vector3
  57970. */
  57971. normalizeFromLength(len: number): Vector3;
  57972. /**
  57973. * Normalize the current Vector3 to a new vector
  57974. * @returns the new Vector3
  57975. */
  57976. normalizeToNew(): Vector3;
  57977. /**
  57978. * Normalize the current Vector3 to the reference
  57979. * @param reference define the Vector3 to update
  57980. * @returns the updated Vector3
  57981. */
  57982. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  57983. /**
  57984. * Creates a new Vector3 copied from the current Vector3
  57985. * @returns the new Vector3
  57986. */
  57987. clone(): Vector3;
  57988. /**
  57989. * Copies the given vector coordinates to the current Vector3 ones
  57990. * @param source defines the source Vector3
  57991. * @returns the current updated Vector3
  57992. */
  57993. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  57994. /**
  57995. * Copies the given floats to the current Vector3 coordinates
  57996. * @param x defines the x coordinate of the operand
  57997. * @param y defines the y coordinate of the operand
  57998. * @param z defines the z coordinate of the operand
  57999. * @returns the current updated Vector3
  58000. */
  58001. copyFromFloats(x: number, y: number, z: number): Vector3;
  58002. /**
  58003. * Copies the given floats to the current Vector3 coordinates
  58004. * @param x defines the x coordinate of the operand
  58005. * @param y defines the y coordinate of the operand
  58006. * @param z defines the z coordinate of the operand
  58007. * @returns the current updated Vector3
  58008. */
  58009. set(x: number, y: number, z: number): Vector3;
  58010. /**
  58011. * Copies the given float to the current Vector3 coordinates
  58012. * @param v defines the x, y and z coordinates of the operand
  58013. * @returns the current updated Vector3
  58014. */
  58015. setAll(v: number): Vector3;
  58016. /**
  58017. * Get the clip factor between two vectors
  58018. * @param vector0 defines the first operand
  58019. * @param vector1 defines the second operand
  58020. * @param axis defines the axis to use
  58021. * @param size defines the size along the axis
  58022. * @returns the clip factor
  58023. */
  58024. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58025. /**
  58026. * Get angle between two vectors
  58027. * @param vector0 angle between vector0 and vector1
  58028. * @param vector1 angle between vector0 and vector1
  58029. * @param normal direction of the normal
  58030. * @return the angle between vector0 and vector1
  58031. */
  58032. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58033. /**
  58034. * Returns a new Vector3 set from the index "offset" of the given array
  58035. * @param array defines the source array
  58036. * @param offset defines the offset in the source array
  58037. * @returns the new Vector3
  58038. */
  58039. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58040. /**
  58041. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58042. * This function is deprecated. Use FromArray instead
  58043. * @param array defines the source array
  58044. * @param offset defines the offset in the source array
  58045. * @returns the new Vector3
  58046. */
  58047. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58048. /**
  58049. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58050. * @param array defines the source array
  58051. * @param offset defines the offset in the source array
  58052. * @param result defines the Vector3 where to store the result
  58053. */
  58054. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58055. /**
  58056. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58057. * This function is deprecated. Use FromArrayToRef instead.
  58058. * @param array defines the source array
  58059. * @param offset defines the offset in the source array
  58060. * @param result defines the Vector3 where to store the result
  58061. */
  58062. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58063. /**
  58064. * Sets the given vector "result" with the given floats.
  58065. * @param x defines the x coordinate of the source
  58066. * @param y defines the y coordinate of the source
  58067. * @param z defines the z coordinate of the source
  58068. * @param result defines the Vector3 where to store the result
  58069. */
  58070. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58071. /**
  58072. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58073. * @returns a new empty Vector3
  58074. */
  58075. static Zero(): Vector3;
  58076. /**
  58077. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58078. * @returns a new unit Vector3
  58079. */
  58080. static One(): Vector3;
  58081. /**
  58082. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58083. * @returns a new up Vector3
  58084. */
  58085. static Up(): Vector3;
  58086. /**
  58087. * Gets a up Vector3 that must not be updated
  58088. */
  58089. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58090. /**
  58091. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58092. * @returns a new down Vector3
  58093. */
  58094. static Down(): Vector3;
  58095. /**
  58096. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58097. * @returns a new forward Vector3
  58098. */
  58099. static Forward(): Vector3;
  58100. /**
  58101. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58102. * @returns a new forward Vector3
  58103. */
  58104. static Backward(): Vector3;
  58105. /**
  58106. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58107. * @returns a new right Vector3
  58108. */
  58109. static Right(): Vector3;
  58110. /**
  58111. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58112. * @returns a new left Vector3
  58113. */
  58114. static Left(): Vector3;
  58115. /**
  58116. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58117. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58118. * @param vector defines the Vector3 to transform
  58119. * @param transformation defines the transformation matrix
  58120. * @returns the transformed Vector3
  58121. */
  58122. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58123. /**
  58124. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58125. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58126. * @param vector defines the Vector3 to transform
  58127. * @param transformation defines the transformation matrix
  58128. * @param result defines the Vector3 where to store the result
  58129. */
  58130. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58131. /**
  58132. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58133. * This method computes tranformed coordinates only, not transformed direction vectors
  58134. * @param x define the x coordinate of the source vector
  58135. * @param y define the y coordinate of the source vector
  58136. * @param z define the z coordinate of the source vector
  58137. * @param transformation defines the transformation matrix
  58138. * @param result defines the Vector3 where to store the result
  58139. */
  58140. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58141. /**
  58142. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58143. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58144. * @param vector defines the Vector3 to transform
  58145. * @param transformation defines the transformation matrix
  58146. * @returns the new Vector3
  58147. */
  58148. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58149. /**
  58150. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58151. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58152. * @param vector defines the Vector3 to transform
  58153. * @param transformation defines the transformation matrix
  58154. * @param result defines the Vector3 where to store the result
  58155. */
  58156. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58157. /**
  58158. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58159. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58160. * @param x define the x coordinate of the source vector
  58161. * @param y define the y coordinate of the source vector
  58162. * @param z define the z coordinate of the source vector
  58163. * @param transformation defines the transformation matrix
  58164. * @param result defines the Vector3 where to store the result
  58165. */
  58166. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58167. /**
  58168. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58169. * @param value1 defines the first control point
  58170. * @param value2 defines the second control point
  58171. * @param value3 defines the third control point
  58172. * @param value4 defines the fourth control point
  58173. * @param amount defines the amount on the spline to use
  58174. * @returns the new Vector3
  58175. */
  58176. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58177. /**
  58178. * 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"
  58179. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58180. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58181. * @param value defines the current value
  58182. * @param min defines the lower range value
  58183. * @param max defines the upper range value
  58184. * @returns the new Vector3
  58185. */
  58186. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58187. /**
  58188. * 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"
  58189. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58190. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58191. * @param value defines the current value
  58192. * @param min defines the lower range value
  58193. * @param max defines the upper range value
  58194. * @param result defines the Vector3 where to store the result
  58195. */
  58196. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58197. /**
  58198. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58199. * @param value1 defines the first control point
  58200. * @param tangent1 defines the first tangent vector
  58201. * @param value2 defines the second control point
  58202. * @param tangent2 defines the second tangent vector
  58203. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58204. * @returns the new Vector3
  58205. */
  58206. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58207. /**
  58208. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58209. * @param start defines the start value
  58210. * @param end defines the end value
  58211. * @param amount max defines amount between both (between 0 and 1)
  58212. * @returns the new Vector3
  58213. */
  58214. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58215. /**
  58216. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58217. * @param start defines the start value
  58218. * @param end defines the end value
  58219. * @param amount max defines amount between both (between 0 and 1)
  58220. * @param result defines the Vector3 where to store the result
  58221. */
  58222. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58223. /**
  58224. * Returns the dot product (float) between the vectors "left" and "right"
  58225. * @param left defines the left operand
  58226. * @param right defines the right operand
  58227. * @returns the dot product
  58228. */
  58229. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58230. /**
  58231. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58232. * The cross product is then orthogonal to both "left" and "right"
  58233. * @param left defines the left operand
  58234. * @param right defines the right operand
  58235. * @returns the cross product
  58236. */
  58237. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58238. /**
  58239. * Sets the given vector "result" with the cross product of "left" and "right"
  58240. * The cross product is then orthogonal to both "left" and "right"
  58241. * @param left defines the left operand
  58242. * @param right defines the right operand
  58243. * @param result defines the Vector3 where to store the result
  58244. */
  58245. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58246. /**
  58247. * Returns a new Vector3 as the normalization of the given vector
  58248. * @param vector defines the Vector3 to normalize
  58249. * @returns the new Vector3
  58250. */
  58251. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58252. /**
  58253. * Sets the given vector "result" with the normalization of the given first vector
  58254. * @param vector defines the Vector3 to normalize
  58255. * @param result defines the Vector3 where to store the result
  58256. */
  58257. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58258. /**
  58259. * Project a Vector3 onto screen space
  58260. * @param vector defines the Vector3 to project
  58261. * @param world defines the world matrix to use
  58262. * @param transform defines the transform (view x projection) matrix to use
  58263. * @param viewport defines the screen viewport to use
  58264. * @returns the new Vector3
  58265. */
  58266. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58267. /** @hidden */
  58268. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58269. /**
  58270. * Unproject from screen space to object space
  58271. * @param source defines the screen space Vector3 to use
  58272. * @param viewportWidth defines the current width of the viewport
  58273. * @param viewportHeight defines the current height of the viewport
  58274. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58275. * @param transform defines the transform (view x projection) matrix to use
  58276. * @returns the new Vector3
  58277. */
  58278. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58279. /**
  58280. * Unproject from screen space to object space
  58281. * @param source defines the screen space Vector3 to use
  58282. * @param viewportWidth defines the current width of the viewport
  58283. * @param viewportHeight defines the current height of the viewport
  58284. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58285. * @param view defines the view matrix to use
  58286. * @param projection defines the projection matrix to use
  58287. * @returns the new Vector3
  58288. */
  58289. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58290. /**
  58291. * Unproject from screen space to object space
  58292. * @param source defines the screen space Vector3 to use
  58293. * @param viewportWidth defines the current width of the viewport
  58294. * @param viewportHeight defines the current height of the viewport
  58295. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58296. * @param view defines the view matrix to use
  58297. * @param projection defines the projection matrix to use
  58298. * @param result defines the Vector3 where to store the result
  58299. */
  58300. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58301. /**
  58302. * Unproject from screen space to object space
  58303. * @param sourceX defines the screen space x coordinate to use
  58304. * @param sourceY defines the screen space y coordinate to use
  58305. * @param sourceZ defines the screen space z coordinate to use
  58306. * @param viewportWidth defines the current width of the viewport
  58307. * @param viewportHeight defines the current height of the viewport
  58308. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58309. * @param view defines the view matrix to use
  58310. * @param projection defines the projection matrix to use
  58311. * @param result defines the Vector3 where to store the result
  58312. */
  58313. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58314. /**
  58315. * Gets the minimal coordinate values between two Vector3
  58316. * @param left defines the first operand
  58317. * @param right defines the second operand
  58318. * @returns the new Vector3
  58319. */
  58320. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58321. /**
  58322. * Gets the maximal coordinate values between two Vector3
  58323. * @param left defines the first operand
  58324. * @param right defines the second operand
  58325. * @returns the new Vector3
  58326. */
  58327. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58328. /**
  58329. * Returns the distance between the vectors "value1" and "value2"
  58330. * @param value1 defines the first operand
  58331. * @param value2 defines the second operand
  58332. * @returns the distance
  58333. */
  58334. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58335. /**
  58336. * Returns the squared distance between the vectors "value1" and "value2"
  58337. * @param value1 defines the first operand
  58338. * @param value2 defines the second operand
  58339. * @returns the squared distance
  58340. */
  58341. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58342. /**
  58343. * Returns a new Vector3 located at the center between "value1" and "value2"
  58344. * @param value1 defines the first operand
  58345. * @param value2 defines the second operand
  58346. * @returns the new Vector3
  58347. */
  58348. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58349. /**
  58350. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58351. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58352. * to something in order to rotate it from its local system to the given target system
  58353. * Note: axis1, axis2 and axis3 are normalized during this operation
  58354. * @param axis1 defines the first axis
  58355. * @param axis2 defines the second axis
  58356. * @param axis3 defines the third axis
  58357. * @returns a new Vector3
  58358. */
  58359. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58360. /**
  58361. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58362. * @param axis1 defines the first axis
  58363. * @param axis2 defines the second axis
  58364. * @param axis3 defines the third axis
  58365. * @param ref defines the Vector3 where to store the result
  58366. */
  58367. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58368. }
  58369. /**
  58370. * Vector4 class created for EulerAngle class conversion to Quaternion
  58371. */
  58372. export class Vector4 {
  58373. /** x value of the vector */
  58374. x: number;
  58375. /** y value of the vector */
  58376. y: number;
  58377. /** z value of the vector */
  58378. z: number;
  58379. /** w value of the vector */
  58380. w: number;
  58381. /**
  58382. * Creates a Vector4 object from the given floats.
  58383. * @param x x value of the vector
  58384. * @param y y value of the vector
  58385. * @param z z value of the vector
  58386. * @param w w value of the vector
  58387. */
  58388. constructor(
  58389. /** x value of the vector */
  58390. x: number,
  58391. /** y value of the vector */
  58392. y: number,
  58393. /** z value of the vector */
  58394. z: number,
  58395. /** w value of the vector */
  58396. w: number);
  58397. /**
  58398. * Returns the string with the Vector4 coordinates.
  58399. * @returns a string containing all the vector values
  58400. */
  58401. toString(): string;
  58402. /**
  58403. * Returns the string "Vector4".
  58404. * @returns "Vector4"
  58405. */
  58406. getClassName(): string;
  58407. /**
  58408. * Returns the Vector4 hash code.
  58409. * @returns a unique hash code
  58410. */
  58411. getHashCode(): number;
  58412. /**
  58413. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58414. * @returns the resulting array
  58415. */
  58416. asArray(): number[];
  58417. /**
  58418. * Populates the given array from the given index with the Vector4 coordinates.
  58419. * @param array array to populate
  58420. * @param index index of the array to start at (default: 0)
  58421. * @returns the Vector4.
  58422. */
  58423. toArray(array: FloatArray, index?: number): Vector4;
  58424. /**
  58425. * Adds the given vector to the current Vector4.
  58426. * @param otherVector the vector to add
  58427. * @returns the updated Vector4.
  58428. */
  58429. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58430. /**
  58431. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58432. * @param otherVector the vector to add
  58433. * @returns the resulting vector
  58434. */
  58435. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58436. /**
  58437. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58438. * @param otherVector the vector to add
  58439. * @param result the vector to store the result
  58440. * @returns the current Vector4.
  58441. */
  58442. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58443. /**
  58444. * Subtract in place the given vector from the current Vector4.
  58445. * @param otherVector the vector to subtract
  58446. * @returns the updated Vector4.
  58447. */
  58448. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58449. /**
  58450. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58451. * @param otherVector the vector to add
  58452. * @returns the new vector with the result
  58453. */
  58454. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58455. /**
  58456. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58457. * @param otherVector the vector to subtract
  58458. * @param result the vector to store the result
  58459. * @returns the current Vector4.
  58460. */
  58461. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58462. /**
  58463. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58464. */
  58465. /**
  58466. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58467. * @param x value to subtract
  58468. * @param y value to subtract
  58469. * @param z value to subtract
  58470. * @param w value to subtract
  58471. * @returns new vector containing the result
  58472. */
  58473. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58474. /**
  58475. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58476. * @param x value to subtract
  58477. * @param y value to subtract
  58478. * @param z value to subtract
  58479. * @param w value to subtract
  58480. * @param result the vector to store the result in
  58481. * @returns the current Vector4.
  58482. */
  58483. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58484. /**
  58485. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58486. * @returns a new vector with the negated values
  58487. */
  58488. negate(): Vector4;
  58489. /**
  58490. * Multiplies the current Vector4 coordinates by scale (float).
  58491. * @param scale the number to scale with
  58492. * @returns the updated Vector4.
  58493. */
  58494. scaleInPlace(scale: number): Vector4;
  58495. /**
  58496. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58497. * @param scale the number to scale with
  58498. * @returns a new vector with the result
  58499. */
  58500. scale(scale: number): Vector4;
  58501. /**
  58502. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58503. * @param scale the number to scale with
  58504. * @param result a vector to store the result in
  58505. * @returns the current Vector4.
  58506. */
  58507. scaleToRef(scale: number, result: Vector4): Vector4;
  58508. /**
  58509. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58510. * @param scale defines the scale factor
  58511. * @param result defines the Vector4 object where to store the result
  58512. * @returns the unmodified current Vector4
  58513. */
  58514. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58515. /**
  58516. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58517. * @param otherVector the vector to compare against
  58518. * @returns true if they are equal
  58519. */
  58520. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58521. /**
  58522. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58523. * @param otherVector vector to compare against
  58524. * @param epsilon (Default: very small number)
  58525. * @returns true if they are equal
  58526. */
  58527. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58528. /**
  58529. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58530. * @param x x value to compare against
  58531. * @param y y value to compare against
  58532. * @param z z value to compare against
  58533. * @param w w value to compare against
  58534. * @returns true if equal
  58535. */
  58536. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58537. /**
  58538. * Multiplies in place the current Vector4 by the given one.
  58539. * @param otherVector vector to multiple with
  58540. * @returns the updated Vector4.
  58541. */
  58542. multiplyInPlace(otherVector: Vector4): Vector4;
  58543. /**
  58544. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58545. * @param otherVector vector to multiple with
  58546. * @returns resulting new vector
  58547. */
  58548. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58549. /**
  58550. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58551. * @param otherVector vector to multiple with
  58552. * @param result vector to store the result
  58553. * @returns the current Vector4.
  58554. */
  58555. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58556. /**
  58557. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58558. * @param x x value multiply with
  58559. * @param y y value multiply with
  58560. * @param z z value multiply with
  58561. * @param w w value multiply with
  58562. * @returns resulting new vector
  58563. */
  58564. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58565. /**
  58566. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58567. * @param otherVector vector to devide with
  58568. * @returns resulting new vector
  58569. */
  58570. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58571. /**
  58572. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58573. * @param otherVector vector to devide with
  58574. * @param result vector to store the result
  58575. * @returns the current Vector4.
  58576. */
  58577. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58578. /**
  58579. * Divides the current Vector3 coordinates by the given ones.
  58580. * @param otherVector vector to devide with
  58581. * @returns the updated Vector3.
  58582. */
  58583. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58584. /**
  58585. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58586. * @param other defines the second operand
  58587. * @returns the current updated Vector4
  58588. */
  58589. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58590. /**
  58591. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58592. * @param other defines the second operand
  58593. * @returns the current updated Vector4
  58594. */
  58595. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58596. /**
  58597. * Gets a new Vector4 from current Vector4 floored values
  58598. * @returns a new Vector4
  58599. */
  58600. floor(): Vector4;
  58601. /**
  58602. * Gets a new Vector4 from current Vector3 floored values
  58603. * @returns a new Vector4
  58604. */
  58605. fract(): Vector4;
  58606. /**
  58607. * Returns the Vector4 length (float).
  58608. * @returns the length
  58609. */
  58610. length(): number;
  58611. /**
  58612. * Returns the Vector4 squared length (float).
  58613. * @returns the length squared
  58614. */
  58615. lengthSquared(): number;
  58616. /**
  58617. * Normalizes in place the Vector4.
  58618. * @returns the updated Vector4.
  58619. */
  58620. normalize(): Vector4;
  58621. /**
  58622. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58623. * @returns this converted to a new vector3
  58624. */
  58625. toVector3(): Vector3;
  58626. /**
  58627. * Returns a new Vector4 copied from the current one.
  58628. * @returns the new cloned vector
  58629. */
  58630. clone(): Vector4;
  58631. /**
  58632. * Updates the current Vector4 with the given one coordinates.
  58633. * @param source the source vector to copy from
  58634. * @returns the updated Vector4.
  58635. */
  58636. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58637. /**
  58638. * Updates the current Vector4 coordinates with the given floats.
  58639. * @param x float to copy from
  58640. * @param y float to copy from
  58641. * @param z float to copy from
  58642. * @param w float to copy from
  58643. * @returns the updated Vector4.
  58644. */
  58645. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58646. /**
  58647. * Updates the current Vector4 coordinates with the given floats.
  58648. * @param x float to set from
  58649. * @param y float to set from
  58650. * @param z float to set from
  58651. * @param w float to set from
  58652. * @returns the updated Vector4.
  58653. */
  58654. set(x: number, y: number, z: number, w: number): Vector4;
  58655. /**
  58656. * Copies the given float to the current Vector3 coordinates
  58657. * @param v defines the x, y, z and w coordinates of the operand
  58658. * @returns the current updated Vector3
  58659. */
  58660. setAll(v: number): Vector4;
  58661. /**
  58662. * Returns a new Vector4 set from the starting index of the given array.
  58663. * @param array the array to pull values from
  58664. * @param offset the offset into the array to start at
  58665. * @returns the new vector
  58666. */
  58667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58668. /**
  58669. * Updates the given vector "result" from the starting index of the given array.
  58670. * @param array the array to pull values from
  58671. * @param offset the offset into the array to start at
  58672. * @param result the vector to store the result in
  58673. */
  58674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58675. /**
  58676. * Updates the given vector "result" from the starting index of the given Float32Array.
  58677. * @param array the array to pull values from
  58678. * @param offset the offset into the array to start at
  58679. * @param result the vector to store the result in
  58680. */
  58681. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58682. /**
  58683. * Updates the given vector "result" coordinates from the given floats.
  58684. * @param x float to set from
  58685. * @param y float to set from
  58686. * @param z float to set from
  58687. * @param w float to set from
  58688. * @param result the vector to the floats in
  58689. */
  58690. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58691. /**
  58692. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58693. * @returns the new vector
  58694. */
  58695. static Zero(): Vector4;
  58696. /**
  58697. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58698. * @returns the new vector
  58699. */
  58700. static One(): Vector4;
  58701. /**
  58702. * Returns a new normalized Vector4 from the given one.
  58703. * @param vector the vector to normalize
  58704. * @returns the vector
  58705. */
  58706. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58707. /**
  58708. * Updates the given vector "result" from the normalization of the given one.
  58709. * @param vector the vector to normalize
  58710. * @param result the vector to store the result in
  58711. */
  58712. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58713. /**
  58714. * Returns a vector with the minimum values from the left and right vectors
  58715. * @param left left vector to minimize
  58716. * @param right right vector to minimize
  58717. * @returns a new vector with the minimum of the left and right vector values
  58718. */
  58719. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58720. /**
  58721. * Returns a vector with the maximum values from the left and right vectors
  58722. * @param left left vector to maximize
  58723. * @param right right vector to maximize
  58724. * @returns a new vector with the maximum of the left and right vector values
  58725. */
  58726. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58727. /**
  58728. * Returns the distance (float) between the vectors "value1" and "value2".
  58729. * @param value1 value to calulate the distance between
  58730. * @param value2 value to calulate the distance between
  58731. * @return the distance between the two vectors
  58732. */
  58733. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58734. /**
  58735. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58736. * @param value1 value to calulate the distance between
  58737. * @param value2 value to calulate the distance between
  58738. * @return the distance between the two vectors squared
  58739. */
  58740. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58741. /**
  58742. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58743. * @param value1 value to calulate the center between
  58744. * @param value2 value to calulate the center between
  58745. * @return the center between the two vectors
  58746. */
  58747. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58748. /**
  58749. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58750. * This methods computes transformed normalized direction vectors only.
  58751. * @param vector the vector to transform
  58752. * @param transformation the transformation matrix to apply
  58753. * @returns the new vector
  58754. */
  58755. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58756. /**
  58757. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58758. * This methods computes transformed normalized direction vectors only.
  58759. * @param vector the vector to transform
  58760. * @param transformation the transformation matrix to apply
  58761. * @param result the vector to store the result in
  58762. */
  58763. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58764. /**
  58765. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58766. * This methods computes transformed normalized direction vectors only.
  58767. * @param x value to transform
  58768. * @param y value to transform
  58769. * @param z value to transform
  58770. * @param w value to transform
  58771. * @param transformation the transformation matrix to apply
  58772. * @param result the vector to store the results in
  58773. */
  58774. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58775. /**
  58776. * Creates a new Vector4 from a Vector3
  58777. * @param source defines the source data
  58778. * @param w defines the 4th component (default is 0)
  58779. * @returns a new Vector4
  58780. */
  58781. static FromVector3(source: Vector3, w?: number): Vector4;
  58782. }
  58783. /**
  58784. * Interface for the size containing width and height
  58785. */
  58786. export interface ISize {
  58787. /**
  58788. * Width
  58789. */
  58790. width: number;
  58791. /**
  58792. * Heighht
  58793. */
  58794. height: number;
  58795. }
  58796. /**
  58797. * Size containing widht and height
  58798. */
  58799. export class Size implements ISize {
  58800. /**
  58801. * Width
  58802. */
  58803. width: number;
  58804. /**
  58805. * Height
  58806. */
  58807. height: number;
  58808. /**
  58809. * Creates a Size object from the given width and height (floats).
  58810. * @param width width of the new size
  58811. * @param height height of the new size
  58812. */
  58813. constructor(width: number, height: number);
  58814. /**
  58815. * Returns a string with the Size width and height
  58816. * @returns a string with the Size width and height
  58817. */
  58818. toString(): string;
  58819. /**
  58820. * "Size"
  58821. * @returns the string "Size"
  58822. */
  58823. getClassName(): string;
  58824. /**
  58825. * Returns the Size hash code.
  58826. * @returns a hash code for a unique width and height
  58827. */
  58828. getHashCode(): number;
  58829. /**
  58830. * Updates the current size from the given one.
  58831. * @param src the given size
  58832. */
  58833. copyFrom(src: Size): void;
  58834. /**
  58835. * Updates in place the current Size from the given floats.
  58836. * @param width width of the new size
  58837. * @param height height of the new size
  58838. * @returns the updated Size.
  58839. */
  58840. copyFromFloats(width: number, height: number): Size;
  58841. /**
  58842. * Updates in place the current Size from the given floats.
  58843. * @param width width to set
  58844. * @param height height to set
  58845. * @returns the updated Size.
  58846. */
  58847. set(width: number, height: number): Size;
  58848. /**
  58849. * Multiplies the width and height by numbers
  58850. * @param w factor to multiple the width by
  58851. * @param h factor to multiple the height by
  58852. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58853. */
  58854. multiplyByFloats(w: number, h: number): Size;
  58855. /**
  58856. * Clones the size
  58857. * @returns a new Size copied from the given one.
  58858. */
  58859. clone(): Size;
  58860. /**
  58861. * True if the current Size and the given one width and height are strictly equal.
  58862. * @param other the other size to compare against
  58863. * @returns True if the current Size and the given one width and height are strictly equal.
  58864. */
  58865. equals(other: Size): boolean;
  58866. /**
  58867. * The surface of the Size : width * height (float).
  58868. */
  58869. readonly surface: number;
  58870. /**
  58871. * Create a new size of zero
  58872. * @returns a new Size set to (0.0, 0.0)
  58873. */
  58874. static Zero(): Size;
  58875. /**
  58876. * Sums the width and height of two sizes
  58877. * @param otherSize size to add to this size
  58878. * @returns a new Size set as the addition result of the current Size and the given one.
  58879. */
  58880. add(otherSize: Size): Size;
  58881. /**
  58882. * Subtracts the width and height of two
  58883. * @param otherSize size to subtract to this size
  58884. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58885. */
  58886. subtract(otherSize: Size): Size;
  58887. /**
  58888. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58889. * @param start starting size to lerp between
  58890. * @param end end size to lerp between
  58891. * @param amount amount to lerp between the start and end values
  58892. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58893. */
  58894. static Lerp(start: Size, end: Size, amount: number): Size;
  58895. }
  58896. /**
  58897. * Class used to store quaternion data
  58898. * @see https://en.wikipedia.org/wiki/Quaternion
  58899. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58900. */
  58901. export class Quaternion {
  58902. /** defines the first component (0 by default) */
  58903. x: number;
  58904. /** defines the second component (0 by default) */
  58905. y: number;
  58906. /** defines the third component (0 by default) */
  58907. z: number;
  58908. /** defines the fourth component (1.0 by default) */
  58909. w: number;
  58910. /**
  58911. * Creates a new Quaternion from the given floats
  58912. * @param x defines the first component (0 by default)
  58913. * @param y defines the second component (0 by default)
  58914. * @param z defines the third component (0 by default)
  58915. * @param w defines the fourth component (1.0 by default)
  58916. */
  58917. constructor(
  58918. /** defines the first component (0 by default) */
  58919. x?: number,
  58920. /** defines the second component (0 by default) */
  58921. y?: number,
  58922. /** defines the third component (0 by default) */
  58923. z?: number,
  58924. /** defines the fourth component (1.0 by default) */
  58925. w?: number);
  58926. /**
  58927. * Gets a string representation for the current quaternion
  58928. * @returns a string with the Quaternion coordinates
  58929. */
  58930. toString(): string;
  58931. /**
  58932. * Gets the class name of the quaternion
  58933. * @returns the string "Quaternion"
  58934. */
  58935. getClassName(): string;
  58936. /**
  58937. * Gets a hash code for this quaternion
  58938. * @returns the quaternion hash code
  58939. */
  58940. getHashCode(): number;
  58941. /**
  58942. * Copy the quaternion to an array
  58943. * @returns a new array populated with 4 elements from the quaternion coordinates
  58944. */
  58945. asArray(): number[];
  58946. /**
  58947. * Check if two quaternions are equals
  58948. * @param otherQuaternion defines the second operand
  58949. * @return true if the current quaternion and the given one coordinates are strictly equals
  58950. */
  58951. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58952. /**
  58953. * Clone the current quaternion
  58954. * @returns a new quaternion copied from the current one
  58955. */
  58956. clone(): Quaternion;
  58957. /**
  58958. * Copy a quaternion to the current one
  58959. * @param other defines the other quaternion
  58960. * @returns the updated current quaternion
  58961. */
  58962. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58963. /**
  58964. * Updates the current quaternion with the given float coordinates
  58965. * @param x defines the x coordinate
  58966. * @param y defines the y coordinate
  58967. * @param z defines the z coordinate
  58968. * @param w defines the w coordinate
  58969. * @returns the updated current quaternion
  58970. */
  58971. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  58972. /**
  58973. * Updates the current quaternion from the given float coordinates
  58974. * @param x defines the x coordinate
  58975. * @param y defines the y coordinate
  58976. * @param z defines the z coordinate
  58977. * @param w defines the w coordinate
  58978. * @returns the updated current quaternion
  58979. */
  58980. set(x: number, y: number, z: number, w: number): Quaternion;
  58981. /**
  58982. * Adds two quaternions
  58983. * @param other defines the second operand
  58984. * @returns a new quaternion as the addition result of the given one and the current quaternion
  58985. */
  58986. add(other: DeepImmutable<Quaternion>): Quaternion;
  58987. /**
  58988. * Add a quaternion to the current one
  58989. * @param other defines the quaternion to add
  58990. * @returns the current quaternion
  58991. */
  58992. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  58993. /**
  58994. * Subtract two quaternions
  58995. * @param other defines the second operand
  58996. * @returns a new quaternion as the subtraction result of the given one from the current one
  58997. */
  58998. subtract(other: Quaternion): Quaternion;
  58999. /**
  59000. * Multiplies the current quaternion by a scale factor
  59001. * @param value defines the scale factor
  59002. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59003. */
  59004. scale(value: number): Quaternion;
  59005. /**
  59006. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59007. * @param scale defines the scale factor
  59008. * @param result defines the Quaternion object where to store the result
  59009. * @returns the unmodified current quaternion
  59010. */
  59011. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59012. /**
  59013. * Multiplies in place the current quaternion by a scale factor
  59014. * @param value defines the scale factor
  59015. * @returns the current modified quaternion
  59016. */
  59017. scaleInPlace(value: number): Quaternion;
  59018. /**
  59019. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59020. * @param scale defines the scale factor
  59021. * @param result defines the Quaternion object where to store the result
  59022. * @returns the unmodified current quaternion
  59023. */
  59024. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59025. /**
  59026. * Multiplies two quaternions
  59027. * @param q1 defines the second operand
  59028. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59029. */
  59030. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59031. /**
  59032. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59033. * @param q1 defines the second operand
  59034. * @param result defines the target quaternion
  59035. * @returns the current quaternion
  59036. */
  59037. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59038. /**
  59039. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59040. * @param q1 defines the second operand
  59041. * @returns the currentupdated quaternion
  59042. */
  59043. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59044. /**
  59045. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59046. * @param ref defines the target quaternion
  59047. * @returns the current quaternion
  59048. */
  59049. conjugateToRef(ref: Quaternion): Quaternion;
  59050. /**
  59051. * Conjugates in place (1-q) the current quaternion
  59052. * @returns the current updated quaternion
  59053. */
  59054. conjugateInPlace(): Quaternion;
  59055. /**
  59056. * Conjugates in place (1-q) the current quaternion
  59057. * @returns a new quaternion
  59058. */
  59059. conjugate(): Quaternion;
  59060. /**
  59061. * Gets length of current quaternion
  59062. * @returns the quaternion length (float)
  59063. */
  59064. length(): number;
  59065. /**
  59066. * Normalize in place the current quaternion
  59067. * @returns the current updated quaternion
  59068. */
  59069. normalize(): Quaternion;
  59070. /**
  59071. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59072. * @param order is a reserved parameter and is ignore for now
  59073. * @returns a new Vector3 containing the Euler angles
  59074. */
  59075. toEulerAngles(order?: string): Vector3;
  59076. /**
  59077. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59078. * @param result defines the vector which will be filled with the Euler angles
  59079. * @param order is a reserved parameter and is ignore for now
  59080. * @returns the current unchanged quaternion
  59081. */
  59082. toEulerAnglesToRef(result: Vector3): Quaternion;
  59083. /**
  59084. * Updates the given rotation matrix with the current quaternion values
  59085. * @param result defines the target matrix
  59086. * @returns the current unchanged quaternion
  59087. */
  59088. toRotationMatrix(result: Matrix): Quaternion;
  59089. /**
  59090. * Updates the current quaternion from the given rotation matrix values
  59091. * @param matrix defines the source matrix
  59092. * @returns the current updated quaternion
  59093. */
  59094. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59095. /**
  59096. * Creates a new quaternion from a rotation matrix
  59097. * @param matrix defines the source matrix
  59098. * @returns a new quaternion created from the given rotation matrix values
  59099. */
  59100. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59101. /**
  59102. * Updates the given quaternion with the given rotation matrix values
  59103. * @param matrix defines the source matrix
  59104. * @param result defines the target quaternion
  59105. */
  59106. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59107. /**
  59108. * Returns the dot product (float) between the quaternions "left" and "right"
  59109. * @param left defines the left operand
  59110. * @param right defines the right operand
  59111. * @returns the dot product
  59112. */
  59113. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59114. /**
  59115. * Checks if the two quaternions are close to each other
  59116. * @param quat0 defines the first quaternion to check
  59117. * @param quat1 defines the second quaternion to check
  59118. * @returns true if the two quaternions are close to each other
  59119. */
  59120. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59121. /**
  59122. * Creates an empty quaternion
  59123. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59124. */
  59125. static Zero(): Quaternion;
  59126. /**
  59127. * Inverse a given quaternion
  59128. * @param q defines the source quaternion
  59129. * @returns a new quaternion as the inverted current quaternion
  59130. */
  59131. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59132. /**
  59133. * Inverse a given quaternion
  59134. * @param q defines the source quaternion
  59135. * @param result the quaternion the result will be stored in
  59136. * @returns the result quaternion
  59137. */
  59138. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59139. /**
  59140. * Creates an identity quaternion
  59141. * @returns the identity quaternion
  59142. */
  59143. static Identity(): Quaternion;
  59144. /**
  59145. * Gets a boolean indicating if the given quaternion is identity
  59146. * @param quaternion defines the quaternion to check
  59147. * @returns true if the quaternion is identity
  59148. */
  59149. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59150. /**
  59151. * Creates a quaternion from a rotation around an axis
  59152. * @param axis defines the axis to use
  59153. * @param angle defines the angle to use
  59154. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59155. */
  59156. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59157. /**
  59158. * Creates a rotation around an axis and stores it into the given quaternion
  59159. * @param axis defines the axis to use
  59160. * @param angle defines the angle to use
  59161. * @param result defines the target quaternion
  59162. * @returns the target quaternion
  59163. */
  59164. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59165. /**
  59166. * Creates a new quaternion from data stored into an array
  59167. * @param array defines the data source
  59168. * @param offset defines the offset in the source array where the data starts
  59169. * @returns a new quaternion
  59170. */
  59171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59172. /**
  59173. * Create a quaternion from Euler rotation angles
  59174. * @param x Pitch
  59175. * @param y Yaw
  59176. * @param z Roll
  59177. * @returns the new Quaternion
  59178. */
  59179. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59180. /**
  59181. * Updates a quaternion from Euler rotation angles
  59182. * @param x Pitch
  59183. * @param y Yaw
  59184. * @param z Roll
  59185. * @param result the quaternion to store the result
  59186. * @returns the updated quaternion
  59187. */
  59188. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59189. /**
  59190. * Create a quaternion from Euler rotation vector
  59191. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59192. * @returns the new Quaternion
  59193. */
  59194. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59195. /**
  59196. * Updates a quaternion from Euler rotation vector
  59197. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59198. * @param result the quaternion to store the result
  59199. * @returns the updated quaternion
  59200. */
  59201. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59202. /**
  59203. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59204. * @param yaw defines the rotation around Y axis
  59205. * @param pitch defines the rotation around X axis
  59206. * @param roll defines the rotation around Z axis
  59207. * @returns the new quaternion
  59208. */
  59209. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59210. /**
  59211. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59212. * @param yaw defines the rotation around Y axis
  59213. * @param pitch defines the rotation around X axis
  59214. * @param roll defines the rotation around Z axis
  59215. * @param result defines the target quaternion
  59216. */
  59217. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59218. /**
  59219. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59220. * @param alpha defines the rotation around first axis
  59221. * @param beta defines the rotation around second axis
  59222. * @param gamma defines the rotation around third axis
  59223. * @returns the new quaternion
  59224. */
  59225. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59226. /**
  59227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59228. * @param alpha defines the rotation around first axis
  59229. * @param beta defines the rotation around second axis
  59230. * @param gamma defines the rotation around third axis
  59231. * @param result defines the target quaternion
  59232. */
  59233. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59234. /**
  59235. * 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)
  59236. * @param axis1 defines the first axis
  59237. * @param axis2 defines the second axis
  59238. * @param axis3 defines the third axis
  59239. * @returns the new quaternion
  59240. */
  59241. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59242. /**
  59243. * 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
  59244. * @param axis1 defines the first axis
  59245. * @param axis2 defines the second axis
  59246. * @param axis3 defines the third axis
  59247. * @param ref defines the target quaternion
  59248. */
  59249. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59250. /**
  59251. * Interpolates between two quaternions
  59252. * @param left defines first quaternion
  59253. * @param right defines second quaternion
  59254. * @param amount defines the gradient to use
  59255. * @returns the new interpolated quaternion
  59256. */
  59257. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59258. /**
  59259. * Interpolates between two quaternions and stores it into a target quaternion
  59260. * @param left defines first quaternion
  59261. * @param right defines second quaternion
  59262. * @param amount defines the gradient to use
  59263. * @param result defines the target quaternion
  59264. */
  59265. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59266. /**
  59267. * Interpolate between two quaternions using Hermite interpolation
  59268. * @param value1 defines first quaternion
  59269. * @param tangent1 defines the incoming tangent
  59270. * @param value2 defines second quaternion
  59271. * @param tangent2 defines the outgoing tangent
  59272. * @param amount defines the target quaternion
  59273. * @returns the new interpolated quaternion
  59274. */
  59275. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59276. }
  59277. /**
  59278. * Class used to store matrix data (4x4)
  59279. */
  59280. export class Matrix {
  59281. private static _updateFlagSeed;
  59282. private static _identityReadOnly;
  59283. private _isIdentity;
  59284. private _isIdentityDirty;
  59285. private _isIdentity3x2;
  59286. private _isIdentity3x2Dirty;
  59287. /**
  59288. * Gets the update flag of the matrix which is an unique number for the matrix.
  59289. * It will be incremented every time the matrix data change.
  59290. * You can use it to speed the comparison between two versions of the same matrix.
  59291. */
  59292. updateFlag: number;
  59293. private readonly _m;
  59294. /**
  59295. * Gets the internal data of the matrix
  59296. */
  59297. readonly m: DeepImmutable<Float32Array>;
  59298. /** @hidden */
  59299. _markAsUpdated(): void;
  59300. /** @hidden */
  59301. private _updateIdentityStatus;
  59302. /**
  59303. * Creates an empty matrix (filled with zeros)
  59304. */
  59305. constructor();
  59306. /**
  59307. * Check if the current matrix is identity
  59308. * @returns true is the matrix is the identity matrix
  59309. */
  59310. isIdentity(): boolean;
  59311. /**
  59312. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59313. * @returns true is the matrix is the identity matrix
  59314. */
  59315. isIdentityAs3x2(): boolean;
  59316. /**
  59317. * Gets the determinant of the matrix
  59318. * @returns the matrix determinant
  59319. */
  59320. determinant(): number;
  59321. /**
  59322. * Returns the matrix as a Float32Array
  59323. * @returns the matrix underlying array
  59324. */
  59325. toArray(): DeepImmutable<Float32Array>;
  59326. /**
  59327. * Returns the matrix as a Float32Array
  59328. * @returns the matrix underlying array.
  59329. */
  59330. asArray(): DeepImmutable<Float32Array>;
  59331. /**
  59332. * Inverts the current matrix in place
  59333. * @returns the current inverted matrix
  59334. */
  59335. invert(): Matrix;
  59336. /**
  59337. * Sets all the matrix elements to zero
  59338. * @returns the current matrix
  59339. */
  59340. reset(): Matrix;
  59341. /**
  59342. * Adds the current matrix with a second one
  59343. * @param other defines the matrix to add
  59344. * @returns a new matrix as the addition of the current matrix and the given one
  59345. */
  59346. add(other: DeepImmutable<Matrix>): Matrix;
  59347. /**
  59348. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59349. * @param other defines the matrix to add
  59350. * @param result defines the target matrix
  59351. * @returns the current matrix
  59352. */
  59353. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59354. /**
  59355. * Adds in place the given matrix to the current matrix
  59356. * @param other defines the second operand
  59357. * @returns the current updated matrix
  59358. */
  59359. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59360. /**
  59361. * Sets the given matrix to the current inverted Matrix
  59362. * @param other defines the target matrix
  59363. * @returns the unmodified current matrix
  59364. */
  59365. invertToRef(other: Matrix): Matrix;
  59366. /**
  59367. * add a value at the specified position in the current Matrix
  59368. * @param index the index of the value within the matrix. between 0 and 15.
  59369. * @param value the value to be added
  59370. * @returns the current updated matrix
  59371. */
  59372. addAtIndex(index: number, value: number): Matrix;
  59373. /**
  59374. * mutiply the specified position in the current Matrix by a value
  59375. * @param index the index of the value within the matrix. between 0 and 15.
  59376. * @param value the value to be added
  59377. * @returns the current updated matrix
  59378. */
  59379. multiplyAtIndex(index: number, value: number): Matrix;
  59380. /**
  59381. * Inserts the translation vector (using 3 floats) in the current matrix
  59382. * @param x defines the 1st component of the translation
  59383. * @param y defines the 2nd component of the translation
  59384. * @param z defines the 3rd component of the translation
  59385. * @returns the current updated matrix
  59386. */
  59387. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59388. /**
  59389. * Inserts the translation vector in the current matrix
  59390. * @param vector3 defines the translation to insert
  59391. * @returns the current updated matrix
  59392. */
  59393. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59394. /**
  59395. * Gets the translation value of the current matrix
  59396. * @returns a new Vector3 as the extracted translation from the matrix
  59397. */
  59398. getTranslation(): Vector3;
  59399. /**
  59400. * Fill a Vector3 with the extracted translation from the matrix
  59401. * @param result defines the Vector3 where to store the translation
  59402. * @returns the current matrix
  59403. */
  59404. getTranslationToRef(result: Vector3): Matrix;
  59405. /**
  59406. * Remove rotation and scaling part from the matrix
  59407. * @returns the updated matrix
  59408. */
  59409. removeRotationAndScaling(): Matrix;
  59410. /**
  59411. * Multiply two matrices
  59412. * @param other defines the second operand
  59413. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59414. */
  59415. multiply(other: DeepImmutable<Matrix>): Matrix;
  59416. /**
  59417. * Copy the current matrix from the given one
  59418. * @param other defines the source matrix
  59419. * @returns the current updated matrix
  59420. */
  59421. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59422. /**
  59423. * Populates the given array from the starting index with the current matrix values
  59424. * @param array defines the target array
  59425. * @param offset defines the offset in the target array where to start storing values
  59426. * @returns the current matrix
  59427. */
  59428. copyToArray(array: Float32Array, offset?: number): Matrix;
  59429. /**
  59430. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59431. * @param other defines the second operand
  59432. * @param result defines the matrix where to store the multiplication
  59433. * @returns the current matrix
  59434. */
  59435. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59436. /**
  59437. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59438. * @param other defines the second operand
  59439. * @param result defines the array where to store the multiplication
  59440. * @param offset defines the offset in the target array where to start storing values
  59441. * @returns the current matrix
  59442. */
  59443. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59444. /**
  59445. * Check equality between this matrix and a second one
  59446. * @param value defines the second matrix to compare
  59447. * @returns true is the current matrix and the given one values are strictly equal
  59448. */
  59449. equals(value: DeepImmutable<Matrix>): boolean;
  59450. /**
  59451. * Clone the current matrix
  59452. * @returns a new matrix from the current matrix
  59453. */
  59454. clone(): Matrix;
  59455. /**
  59456. * Returns the name of the current matrix class
  59457. * @returns the string "Matrix"
  59458. */
  59459. getClassName(): string;
  59460. /**
  59461. * Gets the hash code of the current matrix
  59462. * @returns the hash code
  59463. */
  59464. getHashCode(): number;
  59465. /**
  59466. * Decomposes the current Matrix into a translation, rotation and scaling components
  59467. * @param scale defines the scale vector3 given as a reference to update
  59468. * @param rotation defines the rotation quaternion given as a reference to update
  59469. * @param translation defines the translation vector3 given as a reference to update
  59470. * @returns true if operation was successful
  59471. */
  59472. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59473. /**
  59474. * Gets specific row of the matrix
  59475. * @param index defines the number of the row to get
  59476. * @returns the index-th row of the current matrix as a new Vector4
  59477. */
  59478. getRow(index: number): Nullable<Vector4>;
  59479. /**
  59480. * Sets the index-th row of the current matrix to the vector4 values
  59481. * @param index defines the number of the row to set
  59482. * @param row defines the target vector4
  59483. * @returns the updated current matrix
  59484. */
  59485. setRow(index: number, row: Vector4): Matrix;
  59486. /**
  59487. * Compute the transpose of the matrix
  59488. * @returns the new transposed matrix
  59489. */
  59490. transpose(): Matrix;
  59491. /**
  59492. * Compute the transpose of the matrix and store it in a given matrix
  59493. * @param result defines the target matrix
  59494. * @returns the current matrix
  59495. */
  59496. transposeToRef(result: Matrix): Matrix;
  59497. /**
  59498. * Sets the index-th row of the current matrix with the given 4 x float values
  59499. * @param index defines the row index
  59500. * @param x defines the x component to set
  59501. * @param y defines the y component to set
  59502. * @param z defines the z component to set
  59503. * @param w defines the w component to set
  59504. * @returns the updated current matrix
  59505. */
  59506. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59507. /**
  59508. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59509. * @param scale defines the scale factor
  59510. * @returns a new matrix
  59511. */
  59512. scale(scale: number): Matrix;
  59513. /**
  59514. * Scale the current matrix values by a factor to a given result matrix
  59515. * @param scale defines the scale factor
  59516. * @param result defines the matrix to store the result
  59517. * @returns the current matrix
  59518. */
  59519. scaleToRef(scale: number, result: Matrix): Matrix;
  59520. /**
  59521. * Scale the current matrix values by a factor and add the result to a given matrix
  59522. * @param scale defines the scale factor
  59523. * @param result defines the Matrix to store the result
  59524. * @returns the current matrix
  59525. */
  59526. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59527. /**
  59528. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59529. * @param ref matrix to store the result
  59530. */
  59531. toNormalMatrix(ref: Matrix): void;
  59532. /**
  59533. * Gets only rotation part of the current matrix
  59534. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59535. */
  59536. getRotationMatrix(): Matrix;
  59537. /**
  59538. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59539. * @param result defines the target matrix to store data to
  59540. * @returns the current matrix
  59541. */
  59542. getRotationMatrixToRef(result: Matrix): Matrix;
  59543. /**
  59544. * Toggles model matrix from being right handed to left handed in place and vice versa
  59545. */
  59546. toggleModelMatrixHandInPlace(): void;
  59547. /**
  59548. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59549. */
  59550. toggleProjectionMatrixHandInPlace(): void;
  59551. /**
  59552. * Creates a matrix from an array
  59553. * @param array defines the source array
  59554. * @param offset defines an offset in the source array
  59555. * @returns a new Matrix set from the starting index of the given array
  59556. */
  59557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59558. /**
  59559. * Copy the content of an array into a given matrix
  59560. * @param array defines the source array
  59561. * @param offset defines an offset in the source array
  59562. * @param result defines the target matrix
  59563. */
  59564. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59565. /**
  59566. * Stores an array into a matrix after having multiplied each component by a given factor
  59567. * @param array defines the source array
  59568. * @param offset defines the offset in the source array
  59569. * @param scale defines the scaling factor
  59570. * @param result defines the target matrix
  59571. */
  59572. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59573. /**
  59574. * Gets an identity matrix that must not be updated
  59575. */
  59576. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59577. /**
  59578. * Stores a list of values (16) inside a given matrix
  59579. * @param initialM11 defines 1st value of 1st row
  59580. * @param initialM12 defines 2nd value of 1st row
  59581. * @param initialM13 defines 3rd value of 1st row
  59582. * @param initialM14 defines 4th value of 1st row
  59583. * @param initialM21 defines 1st value of 2nd row
  59584. * @param initialM22 defines 2nd value of 2nd row
  59585. * @param initialM23 defines 3rd value of 2nd row
  59586. * @param initialM24 defines 4th value of 2nd row
  59587. * @param initialM31 defines 1st value of 3rd row
  59588. * @param initialM32 defines 2nd value of 3rd row
  59589. * @param initialM33 defines 3rd value of 3rd row
  59590. * @param initialM34 defines 4th value of 3rd row
  59591. * @param initialM41 defines 1st value of 4th row
  59592. * @param initialM42 defines 2nd value of 4th row
  59593. * @param initialM43 defines 3rd value of 4th row
  59594. * @param initialM44 defines 4th value of 4th row
  59595. * @param result defines the target matrix
  59596. */
  59597. 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;
  59598. /**
  59599. * Creates new matrix from a list of values (16)
  59600. * @param initialM11 defines 1st value of 1st row
  59601. * @param initialM12 defines 2nd value of 1st row
  59602. * @param initialM13 defines 3rd value of 1st row
  59603. * @param initialM14 defines 4th value of 1st row
  59604. * @param initialM21 defines 1st value of 2nd row
  59605. * @param initialM22 defines 2nd value of 2nd row
  59606. * @param initialM23 defines 3rd value of 2nd row
  59607. * @param initialM24 defines 4th value of 2nd row
  59608. * @param initialM31 defines 1st value of 3rd row
  59609. * @param initialM32 defines 2nd value of 3rd row
  59610. * @param initialM33 defines 3rd value of 3rd row
  59611. * @param initialM34 defines 4th value of 3rd row
  59612. * @param initialM41 defines 1st value of 4th row
  59613. * @param initialM42 defines 2nd value of 4th row
  59614. * @param initialM43 defines 3rd value of 4th row
  59615. * @param initialM44 defines 4th value of 4th row
  59616. * @returns the new matrix
  59617. */
  59618. 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;
  59619. /**
  59620. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59621. * @param scale defines the scale vector3
  59622. * @param rotation defines the rotation quaternion
  59623. * @param translation defines the translation vector3
  59624. * @returns a new matrix
  59625. */
  59626. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59627. /**
  59628. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59629. * @param scale defines the scale vector3
  59630. * @param rotation defines the rotation quaternion
  59631. * @param translation defines the translation vector3
  59632. * @param result defines the target matrix
  59633. */
  59634. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59635. /**
  59636. * Creates a new identity matrix
  59637. * @returns a new identity matrix
  59638. */
  59639. static Identity(): Matrix;
  59640. /**
  59641. * Creates a new identity matrix and stores the result in a given matrix
  59642. * @param result defines the target matrix
  59643. */
  59644. static IdentityToRef(result: Matrix): void;
  59645. /**
  59646. * Creates a new zero matrix
  59647. * @returns a new zero matrix
  59648. */
  59649. static Zero(): Matrix;
  59650. /**
  59651. * Creates a new rotation matrix for "angle" radians around the X axis
  59652. * @param angle defines the angle (in radians) to use
  59653. * @return the new matrix
  59654. */
  59655. static RotationX(angle: number): Matrix;
  59656. /**
  59657. * Creates a new matrix as the invert of a given matrix
  59658. * @param source defines the source matrix
  59659. * @returns the new matrix
  59660. */
  59661. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59662. /**
  59663. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59664. * @param angle defines the angle (in radians) to use
  59665. * @param result defines the target matrix
  59666. */
  59667. static RotationXToRef(angle: number, result: Matrix): void;
  59668. /**
  59669. * Creates a new rotation matrix for "angle" radians around the Y axis
  59670. * @param angle defines the angle (in radians) to use
  59671. * @return the new matrix
  59672. */
  59673. static RotationY(angle: number): Matrix;
  59674. /**
  59675. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59676. * @param angle defines the angle (in radians) to use
  59677. * @param result defines the target matrix
  59678. */
  59679. static RotationYToRef(angle: number, result: Matrix): void;
  59680. /**
  59681. * Creates a new rotation matrix for "angle" radians around the Z axis
  59682. * @param angle defines the angle (in radians) to use
  59683. * @return the new matrix
  59684. */
  59685. static RotationZ(angle: number): Matrix;
  59686. /**
  59687. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59688. * @param angle defines the angle (in radians) to use
  59689. * @param result defines the target matrix
  59690. */
  59691. static RotationZToRef(angle: number, result: Matrix): void;
  59692. /**
  59693. * Creates a new rotation matrix for "angle" radians around the given axis
  59694. * @param axis defines the axis to use
  59695. * @param angle defines the angle (in radians) to use
  59696. * @return the new matrix
  59697. */
  59698. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59699. /**
  59700. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59701. * @param axis defines the axis to use
  59702. * @param angle defines the angle (in radians) to use
  59703. * @param result defines the target matrix
  59704. */
  59705. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59706. /**
  59707. * Creates a rotation matrix
  59708. * @param yaw defines the yaw angle in radians (Y axis)
  59709. * @param pitch defines the pitch angle in radians (X axis)
  59710. * @param roll defines the roll angle in radians (X axis)
  59711. * @returns the new rotation matrix
  59712. */
  59713. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59714. /**
  59715. * Creates a rotation matrix and stores it in a given matrix
  59716. * @param yaw defines the yaw angle in radians (Y axis)
  59717. * @param pitch defines the pitch angle in radians (X axis)
  59718. * @param roll defines the roll angle in radians (X axis)
  59719. * @param result defines the target matrix
  59720. */
  59721. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59722. /**
  59723. * Creates a scaling matrix
  59724. * @param x defines the scale factor on X axis
  59725. * @param y defines the scale factor on Y axis
  59726. * @param z defines the scale factor on Z axis
  59727. * @returns the new matrix
  59728. */
  59729. static Scaling(x: number, y: number, z: number): Matrix;
  59730. /**
  59731. * Creates a scaling matrix and stores it in a given matrix
  59732. * @param x defines the scale factor on X axis
  59733. * @param y defines the scale factor on Y axis
  59734. * @param z defines the scale factor on Z axis
  59735. * @param result defines the target matrix
  59736. */
  59737. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59738. /**
  59739. * Creates a translation matrix
  59740. * @param x defines the translation on X axis
  59741. * @param y defines the translation on Y axis
  59742. * @param z defines the translationon Z axis
  59743. * @returns the new matrix
  59744. */
  59745. static Translation(x: number, y: number, z: number): Matrix;
  59746. /**
  59747. * Creates a translation matrix and stores it in a given matrix
  59748. * @param x defines the translation on X axis
  59749. * @param y defines the translation on Y axis
  59750. * @param z defines the translationon Z axis
  59751. * @param result defines the target matrix
  59752. */
  59753. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59754. /**
  59755. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59756. * @param startValue defines the start value
  59757. * @param endValue defines the end value
  59758. * @param gradient defines the gradient factor
  59759. * @returns the new matrix
  59760. */
  59761. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59762. /**
  59763. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59764. * @param startValue defines the start value
  59765. * @param endValue defines the end value
  59766. * @param gradient defines the gradient factor
  59767. * @param result defines the Matrix object where to store data
  59768. */
  59769. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59770. /**
  59771. * Builds a new matrix whose values are computed by:
  59772. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59773. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59774. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59775. * @param startValue defines the first matrix
  59776. * @param endValue defines the second matrix
  59777. * @param gradient defines the gradient between the two matrices
  59778. * @returns the new matrix
  59779. */
  59780. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59781. /**
  59782. * Update a matrix to values which are computed by:
  59783. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59784. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59785. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59786. * @param startValue defines the first matrix
  59787. * @param endValue defines the second matrix
  59788. * @param gradient defines the gradient between the two matrices
  59789. * @param result defines the target matrix
  59790. */
  59791. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59792. /**
  59793. * 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"
  59794. * This function works in left handed mode
  59795. * @param eye defines the final position of the entity
  59796. * @param target defines where the entity should look at
  59797. * @param up defines the up vector for the entity
  59798. * @returns the new matrix
  59799. */
  59800. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59801. /**
  59802. * 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".
  59803. * This function works in left handed mode
  59804. * @param eye defines the final position of the entity
  59805. * @param target defines where the entity should look at
  59806. * @param up defines the up vector for the entity
  59807. * @param result defines the target matrix
  59808. */
  59809. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59810. /**
  59811. * 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"
  59812. * This function works in right handed mode
  59813. * @param eye defines the final position of the entity
  59814. * @param target defines where the entity should look at
  59815. * @param up defines the up vector for the entity
  59816. * @returns the new matrix
  59817. */
  59818. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59819. /**
  59820. * 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".
  59821. * This function works in right handed mode
  59822. * @param eye defines the final position of the entity
  59823. * @param target defines where the entity should look at
  59824. * @param up defines the up vector for the entity
  59825. * @param result defines the target matrix
  59826. */
  59827. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59828. /**
  59829. * Create a left-handed orthographic projection matrix
  59830. * @param width defines the viewport width
  59831. * @param height defines the viewport height
  59832. * @param znear defines the near clip plane
  59833. * @param zfar defines the far clip plane
  59834. * @returns a new matrix as a left-handed orthographic projection matrix
  59835. */
  59836. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59837. /**
  59838. * Store a left-handed orthographic projection to a given matrix
  59839. * @param width defines the viewport width
  59840. * @param height defines the viewport height
  59841. * @param znear defines the near clip plane
  59842. * @param zfar defines the far clip plane
  59843. * @param result defines the target matrix
  59844. */
  59845. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59846. /**
  59847. * Create a left-handed orthographic projection matrix
  59848. * @param left defines the viewport left coordinate
  59849. * @param right defines the viewport right coordinate
  59850. * @param bottom defines the viewport bottom coordinate
  59851. * @param top defines the viewport top coordinate
  59852. * @param znear defines the near clip plane
  59853. * @param zfar defines the far clip plane
  59854. * @returns a new matrix as a left-handed orthographic projection matrix
  59855. */
  59856. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59857. /**
  59858. * Stores a left-handed orthographic projection into a given matrix
  59859. * @param left defines the viewport left coordinate
  59860. * @param right defines the viewport right coordinate
  59861. * @param bottom defines the viewport bottom coordinate
  59862. * @param top defines the viewport top coordinate
  59863. * @param znear defines the near clip plane
  59864. * @param zfar defines the far clip plane
  59865. * @param result defines the target matrix
  59866. */
  59867. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59868. /**
  59869. * Creates a right-handed orthographic projection matrix
  59870. * @param left defines the viewport left coordinate
  59871. * @param right defines the viewport right coordinate
  59872. * @param bottom defines the viewport bottom coordinate
  59873. * @param top defines the viewport top coordinate
  59874. * @param znear defines the near clip plane
  59875. * @param zfar defines the far clip plane
  59876. * @returns a new matrix as a right-handed orthographic projection matrix
  59877. */
  59878. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59879. /**
  59880. * Stores a right-handed orthographic projection into a given matrix
  59881. * @param left defines the viewport left coordinate
  59882. * @param right defines the viewport right coordinate
  59883. * @param bottom defines the viewport bottom coordinate
  59884. * @param top defines the viewport top coordinate
  59885. * @param znear defines the near clip plane
  59886. * @param zfar defines the far clip plane
  59887. * @param result defines the target matrix
  59888. */
  59889. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59890. /**
  59891. * Creates a left-handed perspective projection matrix
  59892. * @param width defines the viewport width
  59893. * @param height defines the viewport height
  59894. * @param znear defines the near clip plane
  59895. * @param zfar defines the far clip plane
  59896. * @returns a new matrix as a left-handed perspective projection matrix
  59897. */
  59898. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59899. /**
  59900. * Creates a left-handed perspective projection matrix
  59901. * @param fov defines the horizontal field of view
  59902. * @param aspect defines the aspect ratio
  59903. * @param znear defines the near clip plane
  59904. * @param zfar defines the far clip plane
  59905. * @returns a new matrix as a left-handed perspective projection matrix
  59906. */
  59907. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59908. /**
  59909. * Stores a left-handed perspective projection into a given matrix
  59910. * @param fov defines the horizontal field of view
  59911. * @param aspect defines the aspect ratio
  59912. * @param znear defines the near clip plane
  59913. * @param zfar defines the far clip plane
  59914. * @param result defines the target matrix
  59915. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59916. */
  59917. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59918. /**
  59919. * Creates a right-handed perspective projection matrix
  59920. * @param fov defines the horizontal field of view
  59921. * @param aspect defines the aspect ratio
  59922. * @param znear defines the near clip plane
  59923. * @param zfar defines the far clip plane
  59924. * @returns a new matrix as a right-handed perspective projection matrix
  59925. */
  59926. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59927. /**
  59928. * Stores a right-handed perspective projection into a given matrix
  59929. * @param fov defines the horizontal field of view
  59930. * @param aspect defines the aspect ratio
  59931. * @param znear defines the near clip plane
  59932. * @param zfar defines the far clip plane
  59933. * @param result defines the target matrix
  59934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59935. */
  59936. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59937. /**
  59938. * Stores a perspective projection for WebVR info a given matrix
  59939. * @param fov defines the field of view
  59940. * @param znear defines the near clip plane
  59941. * @param zfar defines the far clip plane
  59942. * @param result defines the target matrix
  59943. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59944. */
  59945. static PerspectiveFovWebVRToRef(fov: {
  59946. upDegrees: number;
  59947. downDegrees: number;
  59948. leftDegrees: number;
  59949. rightDegrees: number;
  59950. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59951. /**
  59952. * Computes a complete transformation matrix
  59953. * @param viewport defines the viewport to use
  59954. * @param world defines the world matrix
  59955. * @param view defines the view matrix
  59956. * @param projection defines the projection matrix
  59957. * @param zmin defines the near clip plane
  59958. * @param zmax defines the far clip plane
  59959. * @returns the transformation matrix
  59960. */
  59961. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59962. /**
  59963. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  59964. * @param matrix defines the matrix to use
  59965. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  59966. */
  59967. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  59968. /**
  59969. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  59970. * @param matrix defines the matrix to use
  59971. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  59972. */
  59973. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  59974. /**
  59975. * Compute the transpose of a given matrix
  59976. * @param matrix defines the matrix to transpose
  59977. * @returns the new matrix
  59978. */
  59979. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  59980. /**
  59981. * Compute the transpose of a matrix and store it in a target matrix
  59982. * @param matrix defines the matrix to transpose
  59983. * @param result defines the target matrix
  59984. */
  59985. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  59986. /**
  59987. * Computes a reflection matrix from a plane
  59988. * @param plane defines the reflection plane
  59989. * @returns a new matrix
  59990. */
  59991. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  59992. /**
  59993. * Computes a reflection matrix from a plane
  59994. * @param plane defines the reflection plane
  59995. * @param result defines the target matrix
  59996. */
  59997. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  59998. /**
  59999. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60000. * @param xaxis defines the value of the 1st axis
  60001. * @param yaxis defines the value of the 2nd axis
  60002. * @param zaxis defines the value of the 3rd axis
  60003. * @param result defines the target matrix
  60004. */
  60005. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60006. /**
  60007. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60008. * @param quat defines the quaternion to use
  60009. * @param result defines the target matrix
  60010. */
  60011. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60012. }
  60013. /**
  60014. * Represens a plane by the equation ax + by + cz + d = 0
  60015. */
  60016. export class Plane {
  60017. /**
  60018. * Normal of the plane (a,b,c)
  60019. */
  60020. normal: Vector3;
  60021. /**
  60022. * d component of the plane
  60023. */
  60024. d: number;
  60025. /**
  60026. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60027. * @param a a component of the plane
  60028. * @param b b component of the plane
  60029. * @param c c component of the plane
  60030. * @param d d component of the plane
  60031. */
  60032. constructor(a: number, b: number, c: number, d: number);
  60033. /**
  60034. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60035. */
  60036. asArray(): number[];
  60037. /**
  60038. * @returns a new plane copied from the current Plane.
  60039. */
  60040. clone(): Plane;
  60041. /**
  60042. * @returns the string "Plane".
  60043. */
  60044. getClassName(): string;
  60045. /**
  60046. * @returns the Plane hash code.
  60047. */
  60048. getHashCode(): number;
  60049. /**
  60050. * Normalize the current Plane in place.
  60051. * @returns the updated Plane.
  60052. */
  60053. normalize(): Plane;
  60054. /**
  60055. * Applies a transformation the plane and returns the result
  60056. * @param transformation the transformation matrix to be applied to the plane
  60057. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60058. */
  60059. transform(transformation: DeepImmutable<Matrix>): Plane;
  60060. /**
  60061. * Calcualtte the dot product between the point and the plane normal
  60062. * @param point point to calculate the dot product with
  60063. * @returns the dot product (float) of the point coordinates and the plane normal.
  60064. */
  60065. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60066. /**
  60067. * Updates the current Plane from the plane defined by the three given points.
  60068. * @param point1 one of the points used to contruct the plane
  60069. * @param point2 one of the points used to contruct the plane
  60070. * @param point3 one of the points used to contruct the plane
  60071. * @returns the updated Plane.
  60072. */
  60073. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60074. /**
  60075. * Checks if the plane is facing a given direction
  60076. * @param direction the direction to check if the plane is facing
  60077. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60078. * @returns True is the vector "direction" is the same side than the plane normal.
  60079. */
  60080. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60081. /**
  60082. * Calculates the distance to a point
  60083. * @param point point to calculate distance to
  60084. * @returns the signed distance (float) from the given point to the Plane.
  60085. */
  60086. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60087. /**
  60088. * Creates a plane from an array
  60089. * @param array the array to create a plane from
  60090. * @returns a new Plane from the given array.
  60091. */
  60092. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60093. /**
  60094. * Creates a plane from three points
  60095. * @param point1 point used to create the plane
  60096. * @param point2 point used to create the plane
  60097. * @param point3 point used to create the plane
  60098. * @returns a new Plane defined by the three given points.
  60099. */
  60100. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60101. /**
  60102. * Creates a plane from an origin point and a normal
  60103. * @param origin origin of the plane to be constructed
  60104. * @param normal normal of the plane to be constructed
  60105. * @returns a new Plane the normal vector to this plane at the given origin point.
  60106. * Note : the vector "normal" is updated because normalized.
  60107. */
  60108. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60109. /**
  60110. * Calculates the distance from a plane and a point
  60111. * @param origin origin of the plane to be constructed
  60112. * @param normal normal of the plane to be constructed
  60113. * @param point point to calculate distance to
  60114. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60115. */
  60116. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60117. }
  60118. /**
  60119. * Class used to represent a viewport on screen
  60120. */
  60121. export class Viewport {
  60122. /** viewport left coordinate */
  60123. x: number;
  60124. /** viewport top coordinate */
  60125. y: number;
  60126. /**viewport width */
  60127. width: number;
  60128. /** viewport height */
  60129. height: number;
  60130. /**
  60131. * Creates a Viewport object located at (x, y) and sized (width, height)
  60132. * @param x defines viewport left coordinate
  60133. * @param y defines viewport top coordinate
  60134. * @param width defines the viewport width
  60135. * @param height defines the viewport height
  60136. */
  60137. constructor(
  60138. /** viewport left coordinate */
  60139. x: number,
  60140. /** viewport top coordinate */
  60141. y: number,
  60142. /**viewport width */
  60143. width: number,
  60144. /** viewport height */
  60145. height: number);
  60146. /**
  60147. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60148. * @param renderWidth defines the rendering width
  60149. * @param renderHeight defines the rendering height
  60150. * @returns a new Viewport
  60151. */
  60152. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60153. /**
  60154. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60155. * @param renderWidth defines the rendering width
  60156. * @param renderHeight defines the rendering height
  60157. * @param ref defines the target viewport
  60158. * @returns the current viewport
  60159. */
  60160. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60161. /**
  60162. * Returns a new Viewport copied from the current one
  60163. * @returns a new Viewport
  60164. */
  60165. clone(): Viewport;
  60166. }
  60167. /**
  60168. * Reprasents a camera frustum
  60169. */
  60170. export class Frustum {
  60171. /**
  60172. * Gets the planes representing the frustum
  60173. * @param transform matrix to be applied to the returned planes
  60174. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60175. */
  60176. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60177. /**
  60178. * Gets the near frustum plane transformed by the transform matrix
  60179. * @param transform transformation matrix to be applied to the resulting frustum plane
  60180. * @param frustumPlane the resuling frustum plane
  60181. */
  60182. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60183. /**
  60184. * Gets the far frustum plane transformed by the transform matrix
  60185. * @param transform transformation matrix to be applied to the resulting frustum plane
  60186. * @param frustumPlane the resuling frustum plane
  60187. */
  60188. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60189. /**
  60190. * Gets the left frustum plane transformed by the transform matrix
  60191. * @param transform transformation matrix to be applied to the resulting frustum plane
  60192. * @param frustumPlane the resuling frustum plane
  60193. */
  60194. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60195. /**
  60196. * Gets the right frustum plane transformed by the transform matrix
  60197. * @param transform transformation matrix to be applied to the resulting frustum plane
  60198. * @param frustumPlane the resuling frustum plane
  60199. */
  60200. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60201. /**
  60202. * Gets the top frustum plane transformed by the transform matrix
  60203. * @param transform transformation matrix to be applied to the resulting frustum plane
  60204. * @param frustumPlane the resuling frustum plane
  60205. */
  60206. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60207. /**
  60208. * Gets the bottom frustum plane transformed by the transform matrix
  60209. * @param transform transformation matrix to be applied to the resulting frustum plane
  60210. * @param frustumPlane the resuling frustum plane
  60211. */
  60212. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60213. /**
  60214. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60215. * @param transform transformation matrix to be applied to the resulting frustum planes
  60216. * @param frustumPlanes the resuling frustum planes
  60217. */
  60218. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60219. }
  60220. /** Defines supported spaces */
  60221. export enum Space {
  60222. /** Local (object) space */
  60223. LOCAL = 0,
  60224. /** World space */
  60225. WORLD = 1,
  60226. /** Bone space */
  60227. BONE = 2
  60228. }
  60229. /** Defines the 3 main axes */
  60230. export class Axis {
  60231. /** X axis */
  60232. static X: Vector3;
  60233. /** Y axis */
  60234. static Y: Vector3;
  60235. /** Z axis */
  60236. static Z: Vector3;
  60237. }
  60238. /** Class used to represent a Bezier curve */
  60239. export class BezierCurve {
  60240. /**
  60241. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60242. * @param t defines the time
  60243. * @param x1 defines the left coordinate on X axis
  60244. * @param y1 defines the left coordinate on Y axis
  60245. * @param x2 defines the right coordinate on X axis
  60246. * @param y2 defines the right coordinate on Y axis
  60247. * @returns the interpolated value
  60248. */
  60249. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60250. }
  60251. /**
  60252. * Defines potential orientation for back face culling
  60253. */
  60254. export enum Orientation {
  60255. /**
  60256. * Clockwise
  60257. */
  60258. CW = 0,
  60259. /** Counter clockwise */
  60260. CCW = 1
  60261. }
  60262. /**
  60263. * Defines angle representation
  60264. */
  60265. export class Angle {
  60266. private _radians;
  60267. /**
  60268. * Creates an Angle object of "radians" radians (float).
  60269. * @param radians the angle in radians
  60270. */
  60271. constructor(radians: number);
  60272. /**
  60273. * Get value in degrees
  60274. * @returns the Angle value in degrees (float)
  60275. */
  60276. degrees(): number;
  60277. /**
  60278. * Get value in radians
  60279. * @returns the Angle value in radians (float)
  60280. */
  60281. radians(): number;
  60282. /**
  60283. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60284. * @param a defines first vector
  60285. * @param b defines second vector
  60286. * @returns a new Angle
  60287. */
  60288. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60289. /**
  60290. * Gets a new Angle object from the given float in radians
  60291. * @param radians defines the angle value in radians
  60292. * @returns a new Angle
  60293. */
  60294. static FromRadians(radians: number): Angle;
  60295. /**
  60296. * Gets a new Angle object from the given float in degrees
  60297. * @param degrees defines the angle value in degrees
  60298. * @returns a new Angle
  60299. */
  60300. static FromDegrees(degrees: number): Angle;
  60301. }
  60302. /**
  60303. * This represents an arc in a 2d space.
  60304. */
  60305. export class Arc2 {
  60306. /** Defines the start point of the arc */
  60307. startPoint: Vector2;
  60308. /** Defines the mid point of the arc */
  60309. midPoint: Vector2;
  60310. /** Defines the end point of the arc */
  60311. endPoint: Vector2;
  60312. /**
  60313. * Defines the center point of the arc.
  60314. */
  60315. centerPoint: Vector2;
  60316. /**
  60317. * Defines the radius of the arc.
  60318. */
  60319. radius: number;
  60320. /**
  60321. * Defines the angle of the arc (from mid point to end point).
  60322. */
  60323. angle: Angle;
  60324. /**
  60325. * Defines the start angle of the arc (from start point to middle point).
  60326. */
  60327. startAngle: Angle;
  60328. /**
  60329. * Defines the orientation of the arc (clock wise/counter clock wise).
  60330. */
  60331. orientation: Orientation;
  60332. /**
  60333. * Creates an Arc object from the three given points : start, middle and end.
  60334. * @param startPoint Defines the start point of the arc
  60335. * @param midPoint Defines the midlle point of the arc
  60336. * @param endPoint Defines the end point of the arc
  60337. */
  60338. constructor(
  60339. /** Defines the start point of the arc */
  60340. startPoint: Vector2,
  60341. /** Defines the mid point of the arc */
  60342. midPoint: Vector2,
  60343. /** Defines the end point of the arc */
  60344. endPoint: Vector2);
  60345. }
  60346. /**
  60347. * Represents a 2D path made up of multiple 2D points
  60348. */
  60349. export class Path2 {
  60350. private _points;
  60351. private _length;
  60352. /**
  60353. * If the path start and end point are the same
  60354. */
  60355. closed: boolean;
  60356. /**
  60357. * Creates a Path2 object from the starting 2D coordinates x and y.
  60358. * @param x the starting points x value
  60359. * @param y the starting points y value
  60360. */
  60361. constructor(x: number, y: number);
  60362. /**
  60363. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60364. * @param x the added points x value
  60365. * @param y the added points y value
  60366. * @returns the updated Path2.
  60367. */
  60368. addLineTo(x: number, y: number): Path2;
  60369. /**
  60370. * 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.
  60371. * @param midX middle point x value
  60372. * @param midY middle point y value
  60373. * @param endX end point x value
  60374. * @param endY end point y value
  60375. * @param numberOfSegments (default: 36)
  60376. * @returns the updated Path2.
  60377. */
  60378. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60379. /**
  60380. * Closes the Path2.
  60381. * @returns the Path2.
  60382. */
  60383. close(): Path2;
  60384. /**
  60385. * Gets the sum of the distance between each sequential point in the path
  60386. * @returns the Path2 total length (float).
  60387. */
  60388. length(): number;
  60389. /**
  60390. * Gets the points which construct the path
  60391. * @returns the Path2 internal array of points.
  60392. */
  60393. getPoints(): Vector2[];
  60394. /**
  60395. * Retreives the point at the distance aways from the starting point
  60396. * @param normalizedLengthPosition the length along the path to retreive the point from
  60397. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60398. */
  60399. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60400. /**
  60401. * Creates a new path starting from an x and y position
  60402. * @param x starting x value
  60403. * @param y starting y value
  60404. * @returns a new Path2 starting at the coordinates (x, y).
  60405. */
  60406. static StartingAt(x: number, y: number): Path2;
  60407. }
  60408. /**
  60409. * Represents a 3D path made up of multiple 3D points
  60410. */
  60411. export class Path3D {
  60412. /**
  60413. * an array of Vector3, the curve axis of the Path3D
  60414. */
  60415. path: Vector3[];
  60416. private _curve;
  60417. private _distances;
  60418. private _tangents;
  60419. private _normals;
  60420. private _binormals;
  60421. private _raw;
  60422. /**
  60423. * new Path3D(path, normal, raw)
  60424. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60425. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60426. * @param path an array of Vector3, the curve axis of the Path3D
  60427. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60428. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60429. */
  60430. constructor(
  60431. /**
  60432. * an array of Vector3, the curve axis of the Path3D
  60433. */
  60434. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60435. /**
  60436. * Returns the Path3D array of successive Vector3 designing its curve.
  60437. * @returns the Path3D array of successive Vector3 designing its curve.
  60438. */
  60439. getCurve(): Vector3[];
  60440. /**
  60441. * Returns an array populated with tangent vectors on each Path3D curve point.
  60442. * @returns an array populated with tangent vectors on each Path3D curve point.
  60443. */
  60444. getTangents(): Vector3[];
  60445. /**
  60446. * Returns an array populated with normal vectors on each Path3D curve point.
  60447. * @returns an array populated with normal vectors on each Path3D curve point.
  60448. */
  60449. getNormals(): Vector3[];
  60450. /**
  60451. * Returns an array populated with binormal vectors on each Path3D curve point.
  60452. * @returns an array populated with binormal vectors on each Path3D curve point.
  60453. */
  60454. getBinormals(): Vector3[];
  60455. /**
  60456. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60457. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60458. */
  60459. getDistances(): number[];
  60460. /**
  60461. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60462. * @param path path which all values are copied into the curves points
  60463. * @param firstNormal which should be projected onto the curve
  60464. * @returns the same object updated.
  60465. */
  60466. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60467. private _compute;
  60468. private _getFirstNonNullVector;
  60469. private _getLastNonNullVector;
  60470. private _normalVector;
  60471. }
  60472. /**
  60473. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60474. * A Curve3 is designed from a series of successive Vector3.
  60475. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60476. */
  60477. export class Curve3 {
  60478. private _points;
  60479. private _length;
  60480. /**
  60481. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60482. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60483. * @param v1 (Vector3) the control point
  60484. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60485. * @param nbPoints (integer) the wanted number of points in the curve
  60486. * @returns the created Curve3
  60487. */
  60488. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60489. /**
  60490. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60491. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60492. * @param v1 (Vector3) the first control point
  60493. * @param v2 (Vector3) the second control point
  60494. * @param v3 (Vector3) the end point of the Cubic Bezier
  60495. * @param nbPoints (integer) the wanted number of points in the curve
  60496. * @returns the created Curve3
  60497. */
  60498. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60499. /**
  60500. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60501. * @param p1 (Vector3) the origin point of the Hermite Spline
  60502. * @param t1 (Vector3) the tangent vector at the origin point
  60503. * @param p2 (Vector3) the end point of the Hermite Spline
  60504. * @param t2 (Vector3) the tangent vector at the end point
  60505. * @param nbPoints (integer) the wanted number of points in the curve
  60506. * @returns the created Curve3
  60507. */
  60508. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60509. /**
  60510. * Returns a Curve3 object along a CatmullRom Spline curve :
  60511. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60512. * @param nbPoints (integer) the wanted number of points between each curve control points
  60513. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60514. * @returns the created Curve3
  60515. */
  60516. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60517. /**
  60518. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60519. * A Curve3 is designed from a series of successive Vector3.
  60520. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60521. * @param points points which make up the curve
  60522. */
  60523. constructor(points: Vector3[]);
  60524. /**
  60525. * @returns the Curve3 stored array of successive Vector3
  60526. */
  60527. getPoints(): Vector3[];
  60528. /**
  60529. * @returns the computed length (float) of the curve.
  60530. */
  60531. length(): number;
  60532. /**
  60533. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60534. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60535. * curveA and curveB keep unchanged.
  60536. * @param curve the curve to continue from this curve
  60537. * @returns the newly constructed curve
  60538. */
  60539. continue(curve: DeepImmutable<Curve3>): Curve3;
  60540. private _computeLength;
  60541. }
  60542. /**
  60543. * Contains position and normal vectors for a vertex
  60544. */
  60545. export class PositionNormalVertex {
  60546. /** the position of the vertex (defaut: 0,0,0) */
  60547. position: Vector3;
  60548. /** the normal of the vertex (defaut: 0,1,0) */
  60549. normal: Vector3;
  60550. /**
  60551. * Creates a PositionNormalVertex
  60552. * @param position the position of the vertex (defaut: 0,0,0)
  60553. * @param normal the normal of the vertex (defaut: 0,1,0)
  60554. */
  60555. constructor(
  60556. /** the position of the vertex (defaut: 0,0,0) */
  60557. position?: Vector3,
  60558. /** the normal of the vertex (defaut: 0,1,0) */
  60559. normal?: Vector3);
  60560. /**
  60561. * Clones the PositionNormalVertex
  60562. * @returns the cloned PositionNormalVertex
  60563. */
  60564. clone(): PositionNormalVertex;
  60565. }
  60566. /**
  60567. * Contains position, normal and uv vectors for a vertex
  60568. */
  60569. export class PositionNormalTextureVertex {
  60570. /** the position of the vertex (defaut: 0,0,0) */
  60571. position: Vector3;
  60572. /** the normal of the vertex (defaut: 0,1,0) */
  60573. normal: Vector3;
  60574. /** the uv of the vertex (default: 0,0) */
  60575. uv: Vector2;
  60576. /**
  60577. * Creates a PositionNormalTextureVertex
  60578. * @param position the position of the vertex (defaut: 0,0,0)
  60579. * @param normal the normal of the vertex (defaut: 0,1,0)
  60580. * @param uv the uv of the vertex (default: 0,0)
  60581. */
  60582. constructor(
  60583. /** the position of the vertex (defaut: 0,0,0) */
  60584. position?: Vector3,
  60585. /** the normal of the vertex (defaut: 0,1,0) */
  60586. normal?: Vector3,
  60587. /** the uv of the vertex (default: 0,0) */
  60588. uv?: Vector2);
  60589. /**
  60590. * Clones the PositionNormalTextureVertex
  60591. * @returns the cloned PositionNormalTextureVertex
  60592. */
  60593. clone(): PositionNormalTextureVertex;
  60594. }
  60595. /**
  60596. * @hidden
  60597. */
  60598. export class Tmp {
  60599. static Color3: Color3[];
  60600. static Color4: Color4[];
  60601. static Vector2: Vector2[];
  60602. static Vector3: Vector3[];
  60603. static Vector4: Vector4[];
  60604. static Quaternion: Quaternion[];
  60605. static Matrix: Matrix[];
  60606. }
  60607. }
  60608. declare module BABYLON {
  60609. /**
  60610. * Class used to enable access to offline support
  60611. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60612. */
  60613. export interface IOfflineProvider {
  60614. /**
  60615. * Gets a boolean indicating if scene must be saved in the database
  60616. */
  60617. enableSceneOffline: boolean;
  60618. /**
  60619. * Gets a boolean indicating if textures must be saved in the database
  60620. */
  60621. enableTexturesOffline: boolean;
  60622. /**
  60623. * Open the offline support and make it available
  60624. * @param successCallback defines the callback to call on success
  60625. * @param errorCallback defines the callback to call on error
  60626. */
  60627. open(successCallback: () => void, errorCallback: () => void): void;
  60628. /**
  60629. * Loads an image from the offline support
  60630. * @param url defines the url to load from
  60631. * @param image defines the target DOM image
  60632. */
  60633. loadImage(url: string, image: HTMLImageElement): void;
  60634. /**
  60635. * Loads a file from offline support
  60636. * @param url defines the URL to load from
  60637. * @param sceneLoaded defines a callback to call on success
  60638. * @param progressCallBack defines a callback to call when progress changed
  60639. * @param errorCallback defines a callback to call on error
  60640. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60641. */
  60642. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60643. }
  60644. }
  60645. declare module BABYLON {
  60646. /**
  60647. * A class serves as a medium between the observable and its observers
  60648. */
  60649. export class EventState {
  60650. /**
  60651. * Create a new EventState
  60652. * @param mask defines the mask associated with this state
  60653. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60654. * @param target defines the original target of the state
  60655. * @param currentTarget defines the current target of the state
  60656. */
  60657. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60658. /**
  60659. * Initialize the current event state
  60660. * @param mask defines the mask associated with this state
  60661. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60662. * @param target defines the original target of the state
  60663. * @param currentTarget defines the current target of the state
  60664. * @returns the current event state
  60665. */
  60666. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60667. /**
  60668. * An Observer can set this property to true to prevent subsequent observers of being notified
  60669. */
  60670. skipNextObservers: boolean;
  60671. /**
  60672. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60673. */
  60674. mask: number;
  60675. /**
  60676. * The object that originally notified the event
  60677. */
  60678. target?: any;
  60679. /**
  60680. * The current object in the bubbling phase
  60681. */
  60682. currentTarget?: any;
  60683. /**
  60684. * This will be populated with the return value of the last function that was executed.
  60685. * If it is the first function in the callback chain it will be the event data.
  60686. */
  60687. lastReturnValue?: any;
  60688. }
  60689. /**
  60690. * Represent an Observer registered to a given Observable object.
  60691. */
  60692. export class Observer<T> {
  60693. /**
  60694. * Defines the callback to call when the observer is notified
  60695. */
  60696. callback: (eventData: T, eventState: EventState) => void;
  60697. /**
  60698. * Defines the mask of the observer (used to filter notifications)
  60699. */
  60700. mask: number;
  60701. /**
  60702. * Defines the current scope used to restore the JS context
  60703. */
  60704. scope: any;
  60705. /** @hidden */
  60706. _willBeUnregistered: boolean;
  60707. /**
  60708. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60709. */
  60710. unregisterOnNextCall: boolean;
  60711. /**
  60712. * Creates a new observer
  60713. * @param callback defines the callback to call when the observer is notified
  60714. * @param mask defines the mask of the observer (used to filter notifications)
  60715. * @param scope defines the current scope used to restore the JS context
  60716. */
  60717. constructor(
  60718. /**
  60719. * Defines the callback to call when the observer is notified
  60720. */
  60721. callback: (eventData: T, eventState: EventState) => void,
  60722. /**
  60723. * Defines the mask of the observer (used to filter notifications)
  60724. */
  60725. mask: number,
  60726. /**
  60727. * Defines the current scope used to restore the JS context
  60728. */
  60729. scope?: any);
  60730. }
  60731. /**
  60732. * Represent a list of observers registered to multiple Observables object.
  60733. */
  60734. export class MultiObserver<T> {
  60735. private _observers;
  60736. private _observables;
  60737. /**
  60738. * Release associated resources
  60739. */
  60740. dispose(): void;
  60741. /**
  60742. * Raise a callback when one of the observable will notify
  60743. * @param observables defines a list of observables to watch
  60744. * @param callback defines the callback to call on notification
  60745. * @param mask defines the mask used to filter notifications
  60746. * @param scope defines the current scope used to restore the JS context
  60747. * @returns the new MultiObserver
  60748. */
  60749. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60750. }
  60751. /**
  60752. * The Observable class is a simple implementation of the Observable pattern.
  60753. *
  60754. * 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.
  60755. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60756. * 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).
  60757. * 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.
  60758. */
  60759. export class Observable<T> {
  60760. private _observers;
  60761. private _eventState;
  60762. private _onObserverAdded;
  60763. /**
  60764. * Creates a new observable
  60765. * @param onObserverAdded defines a callback to call when a new observer is added
  60766. */
  60767. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60768. /**
  60769. * Create a new Observer with the specified callback
  60770. * @param callback the callback that will be executed for that Observer
  60771. * @param mask the mask used to filter observers
  60772. * @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.
  60773. * @param scope optional scope for the callback to be called from
  60774. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60775. * @returns the new observer created for the callback
  60776. */
  60777. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60778. /**
  60779. * Create a new Observer with the specified callback and unregisters after the next notification
  60780. * @param callback the callback that will be executed for that Observer
  60781. * @returns the new observer created for the callback
  60782. */
  60783. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60784. /**
  60785. * Remove an Observer from the Observable object
  60786. * @param observer the instance of the Observer to remove
  60787. * @returns false if it doesn't belong to this Observable
  60788. */
  60789. remove(observer: Nullable<Observer<T>>): boolean;
  60790. /**
  60791. * Remove a callback from the Observable object
  60792. * @param callback the callback to remove
  60793. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60794. * @returns false if it doesn't belong to this Observable
  60795. */
  60796. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60797. private _deferUnregister;
  60798. private _remove;
  60799. /**
  60800. * Notify all Observers by calling their respective callback with the given data
  60801. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60802. * @param eventData defines the data to send to all observers
  60803. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60804. * @param target defines the original target of the state
  60805. * @param currentTarget defines the current target of the state
  60806. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60807. */
  60808. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60809. /**
  60810. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60811. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60812. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60813. * and it is crucial that all callbacks will be executed.
  60814. * The order of the callbacks is kept, callbacks are not executed parallel.
  60815. *
  60816. * @param eventData The data to be sent to each callback
  60817. * @param mask is used to filter observers defaults to -1
  60818. * @param target defines the callback target (see EventState)
  60819. * @param currentTarget defines he current object in the bubbling phase
  60820. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60821. */
  60822. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60823. /**
  60824. * Notify a specific observer
  60825. * @param observer defines the observer to notify
  60826. * @param eventData defines the data to be sent to each callback
  60827. * @param mask is used to filter observers defaults to -1
  60828. */
  60829. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60830. /**
  60831. * Gets a boolean indicating if the observable has at least one observer
  60832. * @returns true is the Observable has at least one Observer registered
  60833. */
  60834. hasObservers(): boolean;
  60835. /**
  60836. * Clear the list of observers
  60837. */
  60838. clear(): void;
  60839. /**
  60840. * Clone the current observable
  60841. * @returns a new observable
  60842. */
  60843. clone(): Observable<T>;
  60844. /**
  60845. * Does this observable handles observer registered with a given mask
  60846. * @param mask defines the mask to be tested
  60847. * @return whether or not one observer registered with the given mask is handeled
  60848. **/
  60849. hasSpecificMask(mask?: number): boolean;
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /**
  60854. * Class used to help managing file picking and drag'n'drop
  60855. * File Storage
  60856. */
  60857. export class FilesInputStore {
  60858. /**
  60859. * List of files ready to be loaded
  60860. */
  60861. static FilesToLoad: {
  60862. [key: string]: File;
  60863. };
  60864. }
  60865. }
  60866. declare module BABYLON {
  60867. /** Defines the cross module used constants to avoid circular dependncies */
  60868. export class Constants {
  60869. /** Defines that alpha blending is disabled */
  60870. static readonly ALPHA_DISABLE: number;
  60871. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60872. static readonly ALPHA_ADD: number;
  60873. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60874. static readonly ALPHA_COMBINE: number;
  60875. /** Defines that alpha blending to DEST - SRC * DEST */
  60876. static readonly ALPHA_SUBTRACT: number;
  60877. /** Defines that alpha blending to SRC * DEST */
  60878. static readonly ALPHA_MULTIPLY: number;
  60879. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60880. static readonly ALPHA_MAXIMIZED: number;
  60881. /** Defines that alpha blending to SRC + DEST */
  60882. static readonly ALPHA_ONEONE: number;
  60883. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60884. static readonly ALPHA_PREMULTIPLIED: number;
  60885. /**
  60886. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60887. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60888. */
  60889. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60890. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60891. static readonly ALPHA_INTERPOLATE: number;
  60892. /**
  60893. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60894. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60895. */
  60896. static readonly ALPHA_SCREENMODE: number;
  60897. /** Defines that the ressource is not delayed*/
  60898. static readonly DELAYLOADSTATE_NONE: number;
  60899. /** Defines that the ressource was successfully delay loaded */
  60900. static readonly DELAYLOADSTATE_LOADED: number;
  60901. /** Defines that the ressource is currently delay loading */
  60902. static readonly DELAYLOADSTATE_LOADING: number;
  60903. /** Defines that the ressource is delayed and has not started loading */
  60904. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60906. static readonly NEVER: number;
  60907. /** 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 */
  60908. static readonly ALWAYS: number;
  60909. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60910. static readonly LESS: number;
  60911. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60912. static readonly EQUAL: number;
  60913. /** 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 */
  60914. static readonly LEQUAL: number;
  60915. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60916. static readonly GREATER: number;
  60917. /** 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 */
  60918. static readonly GEQUAL: number;
  60919. /** 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 */
  60920. static readonly NOTEQUAL: number;
  60921. /** Passed to stencilOperation to specify that stencil value must be kept */
  60922. static readonly KEEP: number;
  60923. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60924. static readonly REPLACE: number;
  60925. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60926. static readonly INCR: number;
  60927. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60928. static readonly DECR: number;
  60929. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60930. static readonly INVERT: number;
  60931. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60932. static readonly INCR_WRAP: number;
  60933. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60934. static readonly DECR_WRAP: number;
  60935. /** Texture is not repeating outside of 0..1 UVs */
  60936. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60937. /** Texture is repeating outside of 0..1 UVs */
  60938. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60939. /** Texture is repeating and mirrored */
  60940. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60941. /** ALPHA */
  60942. static readonly TEXTUREFORMAT_ALPHA: number;
  60943. /** LUMINANCE */
  60944. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60945. /** LUMINANCE_ALPHA */
  60946. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60947. /** RGB */
  60948. static readonly TEXTUREFORMAT_RGB: number;
  60949. /** RGBA */
  60950. static readonly TEXTUREFORMAT_RGBA: number;
  60951. /** RED */
  60952. static readonly TEXTUREFORMAT_RED: number;
  60953. /** RED (2nd reference) */
  60954. static readonly TEXTUREFORMAT_R: number;
  60955. /** RG */
  60956. static readonly TEXTUREFORMAT_RG: number;
  60957. /** RED_INTEGER */
  60958. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60959. /** RED_INTEGER (2nd reference) */
  60960. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60961. /** RG_INTEGER */
  60962. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60963. /** RGB_INTEGER */
  60964. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  60965. /** RGBA_INTEGER */
  60966. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  60967. /** UNSIGNED_BYTE */
  60968. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  60969. /** UNSIGNED_BYTE (2nd reference) */
  60970. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  60971. /** FLOAT */
  60972. static readonly TEXTURETYPE_FLOAT: number;
  60973. /** HALF_FLOAT */
  60974. static readonly TEXTURETYPE_HALF_FLOAT: number;
  60975. /** BYTE */
  60976. static readonly TEXTURETYPE_BYTE: number;
  60977. /** SHORT */
  60978. static readonly TEXTURETYPE_SHORT: number;
  60979. /** UNSIGNED_SHORT */
  60980. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  60981. /** INT */
  60982. static readonly TEXTURETYPE_INT: number;
  60983. /** UNSIGNED_INT */
  60984. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  60985. /** UNSIGNED_SHORT_4_4_4_4 */
  60986. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  60987. /** UNSIGNED_SHORT_5_5_5_1 */
  60988. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  60989. /** UNSIGNED_SHORT_5_6_5 */
  60990. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  60991. /** UNSIGNED_INT_2_10_10_10_REV */
  60992. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  60993. /** UNSIGNED_INT_24_8 */
  60994. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  60995. /** UNSIGNED_INT_10F_11F_11F_REV */
  60996. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  60997. /** UNSIGNED_INT_5_9_9_9_REV */
  60998. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  60999. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61000. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61001. /** nearest is mag = nearest and min = nearest and mip = linear */
  61002. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61003. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61004. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61005. /** Trilinear is mag = linear and min = linear and mip = linear */
  61006. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61007. /** nearest is mag = nearest and min = nearest and mip = linear */
  61008. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61009. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61010. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61011. /** Trilinear is mag = linear and min = linear and mip = linear */
  61012. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61013. /** mag = nearest and min = nearest and mip = nearest */
  61014. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61015. /** mag = nearest and min = linear and mip = nearest */
  61016. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61017. /** mag = nearest and min = linear and mip = linear */
  61018. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61019. /** mag = nearest and min = linear and mip = none */
  61020. static readonly TEXTURE_NEAREST_LINEAR: number;
  61021. /** mag = nearest and min = nearest and mip = none */
  61022. static readonly TEXTURE_NEAREST_NEAREST: number;
  61023. /** mag = linear and min = nearest and mip = nearest */
  61024. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61025. /** mag = linear and min = nearest and mip = linear */
  61026. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61027. /** mag = linear and min = linear and mip = none */
  61028. static readonly TEXTURE_LINEAR_LINEAR: number;
  61029. /** mag = linear and min = nearest and mip = none */
  61030. static readonly TEXTURE_LINEAR_NEAREST: number;
  61031. /** Explicit coordinates mode */
  61032. static readonly TEXTURE_EXPLICIT_MODE: number;
  61033. /** Spherical coordinates mode */
  61034. static readonly TEXTURE_SPHERICAL_MODE: number;
  61035. /** Planar coordinates mode */
  61036. static readonly TEXTURE_PLANAR_MODE: number;
  61037. /** Cubic coordinates mode */
  61038. static readonly TEXTURE_CUBIC_MODE: number;
  61039. /** Projection coordinates mode */
  61040. static readonly TEXTURE_PROJECTION_MODE: number;
  61041. /** Skybox coordinates mode */
  61042. static readonly TEXTURE_SKYBOX_MODE: number;
  61043. /** Inverse Cubic coordinates mode */
  61044. static readonly TEXTURE_INVCUBIC_MODE: number;
  61045. /** Equirectangular coordinates mode */
  61046. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61047. /** Equirectangular Fixed coordinates mode */
  61048. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61049. /** Equirectangular Fixed Mirrored coordinates mode */
  61050. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61051. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61052. static readonly SCALEMODE_FLOOR: number;
  61053. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61054. static readonly SCALEMODE_NEAREST: number;
  61055. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61056. static readonly SCALEMODE_CEILING: number;
  61057. /**
  61058. * The dirty texture flag value
  61059. */
  61060. static readonly MATERIAL_TextureDirtyFlag: number;
  61061. /**
  61062. * The dirty light flag value
  61063. */
  61064. static readonly MATERIAL_LightDirtyFlag: number;
  61065. /**
  61066. * The dirty fresnel flag value
  61067. */
  61068. static readonly MATERIAL_FresnelDirtyFlag: number;
  61069. /**
  61070. * The dirty attribute flag value
  61071. */
  61072. static readonly MATERIAL_AttributesDirtyFlag: number;
  61073. /**
  61074. * The dirty misc flag value
  61075. */
  61076. static readonly MATERIAL_MiscDirtyFlag: number;
  61077. /**
  61078. * The all dirty flag value
  61079. */
  61080. static readonly MATERIAL_AllDirtyFlag: number;
  61081. /**
  61082. * Returns the triangle fill mode
  61083. */
  61084. static readonly MATERIAL_TriangleFillMode: number;
  61085. /**
  61086. * Returns the wireframe mode
  61087. */
  61088. static readonly MATERIAL_WireFrameFillMode: number;
  61089. /**
  61090. * Returns the point fill mode
  61091. */
  61092. static readonly MATERIAL_PointFillMode: number;
  61093. /**
  61094. * Returns the point list draw mode
  61095. */
  61096. static readonly MATERIAL_PointListDrawMode: number;
  61097. /**
  61098. * Returns the line list draw mode
  61099. */
  61100. static readonly MATERIAL_LineListDrawMode: number;
  61101. /**
  61102. * Returns the line loop draw mode
  61103. */
  61104. static readonly MATERIAL_LineLoopDrawMode: number;
  61105. /**
  61106. * Returns the line strip draw mode
  61107. */
  61108. static readonly MATERIAL_LineStripDrawMode: number;
  61109. /**
  61110. * Returns the triangle strip draw mode
  61111. */
  61112. static readonly MATERIAL_TriangleStripDrawMode: number;
  61113. /**
  61114. * Returns the triangle fan draw mode
  61115. */
  61116. static readonly MATERIAL_TriangleFanDrawMode: number;
  61117. /**
  61118. * Stores the clock-wise side orientation
  61119. */
  61120. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61121. /**
  61122. * Stores the counter clock-wise side orientation
  61123. */
  61124. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61125. /**
  61126. * Nothing
  61127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61128. */
  61129. static readonly ACTION_NothingTrigger: number;
  61130. /**
  61131. * On pick
  61132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61133. */
  61134. static readonly ACTION_OnPickTrigger: number;
  61135. /**
  61136. * On left pick
  61137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61138. */
  61139. static readonly ACTION_OnLeftPickTrigger: number;
  61140. /**
  61141. * On right pick
  61142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61143. */
  61144. static readonly ACTION_OnRightPickTrigger: number;
  61145. /**
  61146. * On center pick
  61147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61148. */
  61149. static readonly ACTION_OnCenterPickTrigger: number;
  61150. /**
  61151. * On pick down
  61152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61153. */
  61154. static readonly ACTION_OnPickDownTrigger: number;
  61155. /**
  61156. * On double pick
  61157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61158. */
  61159. static readonly ACTION_OnDoublePickTrigger: number;
  61160. /**
  61161. * On pick up
  61162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61163. */
  61164. static readonly ACTION_OnPickUpTrigger: number;
  61165. /**
  61166. * On pick out.
  61167. * This trigger will only be raised if you also declared a OnPickDown
  61168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61169. */
  61170. static readonly ACTION_OnPickOutTrigger: number;
  61171. /**
  61172. * On long press
  61173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61174. */
  61175. static readonly ACTION_OnLongPressTrigger: number;
  61176. /**
  61177. * On pointer over
  61178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61179. */
  61180. static readonly ACTION_OnPointerOverTrigger: number;
  61181. /**
  61182. * On pointer out
  61183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61184. */
  61185. static readonly ACTION_OnPointerOutTrigger: number;
  61186. /**
  61187. * On every frame
  61188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61189. */
  61190. static readonly ACTION_OnEveryFrameTrigger: number;
  61191. /**
  61192. * On intersection enter
  61193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61194. */
  61195. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61196. /**
  61197. * On intersection exit
  61198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61199. */
  61200. static readonly ACTION_OnIntersectionExitTrigger: number;
  61201. /**
  61202. * On key down
  61203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61204. */
  61205. static readonly ACTION_OnKeyDownTrigger: number;
  61206. /**
  61207. * On key up
  61208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61209. */
  61210. static readonly ACTION_OnKeyUpTrigger: number;
  61211. /**
  61212. * Billboard mode will only apply to Y axis
  61213. */
  61214. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61215. /**
  61216. * Billboard mode will apply to all axes
  61217. */
  61218. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61219. /**
  61220. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61221. */
  61222. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61223. /**
  61224. * Gets or sets base Assets URL
  61225. */
  61226. static readonly PARTICLES_BaseAssetsUrl: string;
  61227. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61228. * Test order :
  61229. * Is the bounding sphere outside the frustum ?
  61230. * If not, are the bounding box vertices outside the frustum ?
  61231. * It not, then the cullable object is in the frustum.
  61232. */
  61233. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61234. /** Culling strategy : Bounding Sphere Only.
  61235. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61236. * It's also less accurate than the standard because some not visible objects can still be selected.
  61237. * Test : is the bounding sphere outside the frustum ?
  61238. * If not, then the cullable object is in the frustum.
  61239. */
  61240. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61241. /** Culling strategy : Optimistic Inclusion.
  61242. * This in an inclusion test first, then the standard exclusion test.
  61243. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61244. * 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.
  61245. * Anyway, it's as accurate as the standard strategy.
  61246. * Test :
  61247. * Is the cullable object bounding sphere center in the frustum ?
  61248. * If not, apply the default culling strategy.
  61249. */
  61250. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61251. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61252. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61253. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61254. * 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.
  61255. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61256. * Test :
  61257. * Is the cullable object bounding sphere center in the frustum ?
  61258. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61259. */
  61260. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61261. /**
  61262. * No logging while loading
  61263. */
  61264. static readonly SCENELOADER_NO_LOGGING: number;
  61265. /**
  61266. * Minimal logging while loading
  61267. */
  61268. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61269. /**
  61270. * Summary logging while loading
  61271. */
  61272. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61273. /**
  61274. * Detailled logging while loading
  61275. */
  61276. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61277. }
  61278. }
  61279. declare module BABYLON {
  61280. /**
  61281. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61282. * Babylon.js
  61283. */
  61284. export class DomManagement {
  61285. /**
  61286. * Checks if the window object exists
  61287. * @returns true if the window object exists
  61288. */
  61289. static IsWindowObjectExist(): boolean;
  61290. /**
  61291. * Extracts text content from a DOM element hierarchy
  61292. * @param element defines the root element
  61293. * @returns a string
  61294. */
  61295. static GetDOMTextContent(element: HTMLElement): string;
  61296. }
  61297. }
  61298. declare module BABYLON {
  61299. /**
  61300. * Logger used througouht the application to allow configuration of
  61301. * the log level required for the messages.
  61302. */
  61303. export class Logger {
  61304. /**
  61305. * No log
  61306. */
  61307. static readonly NoneLogLevel: number;
  61308. /**
  61309. * Only message logs
  61310. */
  61311. static readonly MessageLogLevel: number;
  61312. /**
  61313. * Only warning logs
  61314. */
  61315. static readonly WarningLogLevel: number;
  61316. /**
  61317. * Only error logs
  61318. */
  61319. static readonly ErrorLogLevel: number;
  61320. /**
  61321. * All logs
  61322. */
  61323. static readonly AllLogLevel: number;
  61324. private static _LogCache;
  61325. /**
  61326. * Gets a value indicating the number of loading errors
  61327. * @ignorenaming
  61328. */
  61329. static errorsCount: number;
  61330. /**
  61331. * Callback called when a new log is added
  61332. */
  61333. static OnNewCacheEntry: (entry: string) => void;
  61334. private static _AddLogEntry;
  61335. private static _FormatMessage;
  61336. private static _LogDisabled;
  61337. private static _LogEnabled;
  61338. private static _WarnDisabled;
  61339. private static _WarnEnabled;
  61340. private static _ErrorDisabled;
  61341. private static _ErrorEnabled;
  61342. /**
  61343. * Log a message to the console
  61344. */
  61345. static Log: (message: string) => void;
  61346. /**
  61347. * Write a warning message to the console
  61348. */
  61349. static Warn: (message: string) => void;
  61350. /**
  61351. * Write an error message to the console
  61352. */
  61353. static Error: (message: string) => void;
  61354. /**
  61355. * Gets current log cache (list of logs)
  61356. */
  61357. static readonly LogCache: string;
  61358. /**
  61359. * Clears the log cache
  61360. */
  61361. static ClearLogCache(): void;
  61362. /**
  61363. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61364. */
  61365. static LogLevels: number;
  61366. }
  61367. }
  61368. declare module BABYLON {
  61369. /** @hidden */
  61370. export class _TypeStore {
  61371. /** @hidden */
  61372. static RegisteredTypes: {
  61373. [key: string]: Object;
  61374. };
  61375. /** @hidden */
  61376. static GetClass(fqdn: string): any;
  61377. }
  61378. }
  61379. declare module BABYLON {
  61380. /**
  61381. * Class containing a set of static utilities functions for deep copy.
  61382. */
  61383. export class DeepCopier {
  61384. /**
  61385. * Tries to copy an object by duplicating every property
  61386. * @param source defines the source object
  61387. * @param destination defines the target object
  61388. * @param doNotCopyList defines a list of properties to avoid
  61389. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61390. */
  61391. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61392. }
  61393. }
  61394. declare module BABYLON {
  61395. /**
  61396. * Class containing a set of static utilities functions for precision date
  61397. */
  61398. export class PrecisionDate {
  61399. /**
  61400. * Gets either window.performance.now() if supported or Date.now() else
  61401. */
  61402. static readonly Now: number;
  61403. }
  61404. }
  61405. declare module BABYLON {
  61406. /** @hidden */
  61407. export class _DevTools {
  61408. static WarnImport(name: string): string;
  61409. }
  61410. }
  61411. declare module BABYLON {
  61412. /**
  61413. * Class used to evalaute queries containing `and` and `or` operators
  61414. */
  61415. export class AndOrNotEvaluator {
  61416. /**
  61417. * Evaluate a query
  61418. * @param query defines the query to evaluate
  61419. * @param evaluateCallback defines the callback used to filter result
  61420. * @returns true if the query matches
  61421. */
  61422. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61423. private static _HandleParenthesisContent;
  61424. private static _SimplifyNegation;
  61425. }
  61426. }
  61427. declare module BABYLON {
  61428. /**
  61429. * Class used to store custom tags
  61430. */
  61431. export class Tags {
  61432. /**
  61433. * Adds support for tags on the given object
  61434. * @param obj defines the object to use
  61435. */
  61436. static EnableFor(obj: any): void;
  61437. /**
  61438. * Removes tags support
  61439. * @param obj defines the object to use
  61440. */
  61441. static DisableFor(obj: any): void;
  61442. /**
  61443. * Gets a boolean indicating if the given object has tags
  61444. * @param obj defines the object to use
  61445. * @returns a boolean
  61446. */
  61447. static HasTags(obj: any): boolean;
  61448. /**
  61449. * Gets the tags available on a given object
  61450. * @param obj defines the object to use
  61451. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61452. * @returns the tags
  61453. */
  61454. static GetTags(obj: any, asString?: boolean): any;
  61455. /**
  61456. * Adds tags to an object
  61457. * @param obj defines the object to use
  61458. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61459. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61460. */
  61461. static AddTagsTo(obj: any, tagsString: string): void;
  61462. /**
  61463. * @hidden
  61464. */
  61465. static _AddTagTo(obj: any, tag: string): void;
  61466. /**
  61467. * Removes specific tags from a specific object
  61468. * @param obj defines the object to use
  61469. * @param tagsString defines the tags to remove
  61470. */
  61471. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61472. /**
  61473. * @hidden
  61474. */
  61475. static _RemoveTagFrom(obj: any, tag: string): void;
  61476. /**
  61477. * Defines if tags hosted on an object match a given query
  61478. * @param obj defines the object to use
  61479. * @param tagsQuery defines the tag query
  61480. * @returns a boolean
  61481. */
  61482. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61483. }
  61484. }
  61485. declare module BABYLON {
  61486. /**
  61487. * Manages the defines for the Material
  61488. */
  61489. export class MaterialDefines {
  61490. private _keys;
  61491. private _isDirty;
  61492. /** @hidden */
  61493. _renderId: number;
  61494. /** @hidden */
  61495. _areLightsDirty: boolean;
  61496. /** @hidden */
  61497. _areAttributesDirty: boolean;
  61498. /** @hidden */
  61499. _areTexturesDirty: boolean;
  61500. /** @hidden */
  61501. _areFresnelDirty: boolean;
  61502. /** @hidden */
  61503. _areMiscDirty: boolean;
  61504. /** @hidden */
  61505. _areImageProcessingDirty: boolean;
  61506. /** @hidden */
  61507. _normals: boolean;
  61508. /** @hidden */
  61509. _uvs: boolean;
  61510. /** @hidden */
  61511. _needNormals: boolean;
  61512. /** @hidden */
  61513. _needUVs: boolean;
  61514. /**
  61515. * Specifies if the material needs to be re-calculated
  61516. */
  61517. readonly isDirty: boolean;
  61518. /**
  61519. * Marks the material to indicate that it has been re-calculated
  61520. */
  61521. markAsProcessed(): void;
  61522. /**
  61523. * Marks the material to indicate that it needs to be re-calculated
  61524. */
  61525. markAsUnprocessed(): void;
  61526. /**
  61527. * Marks the material to indicate all of its defines need to be re-calculated
  61528. */
  61529. markAllAsDirty(): void;
  61530. /**
  61531. * Marks the material to indicate that image processing needs to be re-calculated
  61532. */
  61533. markAsImageProcessingDirty(): void;
  61534. /**
  61535. * Marks the material to indicate the lights need to be re-calculated
  61536. */
  61537. markAsLightDirty(): void;
  61538. /**
  61539. * Marks the attribute state as changed
  61540. */
  61541. markAsAttributesDirty(): void;
  61542. /**
  61543. * Marks the texture state as changed
  61544. */
  61545. markAsTexturesDirty(): void;
  61546. /**
  61547. * Marks the fresnel state as changed
  61548. */
  61549. markAsFresnelDirty(): void;
  61550. /**
  61551. * Marks the misc state as changed
  61552. */
  61553. markAsMiscDirty(): void;
  61554. /**
  61555. * Rebuilds the material defines
  61556. */
  61557. rebuild(): void;
  61558. /**
  61559. * Specifies if two material defines are equal
  61560. * @param other - A material define instance to compare to
  61561. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61562. */
  61563. isEqual(other: MaterialDefines): boolean;
  61564. /**
  61565. * Clones this instance's defines to another instance
  61566. * @param other - material defines to clone values to
  61567. */
  61568. cloneTo(other: MaterialDefines): void;
  61569. /**
  61570. * Resets the material define values
  61571. */
  61572. reset(): void;
  61573. /**
  61574. * Converts the material define values to a string
  61575. * @returns - String of material define information
  61576. */
  61577. toString(): string;
  61578. }
  61579. }
  61580. declare module BABYLON {
  61581. /**
  61582. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61583. */
  61584. export class PerformanceMonitor {
  61585. private _enabled;
  61586. private _rollingFrameTime;
  61587. private _lastFrameTimeMs;
  61588. /**
  61589. * constructor
  61590. * @param frameSampleSize The number of samples required to saturate the sliding window
  61591. */
  61592. constructor(frameSampleSize?: number);
  61593. /**
  61594. * Samples current frame
  61595. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61596. */
  61597. sampleFrame(timeMs?: number): void;
  61598. /**
  61599. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61600. */
  61601. readonly averageFrameTime: number;
  61602. /**
  61603. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61604. */
  61605. readonly averageFrameTimeVariance: number;
  61606. /**
  61607. * Returns the frame time of the most recent frame
  61608. */
  61609. readonly instantaneousFrameTime: number;
  61610. /**
  61611. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61612. */
  61613. readonly averageFPS: number;
  61614. /**
  61615. * Returns the average framerate in frames per second using the most recent frame time
  61616. */
  61617. readonly instantaneousFPS: number;
  61618. /**
  61619. * Returns true if enough samples have been taken to completely fill the sliding window
  61620. */
  61621. readonly isSaturated: boolean;
  61622. /**
  61623. * Enables contributions to the sliding window sample set
  61624. */
  61625. enable(): void;
  61626. /**
  61627. * Disables contributions to the sliding window sample set
  61628. * Samples will not be interpolated over the disabled period
  61629. */
  61630. disable(): void;
  61631. /**
  61632. * Returns true if sampling is enabled
  61633. */
  61634. readonly isEnabled: boolean;
  61635. /**
  61636. * Resets performance monitor
  61637. */
  61638. reset(): void;
  61639. }
  61640. /**
  61641. * RollingAverage
  61642. *
  61643. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61644. */
  61645. export class RollingAverage {
  61646. /**
  61647. * Current average
  61648. */
  61649. average: number;
  61650. /**
  61651. * Current variance
  61652. */
  61653. variance: number;
  61654. protected _samples: Array<number>;
  61655. protected _sampleCount: number;
  61656. protected _pos: number;
  61657. protected _m2: number;
  61658. /**
  61659. * constructor
  61660. * @param length The number of samples required to saturate the sliding window
  61661. */
  61662. constructor(length: number);
  61663. /**
  61664. * Adds a sample to the sample set
  61665. * @param v The sample value
  61666. */
  61667. add(v: number): void;
  61668. /**
  61669. * Returns previously added values or null if outside of history or outside the sliding window domain
  61670. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61671. * @return Value previously recorded with add() or null if outside of range
  61672. */
  61673. history(i: number): number;
  61674. /**
  61675. * Returns true if enough samples have been taken to completely fill the sliding window
  61676. * @return true if sample-set saturated
  61677. */
  61678. isSaturated(): boolean;
  61679. /**
  61680. * Resets the rolling average (equivalent to 0 samples taken so far)
  61681. */
  61682. reset(): void;
  61683. /**
  61684. * Wraps a value around the sample range boundaries
  61685. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61686. * @return Wrapped position in sample range
  61687. */
  61688. protected _wrapPosition(i: number): number;
  61689. }
  61690. }
  61691. declare module BABYLON {
  61692. /**
  61693. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61694. * The underlying implementation relies on an associative array to ensure the best performances.
  61695. * The value can be anything including 'null' but except 'undefined'
  61696. */
  61697. export class StringDictionary<T> {
  61698. /**
  61699. * This will clear this dictionary and copy the content from the 'source' one.
  61700. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61701. * @param source the dictionary to take the content from and copy to this dictionary
  61702. */
  61703. copyFrom(source: StringDictionary<T>): void;
  61704. /**
  61705. * Get a value based from its key
  61706. * @param key the given key to get the matching value from
  61707. * @return the value if found, otherwise undefined is returned
  61708. */
  61709. get(key: string): T | undefined;
  61710. /**
  61711. * Get a value from its key or add it if it doesn't exist.
  61712. * This method will ensure you that a given key/data will be present in the dictionary.
  61713. * @param key the given key to get the matching value from
  61714. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61715. * The factory will only be invoked if there's no data for the given key.
  61716. * @return the value corresponding to the key.
  61717. */
  61718. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61719. /**
  61720. * Get a value from its key if present in the dictionary otherwise add it
  61721. * @param key the key to get the value from
  61722. * @param val if there's no such key/value pair in the dictionary add it with this value
  61723. * @return the value corresponding to the key
  61724. */
  61725. getOrAdd(key: string, val: T): T;
  61726. /**
  61727. * Check if there's a given key in the dictionary
  61728. * @param key the key to check for
  61729. * @return true if the key is present, false otherwise
  61730. */
  61731. contains(key: string): boolean;
  61732. /**
  61733. * Add a new key and its corresponding value
  61734. * @param key the key to add
  61735. * @param value the value corresponding to the key
  61736. * @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
  61737. */
  61738. add(key: string, value: T): boolean;
  61739. /**
  61740. * Update a specific value associated to a key
  61741. * @param key defines the key to use
  61742. * @param value defines the value to store
  61743. * @returns true if the value was updated (or false if the key was not found)
  61744. */
  61745. set(key: string, value: T): boolean;
  61746. /**
  61747. * Get the element of the given key and remove it from the dictionary
  61748. * @param key defines the key to search
  61749. * @returns the value associated with the key or null if not found
  61750. */
  61751. getAndRemove(key: string): Nullable<T>;
  61752. /**
  61753. * Remove a key/value from the dictionary.
  61754. * @param key the key to remove
  61755. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61756. */
  61757. remove(key: string): boolean;
  61758. /**
  61759. * Clear the whole content of the dictionary
  61760. */
  61761. clear(): void;
  61762. /**
  61763. * Gets the current count
  61764. */
  61765. readonly count: number;
  61766. /**
  61767. * Execute a callback on each key/val of the dictionary.
  61768. * Note that you can remove any element in this dictionary in the callback implementation
  61769. * @param callback the callback to execute on a given key/value pair
  61770. */
  61771. forEach(callback: (key: string, val: T) => void): void;
  61772. /**
  61773. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61774. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61775. * Note that you can remove any element in this dictionary in the callback implementation
  61776. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61777. * @returns the first item
  61778. */
  61779. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61780. private _count;
  61781. private _data;
  61782. }
  61783. }
  61784. declare module BABYLON {
  61785. /**
  61786. * Helper class that provides a small promise polyfill
  61787. */
  61788. export class PromisePolyfill {
  61789. /**
  61790. * Static function used to check if the polyfill is required
  61791. * If this is the case then the function will inject the polyfill to window.Promise
  61792. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61793. */
  61794. static Apply(force?: boolean): void;
  61795. }
  61796. }
  61797. declare module BABYLON {
  61798. /**
  61799. * Class used to store data that will be store in GPU memory
  61800. */
  61801. export class Buffer {
  61802. private _engine;
  61803. private _buffer;
  61804. /** @hidden */
  61805. _data: Nullable<DataArray>;
  61806. private _updatable;
  61807. private _instanced;
  61808. /**
  61809. * Gets the byte stride.
  61810. */
  61811. readonly byteStride: number;
  61812. /**
  61813. * Constructor
  61814. * @param engine the engine
  61815. * @param data the data to use for this buffer
  61816. * @param updatable whether the data is updatable
  61817. * @param stride the stride (optional)
  61818. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61819. * @param instanced whether the buffer is instanced (optional)
  61820. * @param useBytes set to true if the stride in in bytes (optional)
  61821. */
  61822. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61823. /**
  61824. * Create a new VertexBuffer based on the current buffer
  61825. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61826. * @param offset defines offset in the buffer (0 by default)
  61827. * @param size defines the size in floats of attributes (position is 3 for instance)
  61828. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61829. * @param instanced defines if the vertex buffer contains indexed data
  61830. * @param useBytes defines if the offset and stride are in bytes
  61831. * @returns the new vertex buffer
  61832. */
  61833. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61834. /**
  61835. * Gets a boolean indicating if the Buffer is updatable?
  61836. * @returns true if the buffer is updatable
  61837. */
  61838. isUpdatable(): boolean;
  61839. /**
  61840. * Gets current buffer's data
  61841. * @returns a DataArray or null
  61842. */
  61843. getData(): Nullable<DataArray>;
  61844. /**
  61845. * Gets underlying native buffer
  61846. * @returns underlying native buffer
  61847. */
  61848. getBuffer(): Nullable<WebGLBuffer>;
  61849. /**
  61850. * Gets the stride in float32 units (i.e. byte stride / 4).
  61851. * May not be an integer if the byte stride is not divisible by 4.
  61852. * DEPRECATED. Use byteStride instead.
  61853. * @returns the stride in float32 units
  61854. */
  61855. getStrideSize(): number;
  61856. /**
  61857. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61858. * @param data defines the data to store
  61859. */
  61860. create(data?: Nullable<DataArray>): void;
  61861. /** @hidden */
  61862. _rebuild(): void;
  61863. /**
  61864. * Update current buffer data
  61865. * @param data defines the data to store
  61866. */
  61867. update(data: DataArray): void;
  61868. /**
  61869. * Updates the data directly.
  61870. * @param data the new data
  61871. * @param offset the new offset
  61872. * @param vertexCount the vertex count (optional)
  61873. * @param useBytes set to true if the offset is in bytes
  61874. */
  61875. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61876. /**
  61877. * Release all resources
  61878. */
  61879. dispose(): void;
  61880. }
  61881. /**
  61882. * Specialized buffer used to store vertex data
  61883. */
  61884. export class VertexBuffer {
  61885. /** @hidden */
  61886. _buffer: Buffer;
  61887. private _kind;
  61888. private _size;
  61889. private _ownsBuffer;
  61890. private _instanced;
  61891. private _instanceDivisor;
  61892. /**
  61893. * The byte type.
  61894. */
  61895. static readonly BYTE: number;
  61896. /**
  61897. * The unsigned byte type.
  61898. */
  61899. static readonly UNSIGNED_BYTE: number;
  61900. /**
  61901. * The short type.
  61902. */
  61903. static readonly SHORT: number;
  61904. /**
  61905. * The unsigned short type.
  61906. */
  61907. static readonly UNSIGNED_SHORT: number;
  61908. /**
  61909. * The integer type.
  61910. */
  61911. static readonly INT: number;
  61912. /**
  61913. * The unsigned integer type.
  61914. */
  61915. static readonly UNSIGNED_INT: number;
  61916. /**
  61917. * The float type.
  61918. */
  61919. static readonly FLOAT: number;
  61920. /**
  61921. * Gets or sets the instance divisor when in instanced mode
  61922. */
  61923. instanceDivisor: number;
  61924. /**
  61925. * Gets the byte stride.
  61926. */
  61927. readonly byteStride: number;
  61928. /**
  61929. * Gets the byte offset.
  61930. */
  61931. readonly byteOffset: number;
  61932. /**
  61933. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61934. */
  61935. readonly normalized: boolean;
  61936. /**
  61937. * Gets the data type of each component in the array.
  61938. */
  61939. readonly type: number;
  61940. /**
  61941. * Constructor
  61942. * @param engine the engine
  61943. * @param data the data to use for this vertex buffer
  61944. * @param kind the vertex buffer kind
  61945. * @param updatable whether the data is updatable
  61946. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61947. * @param stride the stride (optional)
  61948. * @param instanced whether the buffer is instanced (optional)
  61949. * @param offset the offset of the data (optional)
  61950. * @param size the number of components (optional)
  61951. * @param type the type of the component (optional)
  61952. * @param normalized whether the data contains normalized data (optional)
  61953. * @param useBytes set to true if stride and offset are in bytes (optional)
  61954. */
  61955. 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);
  61956. /** @hidden */
  61957. _rebuild(): void;
  61958. /**
  61959. * Returns the kind of the VertexBuffer (string)
  61960. * @returns a string
  61961. */
  61962. getKind(): string;
  61963. /**
  61964. * Gets a boolean indicating if the VertexBuffer is updatable?
  61965. * @returns true if the buffer is updatable
  61966. */
  61967. isUpdatable(): boolean;
  61968. /**
  61969. * Gets current buffer's data
  61970. * @returns a DataArray or null
  61971. */
  61972. getData(): Nullable<DataArray>;
  61973. /**
  61974. * Gets underlying native buffer
  61975. * @returns underlying native buffer
  61976. */
  61977. getBuffer(): Nullable<WebGLBuffer>;
  61978. /**
  61979. * Gets the stride in float32 units (i.e. byte stride / 4).
  61980. * May not be an integer if the byte stride is not divisible by 4.
  61981. * DEPRECATED. Use byteStride instead.
  61982. * @returns the stride in float32 units
  61983. */
  61984. getStrideSize(): number;
  61985. /**
  61986. * Returns the offset as a multiple of the type byte length.
  61987. * DEPRECATED. Use byteOffset instead.
  61988. * @returns the offset in bytes
  61989. */
  61990. getOffset(): number;
  61991. /**
  61992. * Returns the number of components per vertex attribute (integer)
  61993. * @returns the size in float
  61994. */
  61995. getSize(): number;
  61996. /**
  61997. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  61998. * @returns true if this buffer is instanced
  61999. */
  62000. getIsInstanced(): boolean;
  62001. /**
  62002. * Returns the instancing divisor, zero for non-instanced (integer).
  62003. * @returns a number
  62004. */
  62005. getInstanceDivisor(): number;
  62006. /**
  62007. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62008. * @param data defines the data to store
  62009. */
  62010. create(data?: DataArray): void;
  62011. /**
  62012. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62013. * This function will create a new buffer if the current one is not updatable
  62014. * @param data defines the data to store
  62015. */
  62016. update(data: DataArray): void;
  62017. /**
  62018. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62019. * Returns the directly updated WebGLBuffer.
  62020. * @param data the new data
  62021. * @param offset the new offset
  62022. * @param useBytes set to true if the offset is in bytes
  62023. */
  62024. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62025. /**
  62026. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62027. */
  62028. dispose(): void;
  62029. /**
  62030. * Enumerates each value of this vertex buffer as numbers.
  62031. * @param count the number of values to enumerate
  62032. * @param callback the callback function called for each value
  62033. */
  62034. forEach(count: number, callback: (value: number, index: number) => void): void;
  62035. /**
  62036. * Positions
  62037. */
  62038. static readonly PositionKind: string;
  62039. /**
  62040. * Normals
  62041. */
  62042. static readonly NormalKind: string;
  62043. /**
  62044. * Tangents
  62045. */
  62046. static readonly TangentKind: string;
  62047. /**
  62048. * Texture coordinates
  62049. */
  62050. static readonly UVKind: string;
  62051. /**
  62052. * Texture coordinates 2
  62053. */
  62054. static readonly UV2Kind: string;
  62055. /**
  62056. * Texture coordinates 3
  62057. */
  62058. static readonly UV3Kind: string;
  62059. /**
  62060. * Texture coordinates 4
  62061. */
  62062. static readonly UV4Kind: string;
  62063. /**
  62064. * Texture coordinates 5
  62065. */
  62066. static readonly UV5Kind: string;
  62067. /**
  62068. * Texture coordinates 6
  62069. */
  62070. static readonly UV6Kind: string;
  62071. /**
  62072. * Colors
  62073. */
  62074. static readonly ColorKind: string;
  62075. /**
  62076. * Matrix indices (for bones)
  62077. */
  62078. static readonly MatricesIndicesKind: string;
  62079. /**
  62080. * Matrix weights (for bones)
  62081. */
  62082. static readonly MatricesWeightsKind: string;
  62083. /**
  62084. * Additional matrix indices (for bones)
  62085. */
  62086. static readonly MatricesIndicesExtraKind: string;
  62087. /**
  62088. * Additional matrix weights (for bones)
  62089. */
  62090. static readonly MatricesWeightsExtraKind: string;
  62091. /**
  62092. * Deduces the stride given a kind.
  62093. * @param kind The kind string to deduce
  62094. * @returns The deduced stride
  62095. */
  62096. static DeduceStride(kind: string): number;
  62097. /**
  62098. * Gets the byte length of the given type.
  62099. * @param type the type
  62100. * @returns the number of bytes
  62101. */
  62102. static GetTypeByteLength(type: number): number;
  62103. /**
  62104. * Enumerates each value of the given parameters as numbers.
  62105. * @param data the data to enumerate
  62106. * @param byteOffset the byte offset of the data
  62107. * @param byteStride the byte stride of the data
  62108. * @param componentCount the number of components per element
  62109. * @param componentType the type of the component
  62110. * @param count the total number of components
  62111. * @param normalized whether the data is normalized
  62112. * @param callback the callback function called for each value
  62113. */
  62114. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62115. private static _GetFloatValue;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * Class representing spherical polynomial coefficients to the 3rd degree
  62121. */
  62122. export class SphericalPolynomial {
  62123. /**
  62124. * The x coefficients of the spherical polynomial
  62125. */
  62126. x: Vector3;
  62127. /**
  62128. * The y coefficients of the spherical polynomial
  62129. */
  62130. y: Vector3;
  62131. /**
  62132. * The z coefficients of the spherical polynomial
  62133. */
  62134. z: Vector3;
  62135. /**
  62136. * The xx coefficients of the spherical polynomial
  62137. */
  62138. xx: Vector3;
  62139. /**
  62140. * The yy coefficients of the spherical polynomial
  62141. */
  62142. yy: Vector3;
  62143. /**
  62144. * The zz coefficients of the spherical polynomial
  62145. */
  62146. zz: Vector3;
  62147. /**
  62148. * The xy coefficients of the spherical polynomial
  62149. */
  62150. xy: Vector3;
  62151. /**
  62152. * The yz coefficients of the spherical polynomial
  62153. */
  62154. yz: Vector3;
  62155. /**
  62156. * The zx coefficients of the spherical polynomial
  62157. */
  62158. zx: Vector3;
  62159. /**
  62160. * Adds an ambient color to the spherical polynomial
  62161. * @param color the color to add
  62162. */
  62163. addAmbient(color: Color3): void;
  62164. /**
  62165. * Scales the spherical polynomial by the given amount
  62166. * @param scale the amount to scale
  62167. */
  62168. scale(scale: number): void;
  62169. /**
  62170. * Gets the spherical polynomial from harmonics
  62171. * @param harmonics the spherical harmonics
  62172. * @returns the spherical polynomial
  62173. */
  62174. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62175. /**
  62176. * Constructs a spherical polynomial from an array.
  62177. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62178. * @returns the spherical polynomial
  62179. */
  62180. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62181. }
  62182. /**
  62183. * Class representing spherical harmonics coefficients to the 3rd degree
  62184. */
  62185. export class SphericalHarmonics {
  62186. /**
  62187. * The l0,0 coefficients of the spherical harmonics
  62188. */
  62189. l00: Vector3;
  62190. /**
  62191. * The l1,-1 coefficients of the spherical harmonics
  62192. */
  62193. l1_1: Vector3;
  62194. /**
  62195. * The l1,0 coefficients of the spherical harmonics
  62196. */
  62197. l10: Vector3;
  62198. /**
  62199. * The l1,1 coefficients of the spherical harmonics
  62200. */
  62201. l11: Vector3;
  62202. /**
  62203. * The l2,-2 coefficients of the spherical harmonics
  62204. */
  62205. l2_2: Vector3;
  62206. /**
  62207. * The l2,-1 coefficients of the spherical harmonics
  62208. */
  62209. l2_1: Vector3;
  62210. /**
  62211. * The l2,0 coefficients of the spherical harmonics
  62212. */
  62213. l20: Vector3;
  62214. /**
  62215. * The l2,1 coefficients of the spherical harmonics
  62216. */
  62217. l21: Vector3;
  62218. /**
  62219. * The l2,2 coefficients of the spherical harmonics
  62220. */
  62221. lL22: Vector3;
  62222. /**
  62223. * Adds a light to the spherical harmonics
  62224. * @param direction the direction of the light
  62225. * @param color the color of the light
  62226. * @param deltaSolidAngle the delta solid angle of the light
  62227. */
  62228. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62229. /**
  62230. * Scales the spherical harmonics by the given amount
  62231. * @param scale the amount to scale
  62232. */
  62233. scale(scale: number): void;
  62234. /**
  62235. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62236. *
  62237. * ```
  62238. * E_lm = A_l * L_lm
  62239. * ```
  62240. *
  62241. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62242. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62243. * the scaling factors are given in equation 9.
  62244. */
  62245. convertIncidentRadianceToIrradiance(): void;
  62246. /**
  62247. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62248. *
  62249. * ```
  62250. * L = (1/pi) * E * rho
  62251. * ```
  62252. *
  62253. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62254. */
  62255. convertIrradianceToLambertianRadiance(): void;
  62256. /**
  62257. * Gets the spherical harmonics from polynomial
  62258. * @param polynomial the spherical polynomial
  62259. * @returns the spherical harmonics
  62260. */
  62261. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62262. /**
  62263. * Constructs a spherical harmonics from an array.
  62264. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62265. * @returns the spherical harmonics
  62266. */
  62267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62268. }
  62269. }
  62270. declare module BABYLON {
  62271. /**
  62272. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62273. */
  62274. export interface CubeMapInfo {
  62275. /**
  62276. * The pixel array for the front face.
  62277. * This is stored in format, left to right, up to down format.
  62278. */
  62279. front: Nullable<ArrayBufferView>;
  62280. /**
  62281. * The pixel array for the back face.
  62282. * This is stored in format, left to right, up to down format.
  62283. */
  62284. back: Nullable<ArrayBufferView>;
  62285. /**
  62286. * The pixel array for the left face.
  62287. * This is stored in format, left to right, up to down format.
  62288. */
  62289. left: Nullable<ArrayBufferView>;
  62290. /**
  62291. * The pixel array for the right face.
  62292. * This is stored in format, left to right, up to down format.
  62293. */
  62294. right: Nullable<ArrayBufferView>;
  62295. /**
  62296. * The pixel array for the up face.
  62297. * This is stored in format, left to right, up to down format.
  62298. */
  62299. up: Nullable<ArrayBufferView>;
  62300. /**
  62301. * The pixel array for the down face.
  62302. * This is stored in format, left to right, up to down format.
  62303. */
  62304. down: Nullable<ArrayBufferView>;
  62305. /**
  62306. * The size of the cubemap stored.
  62307. *
  62308. * Each faces will be size * size pixels.
  62309. */
  62310. size: number;
  62311. /**
  62312. * The format of the texture.
  62313. *
  62314. * RGBA, RGB.
  62315. */
  62316. format: number;
  62317. /**
  62318. * The type of the texture data.
  62319. *
  62320. * UNSIGNED_INT, FLOAT.
  62321. */
  62322. type: number;
  62323. /**
  62324. * Specifies whether the texture is in gamma space.
  62325. */
  62326. gammaSpace: boolean;
  62327. }
  62328. /**
  62329. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62330. */
  62331. export class PanoramaToCubeMapTools {
  62332. private static FACE_FRONT;
  62333. private static FACE_BACK;
  62334. private static FACE_RIGHT;
  62335. private static FACE_LEFT;
  62336. private static FACE_DOWN;
  62337. private static FACE_UP;
  62338. /**
  62339. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62340. *
  62341. * @param float32Array The source data.
  62342. * @param inputWidth The width of the input panorama.
  62343. * @param inputHeight The height of the input panorama.
  62344. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62345. * @return The cubemap data
  62346. */
  62347. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62348. private static CreateCubemapTexture;
  62349. private static CalcProjectionSpherical;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /**
  62354. * Helper class dealing with the extraction of spherical polynomial dataArray
  62355. * from a cube map.
  62356. */
  62357. export class CubeMapToSphericalPolynomialTools {
  62358. private static FileFaces;
  62359. /**
  62360. * Converts a texture to the according Spherical Polynomial data.
  62361. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62362. *
  62363. * @param texture The texture to extract the information from.
  62364. * @return The Spherical Polynomial data.
  62365. */
  62366. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62367. /**
  62368. * Converts a cubemap to the according Spherical Polynomial data.
  62369. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62370. *
  62371. * @param cubeInfo The Cube map to extract the information from.
  62372. * @return The Spherical Polynomial data.
  62373. */
  62374. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62375. }
  62376. }
  62377. declare module BABYLON {
  62378. /**
  62379. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62380. * during the life time of the application.
  62381. */
  62382. export class EngineStore {
  62383. /** Gets the list of created engines */
  62384. static Instances: Engine[];
  62385. /**
  62386. * Gets the latest created engine
  62387. */
  62388. static readonly LastCreatedEngine: Nullable<Engine>;
  62389. /**
  62390. * Gets the latest created scene
  62391. */
  62392. static readonly LastCreatedScene: Nullable<Scene>;
  62393. }
  62394. }
  62395. declare module BABYLON {
  62396. /**
  62397. * Define options used to create a render target texture
  62398. */
  62399. export class RenderTargetCreationOptions {
  62400. /**
  62401. * Specifies is mipmaps must be generated
  62402. */
  62403. generateMipMaps?: boolean;
  62404. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62405. generateDepthBuffer?: boolean;
  62406. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62407. generateStencilBuffer?: boolean;
  62408. /** Defines texture type (int by default) */
  62409. type?: number;
  62410. /** Defines sampling mode (trilinear by default) */
  62411. samplingMode?: number;
  62412. /** Defines format (RGBA by default) */
  62413. format?: number;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. /**
  62418. * @hidden
  62419. **/
  62420. export class _AlphaState {
  62421. private _isAlphaBlendDirty;
  62422. private _isBlendFunctionParametersDirty;
  62423. private _isBlendEquationParametersDirty;
  62424. private _isBlendConstantsDirty;
  62425. private _alphaBlend;
  62426. private _blendFunctionParameters;
  62427. private _blendEquationParameters;
  62428. private _blendConstants;
  62429. /**
  62430. * Initializes the state.
  62431. */
  62432. constructor();
  62433. readonly isDirty: boolean;
  62434. alphaBlend: boolean;
  62435. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62436. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62437. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62438. reset(): void;
  62439. apply(gl: WebGLRenderingContext): void;
  62440. }
  62441. }
  62442. declare module BABYLON {
  62443. /**
  62444. * @hidden
  62445. **/
  62446. export class _DepthCullingState {
  62447. private _isDepthTestDirty;
  62448. private _isDepthMaskDirty;
  62449. private _isDepthFuncDirty;
  62450. private _isCullFaceDirty;
  62451. private _isCullDirty;
  62452. private _isZOffsetDirty;
  62453. private _isFrontFaceDirty;
  62454. private _depthTest;
  62455. private _depthMask;
  62456. private _depthFunc;
  62457. private _cull;
  62458. private _cullFace;
  62459. private _zOffset;
  62460. private _frontFace;
  62461. /**
  62462. * Initializes the state.
  62463. */
  62464. constructor();
  62465. readonly isDirty: boolean;
  62466. zOffset: number;
  62467. cullFace: Nullable<number>;
  62468. cull: Nullable<boolean>;
  62469. depthFunc: Nullable<number>;
  62470. depthMask: boolean;
  62471. depthTest: boolean;
  62472. frontFace: Nullable<number>;
  62473. reset(): void;
  62474. apply(gl: WebGLRenderingContext): void;
  62475. }
  62476. }
  62477. declare module BABYLON {
  62478. /**
  62479. * @hidden
  62480. **/
  62481. export class _StencilState {
  62482. /** 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 */
  62483. static readonly ALWAYS: number;
  62484. /** Passed to stencilOperation to specify that stencil value must be kept */
  62485. static readonly KEEP: number;
  62486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62487. static readonly REPLACE: number;
  62488. private _isStencilTestDirty;
  62489. private _isStencilMaskDirty;
  62490. private _isStencilFuncDirty;
  62491. private _isStencilOpDirty;
  62492. private _stencilTest;
  62493. private _stencilMask;
  62494. private _stencilFunc;
  62495. private _stencilFuncRef;
  62496. private _stencilFuncMask;
  62497. private _stencilOpStencilFail;
  62498. private _stencilOpDepthFail;
  62499. private _stencilOpStencilDepthPass;
  62500. readonly isDirty: boolean;
  62501. stencilFunc: number;
  62502. stencilFuncRef: number;
  62503. stencilFuncMask: number;
  62504. stencilOpStencilFail: number;
  62505. stencilOpDepthFail: number;
  62506. stencilOpStencilDepthPass: number;
  62507. stencilMask: number;
  62508. stencilTest: boolean;
  62509. constructor();
  62510. reset(): void;
  62511. apply(gl: WebGLRenderingContext): void;
  62512. }
  62513. }
  62514. declare module BABYLON {
  62515. /**
  62516. * @hidden
  62517. **/
  62518. export class _TimeToken {
  62519. _startTimeQuery: Nullable<WebGLQuery>;
  62520. _endTimeQuery: Nullable<WebGLQuery>;
  62521. _timeElapsedQuery: Nullable<WebGLQuery>;
  62522. _timeElapsedQueryEnded: boolean;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * Internal interface used to track InternalTexture already bound to the GL context
  62528. */
  62529. export interface IInternalTextureTracker {
  62530. /**
  62531. * Gets or set the previous tracker in the list
  62532. */
  62533. previous: Nullable<IInternalTextureTracker>;
  62534. /**
  62535. * Gets or set the next tracker in the list
  62536. */
  62537. next: Nullable<IInternalTextureTracker>;
  62538. }
  62539. /**
  62540. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62541. */
  62542. export class DummyInternalTextureTracker {
  62543. /**
  62544. * Gets or set the previous tracker in the list
  62545. */
  62546. previous: Nullable<IInternalTextureTracker>;
  62547. /**
  62548. * Gets or set the next tracker in the list
  62549. */
  62550. next: Nullable<IInternalTextureTracker>;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Class used to store data associated with WebGL texture data for the engine
  62556. * This class should not be used directly
  62557. */
  62558. export class InternalTexture implements IInternalTextureTracker {
  62559. /** hidden */
  62560. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62561. /**
  62562. * The source of the texture data is unknown
  62563. */
  62564. static DATASOURCE_UNKNOWN: number;
  62565. /**
  62566. * Texture data comes from an URL
  62567. */
  62568. static DATASOURCE_URL: number;
  62569. /**
  62570. * Texture data is only used for temporary storage
  62571. */
  62572. static DATASOURCE_TEMP: number;
  62573. /**
  62574. * Texture data comes from raw data (ArrayBuffer)
  62575. */
  62576. static DATASOURCE_RAW: number;
  62577. /**
  62578. * Texture content is dynamic (video or dynamic texture)
  62579. */
  62580. static DATASOURCE_DYNAMIC: number;
  62581. /**
  62582. * Texture content is generated by rendering to it
  62583. */
  62584. static DATASOURCE_RENDERTARGET: number;
  62585. /**
  62586. * Texture content is part of a multi render target process
  62587. */
  62588. static DATASOURCE_MULTIRENDERTARGET: number;
  62589. /**
  62590. * Texture data comes from a cube data file
  62591. */
  62592. static DATASOURCE_CUBE: number;
  62593. /**
  62594. * Texture data comes from a raw cube data
  62595. */
  62596. static DATASOURCE_CUBERAW: number;
  62597. /**
  62598. * Texture data come from a prefiltered cube data file
  62599. */
  62600. static DATASOURCE_CUBEPREFILTERED: number;
  62601. /**
  62602. * Texture content is raw 3D data
  62603. */
  62604. static DATASOURCE_RAW3D: number;
  62605. /**
  62606. * Texture content is a depth texture
  62607. */
  62608. static DATASOURCE_DEPTHTEXTURE: number;
  62609. /**
  62610. * Texture data comes from a raw cube data encoded with RGBD
  62611. */
  62612. static DATASOURCE_CUBERAW_RGBD: number;
  62613. /**
  62614. * Defines if the texture is ready
  62615. */
  62616. isReady: boolean;
  62617. /**
  62618. * Defines if the texture is a cube texture
  62619. */
  62620. isCube: boolean;
  62621. /**
  62622. * Defines if the texture contains 3D data
  62623. */
  62624. is3D: boolean;
  62625. /**
  62626. * Gets the URL used to load this texture
  62627. */
  62628. url: string;
  62629. /**
  62630. * Gets the sampling mode of the texture
  62631. */
  62632. samplingMode: number;
  62633. /**
  62634. * Gets a boolean indicating if the texture needs mipmaps generation
  62635. */
  62636. generateMipMaps: boolean;
  62637. /**
  62638. * Gets the number of samples used by the texture (WebGL2+ only)
  62639. */
  62640. samples: number;
  62641. /**
  62642. * Gets the type of the texture (int, float...)
  62643. */
  62644. type: number;
  62645. /**
  62646. * Gets the format of the texture (RGB, RGBA...)
  62647. */
  62648. format: number;
  62649. /**
  62650. * Observable called when the texture is loaded
  62651. */
  62652. onLoadedObservable: Observable<InternalTexture>;
  62653. /**
  62654. * Gets the width of the texture
  62655. */
  62656. width: number;
  62657. /**
  62658. * Gets the height of the texture
  62659. */
  62660. height: number;
  62661. /**
  62662. * Gets the depth of the texture
  62663. */
  62664. depth: number;
  62665. /**
  62666. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62667. */
  62668. baseWidth: number;
  62669. /**
  62670. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62671. */
  62672. baseHeight: number;
  62673. /**
  62674. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62675. */
  62676. baseDepth: number;
  62677. /**
  62678. * Gets a boolean indicating if the texture is inverted on Y axis
  62679. */
  62680. invertY: boolean;
  62681. /**
  62682. * Gets or set the previous tracker in the list
  62683. */
  62684. previous: Nullable<IInternalTextureTracker>;
  62685. /**
  62686. * Gets or set the next tracker in the list
  62687. */
  62688. next: Nullable<IInternalTextureTracker>;
  62689. /** @hidden */
  62690. _invertVScale: boolean;
  62691. /** @hidden */
  62692. _initialSlot: number;
  62693. /** @hidden */
  62694. _designatedSlot: number;
  62695. /** @hidden */
  62696. _dataSource: number;
  62697. /** @hidden */
  62698. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62699. /** @hidden */
  62700. _bufferView: Nullable<ArrayBufferView>;
  62701. /** @hidden */
  62702. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62703. /** @hidden */
  62704. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62705. /** @hidden */
  62706. _size: number;
  62707. /** @hidden */
  62708. _extension: string;
  62709. /** @hidden */
  62710. _files: Nullable<string[]>;
  62711. /** @hidden */
  62712. _workingCanvas: HTMLCanvasElement;
  62713. /** @hidden */
  62714. _workingContext: CanvasRenderingContext2D;
  62715. /** @hidden */
  62716. _framebuffer: Nullable<WebGLFramebuffer>;
  62717. /** @hidden */
  62718. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62719. /** @hidden */
  62720. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62721. /** @hidden */
  62722. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62723. /** @hidden */
  62724. _attachments: Nullable<number[]>;
  62725. /** @hidden */
  62726. _cachedCoordinatesMode: Nullable<number>;
  62727. /** @hidden */
  62728. _cachedWrapU: Nullable<number>;
  62729. /** @hidden */
  62730. _cachedWrapV: Nullable<number>;
  62731. /** @hidden */
  62732. _cachedWrapR: Nullable<number>;
  62733. /** @hidden */
  62734. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62735. /** @hidden */
  62736. _isDisabled: boolean;
  62737. /** @hidden */
  62738. _compression: Nullable<string>;
  62739. /** @hidden */
  62740. _generateStencilBuffer: boolean;
  62741. /** @hidden */
  62742. _generateDepthBuffer: boolean;
  62743. /** @hidden */
  62744. _comparisonFunction: number;
  62745. /** @hidden */
  62746. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62747. /** @hidden */
  62748. _lodGenerationScale: number;
  62749. /** @hidden */
  62750. _lodGenerationOffset: number;
  62751. /** @hidden */
  62752. _lodTextureHigh: BaseTexture;
  62753. /** @hidden */
  62754. _lodTextureMid: BaseTexture;
  62755. /** @hidden */
  62756. _lodTextureLow: BaseTexture;
  62757. /** @hidden */
  62758. _isRGBD: boolean;
  62759. /** @hidden */
  62760. _webGLTexture: Nullable<WebGLTexture>;
  62761. /** @hidden */
  62762. _references: number;
  62763. private _engine;
  62764. /**
  62765. * Gets the Engine the texture belongs to.
  62766. * @returns The babylon engine
  62767. */
  62768. getEngine(): Engine;
  62769. /**
  62770. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62771. */
  62772. readonly dataSource: number;
  62773. /**
  62774. * Creates a new InternalTexture
  62775. * @param engine defines the engine to use
  62776. * @param dataSource defines the type of data that will be used
  62777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62778. */
  62779. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62780. /**
  62781. * Increments the number of references (ie. the number of Texture that point to it)
  62782. */
  62783. incrementReferences(): void;
  62784. /**
  62785. * Change the size of the texture (not the size of the content)
  62786. * @param width defines the new width
  62787. * @param height defines the new height
  62788. * @param depth defines the new depth (1 by default)
  62789. */
  62790. updateSize(width: int, height: int, depth?: int): void;
  62791. /** @hidden */
  62792. _rebuild(): void;
  62793. /** @hidden */
  62794. _swapAndDie(target: InternalTexture): void;
  62795. /**
  62796. * Dispose the current allocated resources
  62797. */
  62798. dispose(): void;
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /**
  62803. * This represents the main contract an easing function should follow.
  62804. * Easing functions are used throughout the animation system.
  62805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62806. */
  62807. export interface IEasingFunction {
  62808. /**
  62809. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62810. * of the easing function.
  62811. * The link below provides some of the most common examples of easing functions.
  62812. * @see https://easings.net/
  62813. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62814. * @returns the corresponding value on the curve defined by the easing function
  62815. */
  62816. ease(gradient: number): number;
  62817. }
  62818. /**
  62819. * Base class used for every default easing function.
  62820. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62821. */
  62822. export class EasingFunction implements IEasingFunction {
  62823. /**
  62824. * Interpolation follows the mathematical formula associated with the easing function.
  62825. */
  62826. static readonly EASINGMODE_EASEIN: number;
  62827. /**
  62828. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62829. */
  62830. static readonly EASINGMODE_EASEOUT: number;
  62831. /**
  62832. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62833. */
  62834. static readonly EASINGMODE_EASEINOUT: number;
  62835. private _easingMode;
  62836. /**
  62837. * Sets the easing mode of the current function.
  62838. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62839. */
  62840. setEasingMode(easingMode: number): void;
  62841. /**
  62842. * Gets the current easing mode.
  62843. * @returns the easing mode
  62844. */
  62845. getEasingMode(): number;
  62846. /**
  62847. * @hidden
  62848. */
  62849. easeInCore(gradient: number): number;
  62850. /**
  62851. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62852. * of the easing function.
  62853. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62854. * @returns the corresponding value on the curve defined by the easing function
  62855. */
  62856. ease(gradient: number): number;
  62857. }
  62858. /**
  62859. * Easing function with a circle shape (see link below).
  62860. * @see https://easings.net/#easeInCirc
  62861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62862. */
  62863. export class CircleEase extends EasingFunction implements IEasingFunction {
  62864. /** @hidden */
  62865. easeInCore(gradient: number): number;
  62866. }
  62867. /**
  62868. * Easing function with a ease back shape (see link below).
  62869. * @see https://easings.net/#easeInBack
  62870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62871. */
  62872. export class BackEase extends EasingFunction implements IEasingFunction {
  62873. /** Defines the amplitude of the function */
  62874. amplitude: number;
  62875. /**
  62876. * Instantiates a back ease easing
  62877. * @see https://easings.net/#easeInBack
  62878. * @param amplitude Defines the amplitude of the function
  62879. */
  62880. constructor(
  62881. /** Defines the amplitude of the function */
  62882. amplitude?: number);
  62883. /** @hidden */
  62884. easeInCore(gradient: number): number;
  62885. }
  62886. /**
  62887. * Easing function with a bouncing shape (see link below).
  62888. * @see https://easings.net/#easeInBounce
  62889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62890. */
  62891. export class BounceEase extends EasingFunction implements IEasingFunction {
  62892. /** Defines the number of bounces */
  62893. bounces: number;
  62894. /** Defines the amplitude of the bounce */
  62895. bounciness: number;
  62896. /**
  62897. * Instantiates a bounce easing
  62898. * @see https://easings.net/#easeInBounce
  62899. * @param bounces Defines the number of bounces
  62900. * @param bounciness Defines the amplitude of the bounce
  62901. */
  62902. constructor(
  62903. /** Defines the number of bounces */
  62904. bounces?: number,
  62905. /** Defines the amplitude of the bounce */
  62906. bounciness?: number);
  62907. /** @hidden */
  62908. easeInCore(gradient: number): number;
  62909. }
  62910. /**
  62911. * Easing function with a power of 3 shape (see link below).
  62912. * @see https://easings.net/#easeInCubic
  62913. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62914. */
  62915. export class CubicEase extends EasingFunction implements IEasingFunction {
  62916. /** @hidden */
  62917. easeInCore(gradient: number): number;
  62918. }
  62919. /**
  62920. * Easing function with an elastic shape (see link below).
  62921. * @see https://easings.net/#easeInElastic
  62922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62923. */
  62924. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62925. /** Defines the number of oscillations*/
  62926. oscillations: number;
  62927. /** Defines the amplitude of the oscillations*/
  62928. springiness: number;
  62929. /**
  62930. * Instantiates an elastic easing function
  62931. * @see https://easings.net/#easeInElastic
  62932. * @param oscillations Defines the number of oscillations
  62933. * @param springiness Defines the amplitude of the oscillations
  62934. */
  62935. constructor(
  62936. /** Defines the number of oscillations*/
  62937. oscillations?: number,
  62938. /** Defines the amplitude of the oscillations*/
  62939. springiness?: number);
  62940. /** @hidden */
  62941. easeInCore(gradient: number): number;
  62942. }
  62943. /**
  62944. * Easing function with an exponential shape (see link below).
  62945. * @see https://easings.net/#easeInExpo
  62946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62947. */
  62948. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62949. /** Defines the exponent of the function */
  62950. exponent: number;
  62951. /**
  62952. * Instantiates an exponential easing function
  62953. * @see https://easings.net/#easeInExpo
  62954. * @param exponent Defines the exponent of the function
  62955. */
  62956. constructor(
  62957. /** Defines the exponent of the function */
  62958. exponent?: number);
  62959. /** @hidden */
  62960. easeInCore(gradient: number): number;
  62961. }
  62962. /**
  62963. * Easing function with a power shape (see link below).
  62964. * @see https://easings.net/#easeInQuad
  62965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62966. */
  62967. export class PowerEase extends EasingFunction implements IEasingFunction {
  62968. /** Defines the power of the function */
  62969. power: number;
  62970. /**
  62971. * Instantiates an power base easing function
  62972. * @see https://easings.net/#easeInQuad
  62973. * @param power Defines the power of the function
  62974. */
  62975. constructor(
  62976. /** Defines the power of the function */
  62977. power?: number);
  62978. /** @hidden */
  62979. easeInCore(gradient: number): number;
  62980. }
  62981. /**
  62982. * Easing function with a power of 2 shape (see link below).
  62983. * @see https://easings.net/#easeInQuad
  62984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62985. */
  62986. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  62987. /** @hidden */
  62988. easeInCore(gradient: number): number;
  62989. }
  62990. /**
  62991. * Easing function with a power of 4 shape (see link below).
  62992. * @see https://easings.net/#easeInQuart
  62993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62994. */
  62995. export class QuarticEase extends EasingFunction implements IEasingFunction {
  62996. /** @hidden */
  62997. easeInCore(gradient: number): number;
  62998. }
  62999. /**
  63000. * Easing function with a power of 5 shape (see link below).
  63001. * @see https://easings.net/#easeInQuint
  63002. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63003. */
  63004. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63005. /** @hidden */
  63006. easeInCore(gradient: number): number;
  63007. }
  63008. /**
  63009. * Easing function with a sin shape (see link below).
  63010. * @see https://easings.net/#easeInSine
  63011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63012. */
  63013. export class SineEase extends EasingFunction implements IEasingFunction {
  63014. /** @hidden */
  63015. easeInCore(gradient: number): number;
  63016. }
  63017. /**
  63018. * Easing function with a bezier shape (see link below).
  63019. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63021. */
  63022. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63023. /** Defines the x component of the start tangent in the bezier curve */
  63024. x1: number;
  63025. /** Defines the y component of the start tangent in the bezier curve */
  63026. y1: number;
  63027. /** Defines the x component of the end tangent in the bezier curve */
  63028. x2: number;
  63029. /** Defines the y component of the end tangent in the bezier curve */
  63030. y2: number;
  63031. /**
  63032. * Instantiates a bezier function
  63033. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63034. * @param x1 Defines the x component of the start tangent in the bezier curve
  63035. * @param y1 Defines the y component of the start tangent in the bezier curve
  63036. * @param x2 Defines the x component of the end tangent in the bezier curve
  63037. * @param y2 Defines the y component of the end tangent in the bezier curve
  63038. */
  63039. constructor(
  63040. /** Defines the x component of the start tangent in the bezier curve */
  63041. x1?: number,
  63042. /** Defines the y component of the start tangent in the bezier curve */
  63043. y1?: number,
  63044. /** Defines the x component of the end tangent in the bezier curve */
  63045. x2?: number,
  63046. /** Defines the y component of the end tangent in the bezier curve */
  63047. y2?: number);
  63048. /** @hidden */
  63049. easeInCore(gradient: number): number;
  63050. }
  63051. }
  63052. declare module BABYLON {
  63053. /**
  63054. * Defines an interface which represents an animation key frame
  63055. */
  63056. export interface IAnimationKey {
  63057. /**
  63058. * Frame of the key frame
  63059. */
  63060. frame: number;
  63061. /**
  63062. * Value at the specifies key frame
  63063. */
  63064. value: any;
  63065. /**
  63066. * The input tangent for the cubic hermite spline
  63067. */
  63068. inTangent?: any;
  63069. /**
  63070. * The output tangent for the cubic hermite spline
  63071. */
  63072. outTangent?: any;
  63073. /**
  63074. * The animation interpolation type
  63075. */
  63076. interpolation?: AnimationKeyInterpolation;
  63077. }
  63078. /**
  63079. * Enum for the animation key frame interpolation type
  63080. */
  63081. export enum AnimationKeyInterpolation {
  63082. /**
  63083. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63084. */
  63085. STEP = 1
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Represents the range of an animation
  63091. */
  63092. export class AnimationRange {
  63093. /**The name of the animation range**/
  63094. name: string;
  63095. /**The starting frame of the animation */
  63096. from: number;
  63097. /**The ending frame of the animation*/
  63098. to: number;
  63099. /**
  63100. * Initializes the range of an animation
  63101. * @param name The name of the animation range
  63102. * @param from The starting frame of the animation
  63103. * @param to The ending frame of the animation
  63104. */
  63105. constructor(
  63106. /**The name of the animation range**/
  63107. name: string,
  63108. /**The starting frame of the animation */
  63109. from: number,
  63110. /**The ending frame of the animation*/
  63111. to: number);
  63112. /**
  63113. * Makes a copy of the animation range
  63114. * @returns A copy of the animation range
  63115. */
  63116. clone(): AnimationRange;
  63117. }
  63118. }
  63119. declare module BABYLON {
  63120. /**
  63121. * Composed of a frame, and an action function
  63122. */
  63123. export class AnimationEvent {
  63124. /** The frame for which the event is triggered **/
  63125. frame: number;
  63126. /** The event to perform when triggered **/
  63127. action: (currentFrame: number) => void;
  63128. /** Specifies if the event should be triggered only once**/
  63129. onlyOnce?: boolean | undefined;
  63130. /**
  63131. * Specifies if the animation event is done
  63132. */
  63133. isDone: boolean;
  63134. /**
  63135. * Initializes the animation event
  63136. * @param frame The frame for which the event is triggered
  63137. * @param action The event to perform when triggered
  63138. * @param onlyOnce Specifies if the event should be triggered only once
  63139. */
  63140. constructor(
  63141. /** The frame for which the event is triggered **/
  63142. frame: number,
  63143. /** The event to perform when triggered **/
  63144. action: (currentFrame: number) => void,
  63145. /** Specifies if the event should be triggered only once**/
  63146. onlyOnce?: boolean | undefined);
  63147. /** @hidden */
  63148. _clone(): AnimationEvent;
  63149. }
  63150. }
  63151. declare module BABYLON {
  63152. /**
  63153. * Interface used to define a behavior
  63154. */
  63155. export interface Behavior<T> {
  63156. /** gets or sets behavior's name */
  63157. name: string;
  63158. /**
  63159. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63160. */
  63161. init(): void;
  63162. /**
  63163. * Called when the behavior is attached to a target
  63164. * @param target defines the target where the behavior is attached to
  63165. */
  63166. attach(target: T): void;
  63167. /**
  63168. * Called when the behavior is detached from its target
  63169. */
  63170. detach(): void;
  63171. }
  63172. /**
  63173. * Interface implemented by classes supporting behaviors
  63174. */
  63175. export interface IBehaviorAware<T> {
  63176. /**
  63177. * Attach a behavior
  63178. * @param behavior defines the behavior to attach
  63179. * @returns the current host
  63180. */
  63181. addBehavior(behavior: Behavior<T>): T;
  63182. /**
  63183. * Remove a behavior from the current object
  63184. * @param behavior defines the behavior to detach
  63185. * @returns the current host
  63186. */
  63187. removeBehavior(behavior: Behavior<T>): T;
  63188. /**
  63189. * Gets a behavior using its name to search
  63190. * @param name defines the name to search
  63191. * @returns the behavior or null if not found
  63192. */
  63193. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Defines a runtime animation
  63199. */
  63200. export class RuntimeAnimation {
  63201. private _events;
  63202. /**
  63203. * The current frame of the runtime animation
  63204. */
  63205. private _currentFrame;
  63206. /**
  63207. * The animation used by the runtime animation
  63208. */
  63209. private _animation;
  63210. /**
  63211. * The target of the runtime animation
  63212. */
  63213. private _target;
  63214. /**
  63215. * The initiating animatable
  63216. */
  63217. private _host;
  63218. /**
  63219. * The original value of the runtime animation
  63220. */
  63221. private _originalValue;
  63222. /**
  63223. * The original blend value of the runtime animation
  63224. */
  63225. private _originalBlendValue;
  63226. /**
  63227. * The offsets cache of the runtime animation
  63228. */
  63229. private _offsetsCache;
  63230. /**
  63231. * The high limits cache of the runtime animation
  63232. */
  63233. private _highLimitsCache;
  63234. /**
  63235. * Specifies if the runtime animation has been stopped
  63236. */
  63237. private _stopped;
  63238. /**
  63239. * The blending factor of the runtime animation
  63240. */
  63241. private _blendingFactor;
  63242. /**
  63243. * The BabylonJS scene
  63244. */
  63245. private _scene;
  63246. /**
  63247. * The current value of the runtime animation
  63248. */
  63249. private _currentValue;
  63250. /** @hidden */
  63251. _workValue: any;
  63252. /**
  63253. * The active target of the runtime animation
  63254. */
  63255. private _activeTarget;
  63256. /**
  63257. * The target path of the runtime animation
  63258. */
  63259. private _targetPath;
  63260. /**
  63261. * The weight of the runtime animation
  63262. */
  63263. private _weight;
  63264. /**
  63265. * The ratio offset of the runtime animation
  63266. */
  63267. private _ratioOffset;
  63268. /**
  63269. * The previous delay of the runtime animation
  63270. */
  63271. private _previousDelay;
  63272. /**
  63273. * The previous ratio of the runtime animation
  63274. */
  63275. private _previousRatio;
  63276. /**
  63277. * Gets the current frame of the runtime animation
  63278. */
  63279. readonly currentFrame: number;
  63280. /**
  63281. * Gets the weight of the runtime animation
  63282. */
  63283. readonly weight: number;
  63284. /**
  63285. * Gets the current value of the runtime animation
  63286. */
  63287. readonly currentValue: any;
  63288. /**
  63289. * Gets the target path of the runtime animation
  63290. */
  63291. readonly targetPath: string;
  63292. /**
  63293. * Gets the actual target of the runtime animation
  63294. */
  63295. readonly target: any;
  63296. /**
  63297. * Create a new RuntimeAnimation object
  63298. * @param target defines the target of the animation
  63299. * @param animation defines the source animation object
  63300. * @param scene defines the hosting scene
  63301. * @param host defines the initiating Animatable
  63302. */
  63303. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63304. /**
  63305. * Gets the animation from the runtime animation
  63306. */
  63307. readonly animation: Animation;
  63308. /**
  63309. * Resets the runtime animation to the beginning
  63310. * @param restoreOriginal defines whether to restore the target property to the original value
  63311. */
  63312. reset(restoreOriginal?: boolean): void;
  63313. /**
  63314. * Specifies if the runtime animation is stopped
  63315. * @returns Boolean specifying if the runtime animation is stopped
  63316. */
  63317. isStopped(): boolean;
  63318. /**
  63319. * Disposes of the runtime animation
  63320. */
  63321. dispose(): void;
  63322. /**
  63323. * Interpolates the animation from the current frame
  63324. * @param currentFrame The frame to interpolate the animation to
  63325. * @param repeatCount The number of times that the animation should loop
  63326. * @param loopMode The type of looping mode to use
  63327. * @param offsetValue Animation offset value
  63328. * @param highLimitValue The high limit value
  63329. * @returns The interpolated value
  63330. */
  63331. private _interpolate;
  63332. /**
  63333. * Apply the interpolated value to the target
  63334. * @param currentValue defines the value computed by the animation
  63335. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63336. */
  63337. setValue(currentValue: any, weight?: number): void;
  63338. private _setValue;
  63339. /**
  63340. * Gets the loop pmode of the runtime animation
  63341. * @returns Loop Mode
  63342. */
  63343. private _getCorrectLoopMode;
  63344. /**
  63345. * Move the current animation to a given frame
  63346. * @param frame defines the frame to move to
  63347. */
  63348. goToFrame(frame: number): void;
  63349. /**
  63350. * @hidden Internal use only
  63351. */
  63352. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63353. /**
  63354. * Execute the current animation
  63355. * @param delay defines the delay to add to the current frame
  63356. * @param from defines the lower bound of the animation range
  63357. * @param to defines the upper bound of the animation range
  63358. * @param loop defines if the current animation must loop
  63359. * @param speedRatio defines the current speed ratio
  63360. * @param weight defines the weight of the animation (default is -1 so no weight)
  63361. * @param onLoop optional callback called when animation loops
  63362. * @returns a boolean indicating if the animation is running
  63363. */
  63364. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63365. }
  63366. }
  63367. declare module BABYLON {
  63368. /**
  63369. * @hidden
  63370. */
  63371. export class IntersectionInfo {
  63372. bu: Nullable<number>;
  63373. bv: Nullable<number>;
  63374. distance: number;
  63375. faceId: number;
  63376. subMeshId: number;
  63377. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63378. }
  63379. }
  63380. declare module BABYLON {
  63381. /**
  63382. * Class used to store bounding sphere information
  63383. */
  63384. export class BoundingSphere {
  63385. /**
  63386. * Gets the center of the bounding sphere in local space
  63387. */
  63388. readonly center: Vector3;
  63389. /**
  63390. * Radius of the bounding sphere in local space
  63391. */
  63392. radius: number;
  63393. /**
  63394. * Gets the center of the bounding sphere in world space
  63395. */
  63396. readonly centerWorld: Vector3;
  63397. /**
  63398. * Radius of the bounding sphere in world space
  63399. */
  63400. radiusWorld: number;
  63401. /**
  63402. * Gets the minimum vector in local space
  63403. */
  63404. readonly minimum: Vector3;
  63405. /**
  63406. * Gets the maximum vector in local space
  63407. */
  63408. readonly maximum: Vector3;
  63409. private _worldMatrix;
  63410. private static readonly TmpVector3;
  63411. /**
  63412. * Creates a new bounding sphere
  63413. * @param min defines the minimum vector (in local space)
  63414. * @param max defines the maximum vector (in local space)
  63415. * @param worldMatrix defines the new world matrix
  63416. */
  63417. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63418. /**
  63419. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63420. * @param min defines the new minimum vector (in local space)
  63421. * @param max defines the new maximum vector (in local space)
  63422. * @param worldMatrix defines the new world matrix
  63423. */
  63424. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63425. /**
  63426. * Scale the current bounding sphere by applying a scale factor
  63427. * @param factor defines the scale factor to apply
  63428. * @returns the current bounding box
  63429. */
  63430. scale(factor: number): BoundingSphere;
  63431. /**
  63432. * Gets the world matrix of the bounding box
  63433. * @returns a matrix
  63434. */
  63435. getWorldMatrix(): DeepImmutable<Matrix>;
  63436. /** @hidden */
  63437. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63438. /**
  63439. * Tests if the bounding sphere is intersecting the frustum planes
  63440. * @param frustumPlanes defines the frustum planes to test
  63441. * @returns true if there is an intersection
  63442. */
  63443. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63444. /**
  63445. * Tests if the bounding sphere center is in between the frustum planes.
  63446. * Used for optimistic fast inclusion.
  63447. * @param frustumPlanes defines the frustum planes to test
  63448. * @returns true if the sphere center is in between the frustum planes
  63449. */
  63450. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63451. /**
  63452. * Tests if a point is inside the bounding sphere
  63453. * @param point defines the point to test
  63454. * @returns true if the point is inside the bounding sphere
  63455. */
  63456. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63457. /**
  63458. * Checks if two sphere intersct
  63459. * @param sphere0 sphere 0
  63460. * @param sphere1 sphere 1
  63461. * @returns true if the speres intersect
  63462. */
  63463. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63464. }
  63465. }
  63466. declare module BABYLON {
  63467. /**
  63468. * Class used to store bounding box information
  63469. */
  63470. export class BoundingBox implements ICullable {
  63471. /**
  63472. * Gets the 8 vectors representing the bounding box in local space
  63473. */
  63474. readonly vectors: Vector3[];
  63475. /**
  63476. * Gets the center of the bounding box in local space
  63477. */
  63478. readonly center: Vector3;
  63479. /**
  63480. * Gets the center of the bounding box in world space
  63481. */
  63482. readonly centerWorld: Vector3;
  63483. /**
  63484. * Gets the extend size in local space
  63485. */
  63486. readonly extendSize: Vector3;
  63487. /**
  63488. * Gets the extend size in world space
  63489. */
  63490. readonly extendSizeWorld: Vector3;
  63491. /**
  63492. * Gets the OBB (object bounding box) directions
  63493. */
  63494. readonly directions: Vector3[];
  63495. /**
  63496. * Gets the 8 vectors representing the bounding box in world space
  63497. */
  63498. readonly vectorsWorld: Vector3[];
  63499. /**
  63500. * Gets the minimum vector in world space
  63501. */
  63502. readonly minimumWorld: Vector3;
  63503. /**
  63504. * Gets the maximum vector in world space
  63505. */
  63506. readonly maximumWorld: Vector3;
  63507. /**
  63508. * Gets the minimum vector in local space
  63509. */
  63510. readonly minimum: Vector3;
  63511. /**
  63512. * Gets the maximum vector in local space
  63513. */
  63514. readonly maximum: Vector3;
  63515. private _worldMatrix;
  63516. private static readonly TmpVector3;
  63517. /**
  63518. * @hidden
  63519. */
  63520. _tag: number;
  63521. /**
  63522. * Creates a new bounding box
  63523. * @param min defines the minimum vector (in local space)
  63524. * @param max defines the maximum vector (in local space)
  63525. * @param worldMatrix defines the new world matrix
  63526. */
  63527. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63528. /**
  63529. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63530. * @param min defines the new minimum vector (in local space)
  63531. * @param max defines the new maximum vector (in local space)
  63532. * @param worldMatrix defines the new world matrix
  63533. */
  63534. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63535. /**
  63536. * Scale the current bounding box by applying a scale factor
  63537. * @param factor defines the scale factor to apply
  63538. * @returns the current bounding box
  63539. */
  63540. scale(factor: number): BoundingBox;
  63541. /**
  63542. * Gets the world matrix of the bounding box
  63543. * @returns a matrix
  63544. */
  63545. getWorldMatrix(): DeepImmutable<Matrix>;
  63546. /** @hidden */
  63547. _update(world: DeepImmutable<Matrix>): void;
  63548. /**
  63549. * Tests if the bounding box is intersecting the frustum planes
  63550. * @param frustumPlanes defines the frustum planes to test
  63551. * @returns true if there is an intersection
  63552. */
  63553. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63554. /**
  63555. * Tests if the bounding box is entirely inside the frustum planes
  63556. * @param frustumPlanes defines the frustum planes to test
  63557. * @returns true if there is an inclusion
  63558. */
  63559. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63560. /**
  63561. * Tests if a point is inside the bounding box
  63562. * @param point defines the point to test
  63563. * @returns true if the point is inside the bounding box
  63564. */
  63565. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63566. /**
  63567. * Tests if the bounding box intersects with a bounding sphere
  63568. * @param sphere defines the sphere to test
  63569. * @returns true if there is an intersection
  63570. */
  63571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63572. /**
  63573. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63574. * @param min defines the min vector to use
  63575. * @param max defines the max vector to use
  63576. * @returns true if there is an intersection
  63577. */
  63578. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63579. /**
  63580. * Tests if two bounding boxes are intersections
  63581. * @param box0 defines the first box to test
  63582. * @param box1 defines the second box to test
  63583. * @returns true if there is an intersection
  63584. */
  63585. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63586. /**
  63587. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63588. * @param minPoint defines the minimum vector of the bounding box
  63589. * @param maxPoint defines the maximum vector of the bounding box
  63590. * @param sphereCenter defines the sphere center
  63591. * @param sphereRadius defines the sphere radius
  63592. * @returns true if there is an intersection
  63593. */
  63594. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63595. /**
  63596. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63597. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63598. * @param frustumPlanes defines the frustum planes to test
  63599. * @return true if there is an inclusion
  63600. */
  63601. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63602. /**
  63603. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63604. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63605. * @param frustumPlanes defines the frustum planes to test
  63606. * @return true if there is an intersection
  63607. */
  63608. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63609. }
  63610. }
  63611. declare module BABYLON {
  63612. /** @hidden */
  63613. export class Collider {
  63614. /** Define if a collision was found */
  63615. collisionFound: boolean;
  63616. /**
  63617. * Define last intersection point in local space
  63618. */
  63619. intersectionPoint: Vector3;
  63620. /**
  63621. * Define last collided mesh
  63622. */
  63623. collidedMesh: Nullable<AbstractMesh>;
  63624. private _collisionPoint;
  63625. private _planeIntersectionPoint;
  63626. private _tempVector;
  63627. private _tempVector2;
  63628. private _tempVector3;
  63629. private _tempVector4;
  63630. private _edge;
  63631. private _baseToVertex;
  63632. private _destinationPoint;
  63633. private _slidePlaneNormal;
  63634. private _displacementVector;
  63635. /** @hidden */
  63636. _radius: Vector3;
  63637. /** @hidden */
  63638. _retry: number;
  63639. private _velocity;
  63640. private _basePoint;
  63641. private _epsilon;
  63642. /** @hidden */
  63643. _velocityWorldLength: number;
  63644. /** @hidden */
  63645. _basePointWorld: Vector3;
  63646. private _velocityWorld;
  63647. private _normalizedVelocity;
  63648. /** @hidden */
  63649. _initialVelocity: Vector3;
  63650. /** @hidden */
  63651. _initialPosition: Vector3;
  63652. private _nearestDistance;
  63653. private _collisionMask;
  63654. collisionMask: number;
  63655. /**
  63656. * Gets the plane normal used to compute the sliding response (in local space)
  63657. */
  63658. readonly slidePlaneNormal: Vector3;
  63659. /** @hidden */
  63660. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63661. /** @hidden */
  63662. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63663. /** @hidden */
  63664. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63665. /** @hidden */
  63666. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63667. /** @hidden */
  63668. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63669. /** @hidden */
  63670. _getResponse(pos: Vector3, vel: Vector3): void;
  63671. }
  63672. }
  63673. declare module BABYLON {
  63674. /**
  63675. * Interface for cullable objects
  63676. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63677. */
  63678. export interface ICullable {
  63679. /**
  63680. * Checks if the object or part of the object is in the frustum
  63681. * @param frustumPlanes Camera near/planes
  63682. * @returns true if the object is in frustum otherwise false
  63683. */
  63684. isInFrustum(frustumPlanes: Plane[]): boolean;
  63685. /**
  63686. * Checks if a cullable object (mesh...) is in the camera frustum
  63687. * Unlike isInFrustum this cheks the full bounding box
  63688. * @param frustumPlanes Camera near/planes
  63689. * @returns true if the object is in frustum otherwise false
  63690. */
  63691. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63692. }
  63693. /**
  63694. * Info for a bounding data of a mesh
  63695. */
  63696. export class BoundingInfo implements ICullable {
  63697. /**
  63698. * Bounding box for the mesh
  63699. */
  63700. readonly boundingBox: BoundingBox;
  63701. /**
  63702. * Bounding sphere for the mesh
  63703. */
  63704. readonly boundingSphere: BoundingSphere;
  63705. private _isLocked;
  63706. private static readonly TmpVector3;
  63707. /**
  63708. * Constructs bounding info
  63709. * @param minimum min vector of the bounding box/sphere
  63710. * @param maximum max vector of the bounding box/sphere
  63711. * @param worldMatrix defines the new world matrix
  63712. */
  63713. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63714. /**
  63715. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63716. * @param min defines the new minimum vector (in local space)
  63717. * @param max defines the new maximum vector (in local space)
  63718. * @param worldMatrix defines the new world matrix
  63719. */
  63720. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63721. /**
  63722. * min vector of the bounding box/sphere
  63723. */
  63724. readonly minimum: Vector3;
  63725. /**
  63726. * max vector of the bounding box/sphere
  63727. */
  63728. readonly maximum: Vector3;
  63729. /**
  63730. * If the info is locked and won't be updated to avoid perf overhead
  63731. */
  63732. isLocked: boolean;
  63733. /**
  63734. * Updates the bounding sphere and box
  63735. * @param world world matrix to be used to update
  63736. */
  63737. update(world: DeepImmutable<Matrix>): void;
  63738. /**
  63739. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63740. * @param center New center of the bounding info
  63741. * @param extend New extend of the bounding info
  63742. * @returns the current bounding info
  63743. */
  63744. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63745. /**
  63746. * Scale the current bounding info by applying a scale factor
  63747. * @param factor defines the scale factor to apply
  63748. * @returns the current bounding info
  63749. */
  63750. scale(factor: number): BoundingInfo;
  63751. /**
  63752. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63753. * @param frustumPlanes defines the frustum to test
  63754. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63755. * @returns true if the bounding info is in the frustum planes
  63756. */
  63757. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63758. /**
  63759. * Gets the world distance between the min and max points of the bounding box
  63760. */
  63761. readonly diagonalLength: number;
  63762. /**
  63763. * Checks if a cullable object (mesh...) is in the camera frustum
  63764. * Unlike isInFrustum this cheks the full bounding box
  63765. * @param frustumPlanes Camera near/planes
  63766. * @returns true if the object is in frustum otherwise false
  63767. */
  63768. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63769. /** @hidden */
  63770. _checkCollision(collider: Collider): boolean;
  63771. /**
  63772. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63773. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63774. * @param point the point to check intersection with
  63775. * @returns if the point intersects
  63776. */
  63777. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63778. /**
  63779. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63780. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63781. * @param boundingInfo the bounding info to check intersection with
  63782. * @param precise if the intersection should be done using OBB
  63783. * @returns if the bounding info intersects
  63784. */
  63785. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63786. }
  63787. }
  63788. declare module BABYLON {
  63789. /**
  63790. * Defines an array and its length.
  63791. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63792. */
  63793. export interface ISmartArrayLike<T> {
  63794. /**
  63795. * The data of the array.
  63796. */
  63797. data: Array<T>;
  63798. /**
  63799. * The active length of the array.
  63800. */
  63801. length: number;
  63802. }
  63803. /**
  63804. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63805. */
  63806. export class SmartArray<T> implements ISmartArrayLike<T> {
  63807. /**
  63808. * The full set of data from the array.
  63809. */
  63810. data: Array<T>;
  63811. /**
  63812. * The active length of the array.
  63813. */
  63814. length: number;
  63815. protected _id: number;
  63816. /**
  63817. * Instantiates a Smart Array.
  63818. * @param capacity defines the default capacity of the array.
  63819. */
  63820. constructor(capacity: number);
  63821. /**
  63822. * Pushes a value at the end of the active data.
  63823. * @param value defines the object to push in the array.
  63824. */
  63825. push(value: T): void;
  63826. /**
  63827. * Iterates over the active data and apply the lambda to them.
  63828. * @param func defines the action to apply on each value.
  63829. */
  63830. forEach(func: (content: T) => void): void;
  63831. /**
  63832. * Sorts the full sets of data.
  63833. * @param compareFn defines the comparison function to apply.
  63834. */
  63835. sort(compareFn: (a: T, b: T) => number): void;
  63836. /**
  63837. * Resets the active data to an empty array.
  63838. */
  63839. reset(): void;
  63840. /**
  63841. * Releases all the data from the array as well as the array.
  63842. */
  63843. dispose(): void;
  63844. /**
  63845. * Concats the active data with a given array.
  63846. * @param array defines the data to concatenate with.
  63847. */
  63848. concat(array: any): void;
  63849. /**
  63850. * Returns the position of a value in the active data.
  63851. * @param value defines the value to find the index for
  63852. * @returns the index if found in the active data otherwise -1
  63853. */
  63854. indexOf(value: T): number;
  63855. /**
  63856. * Returns whether an element is part of the active data.
  63857. * @param value defines the value to look for
  63858. * @returns true if found in the active data otherwise false
  63859. */
  63860. contains(value: T): boolean;
  63861. private static _GlobalId;
  63862. }
  63863. /**
  63864. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63865. * The data in this array can only be present once
  63866. */
  63867. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63868. private _duplicateId;
  63869. /**
  63870. * Pushes a value at the end of the active data.
  63871. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63872. * @param value defines the object to push in the array.
  63873. */
  63874. push(value: T): void;
  63875. /**
  63876. * Pushes a value at the end of the active data.
  63877. * If the data is already present, it won t be added again
  63878. * @param value defines the object to push in the array.
  63879. * @returns true if added false if it was already present
  63880. */
  63881. pushNoDuplicate(value: T): boolean;
  63882. /**
  63883. * Resets the active data to an empty array.
  63884. */
  63885. reset(): void;
  63886. /**
  63887. * Concats the active data with a given array.
  63888. * This ensures no dupplicate will be present in the result.
  63889. * @param array defines the data to concatenate with.
  63890. */
  63891. concatWithNoDuplicate(array: any): void;
  63892. }
  63893. }
  63894. declare module BABYLON {
  63895. /**
  63896. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63897. * separate meshes. This can be use to improve performances.
  63898. * @see http://doc.babylonjs.com/how_to/multi_materials
  63899. */
  63900. export class MultiMaterial extends Material {
  63901. private _subMaterials;
  63902. /**
  63903. * Gets or Sets the list of Materials used within the multi material.
  63904. * They need to be ordered according to the submeshes order in the associated mesh
  63905. */
  63906. subMaterials: Nullable<Material>[];
  63907. /**
  63908. * Function used to align with Node.getChildren()
  63909. * @returns the list of Materials used within the multi material
  63910. */
  63911. getChildren(): Nullable<Material>[];
  63912. /**
  63913. * Instantiates a new Multi Material
  63914. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63915. * separate meshes. This can be use to improve performances.
  63916. * @see http://doc.babylonjs.com/how_to/multi_materials
  63917. * @param name Define the name in the scene
  63918. * @param scene Define the scene the material belongs to
  63919. */
  63920. constructor(name: string, scene: Scene);
  63921. private _hookArray;
  63922. /**
  63923. * Get one of the submaterial by its index in the submaterials array
  63924. * @param index The index to look the sub material at
  63925. * @returns The Material if the index has been defined
  63926. */
  63927. getSubMaterial(index: number): Nullable<Material>;
  63928. /**
  63929. * Get the list of active textures for the whole sub materials list.
  63930. * @returns All the textures that will be used during the rendering
  63931. */
  63932. getActiveTextures(): BaseTexture[];
  63933. /**
  63934. * Gets the current class name of the material e.g. "MultiMaterial"
  63935. * Mainly use in serialization.
  63936. * @returns the class name
  63937. */
  63938. getClassName(): string;
  63939. /**
  63940. * Checks if the material is ready to render the requested sub mesh
  63941. * @param mesh Define the mesh the submesh belongs to
  63942. * @param subMesh Define the sub mesh to look readyness for
  63943. * @param useInstances Define whether or not the material is used with instances
  63944. * @returns true if ready, otherwise false
  63945. */
  63946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  63947. /**
  63948. * Clones the current material and its related sub materials
  63949. * @param name Define the name of the newly cloned material
  63950. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  63951. * @returns the cloned material
  63952. */
  63953. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  63954. /**
  63955. * Serializes the materials into a JSON representation.
  63956. * @returns the JSON representation
  63957. */
  63958. serialize(): any;
  63959. /**
  63960. * Dispose the material and release its associated resources
  63961. * @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)
  63962. * @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)
  63963. * @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)
  63964. */
  63965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  63966. /**
  63967. * Creates a MultiMaterial from parsed MultiMaterial data.
  63968. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  63969. * @param scene defines the hosting scene
  63970. * @returns a new MultiMaterial
  63971. */
  63972. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. /**
  63977. * Class used to represent data loading progression
  63978. */
  63979. export class SceneLoaderFlags {
  63980. private static _ForceFullSceneLoadingForIncremental;
  63981. private static _ShowLoadingScreen;
  63982. private static _CleanBoneMatrixWeights;
  63983. private static _loggingLevel;
  63984. /**
  63985. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  63986. */
  63987. static ForceFullSceneLoadingForIncremental: boolean;
  63988. /**
  63989. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  63990. */
  63991. static ShowLoadingScreen: boolean;
  63992. /**
  63993. * Defines the current logging level (while loading the scene)
  63994. * @ignorenaming
  63995. */
  63996. static loggingLevel: number;
  63997. /**
  63998. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  63999. */
  64000. static CleanBoneMatrixWeights: boolean;
  64001. }
  64002. }
  64003. declare module BABYLON {
  64004. /**
  64005. * Class used to override all child animations of a given target
  64006. */
  64007. export class AnimationPropertiesOverride {
  64008. /**
  64009. * Gets or sets a value indicating if animation blending must be used
  64010. */
  64011. enableBlending: boolean;
  64012. /**
  64013. * Gets or sets the blending speed to use when enableBlending is true
  64014. */
  64015. blendingSpeed: number;
  64016. /**
  64017. * Gets or sets the default loop mode to use
  64018. */
  64019. loopMode: number;
  64020. }
  64021. }
  64022. declare module BABYLON {
  64023. /**
  64024. * Defines a target to use with MorphTargetManager
  64025. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64026. */
  64027. export class MorphTarget implements IAnimatable {
  64028. /** defines the name of the target */
  64029. name: string;
  64030. /**
  64031. * Gets or sets the list of animations
  64032. */
  64033. animations: Animation[];
  64034. private _scene;
  64035. private _positions;
  64036. private _normals;
  64037. private _tangents;
  64038. private _influence;
  64039. /**
  64040. * Observable raised when the influence changes
  64041. */
  64042. onInfluenceChanged: Observable<boolean>;
  64043. /** @hidden */
  64044. _onDataLayoutChanged: Observable<void>;
  64045. /**
  64046. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  64047. */
  64048. influence: number;
  64049. /**
  64050. * Gets or sets the id of the morph Target
  64051. */
  64052. id: string;
  64053. private _animationPropertiesOverride;
  64054. /**
  64055. * Gets or sets the animation properties override
  64056. */
  64057. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64058. /**
  64059. * Creates a new MorphTarget
  64060. * @param name defines the name of the target
  64061. * @param influence defines the influence to use
  64062. * @param scene defines the scene the morphtarget belongs to
  64063. */
  64064. constructor(
  64065. /** defines the name of the target */
  64066. name: string, influence?: number, scene?: Nullable<Scene>);
  64067. /**
  64068. * Gets a boolean defining if the target contains position data
  64069. */
  64070. readonly hasPositions: boolean;
  64071. /**
  64072. * Gets a boolean defining if the target contains normal data
  64073. */
  64074. readonly hasNormals: boolean;
  64075. /**
  64076. * Gets a boolean defining if the target contains tangent data
  64077. */
  64078. readonly hasTangents: boolean;
  64079. /**
  64080. * Affects position data to this target
  64081. * @param data defines the position data to use
  64082. */
  64083. setPositions(data: Nullable<FloatArray>): void;
  64084. /**
  64085. * Gets the position data stored in this target
  64086. * @returns a FloatArray containing the position data (or null if not present)
  64087. */
  64088. getPositions(): Nullable<FloatArray>;
  64089. /**
  64090. * Affects normal data to this target
  64091. * @param data defines the normal data to use
  64092. */
  64093. setNormals(data: Nullable<FloatArray>): void;
  64094. /**
  64095. * Gets the normal data stored in this target
  64096. * @returns a FloatArray containing the normal data (or null if not present)
  64097. */
  64098. getNormals(): Nullable<FloatArray>;
  64099. /**
  64100. * Affects tangent data to this target
  64101. * @param data defines the tangent data to use
  64102. */
  64103. setTangents(data: Nullable<FloatArray>): void;
  64104. /**
  64105. * Gets the tangent data stored in this target
  64106. * @returns a FloatArray containing the tangent data (or null if not present)
  64107. */
  64108. getTangents(): Nullable<FloatArray>;
  64109. /**
  64110. * Serializes the current target into a Serialization object
  64111. * @returns the serialized object
  64112. */
  64113. serialize(): any;
  64114. /**
  64115. * Returns the string "MorphTarget"
  64116. * @returns "MorphTarget"
  64117. */
  64118. getClassName(): string;
  64119. /**
  64120. * Creates a new target from serialized data
  64121. * @param serializationObject defines the serialized data to use
  64122. * @returns a new MorphTarget
  64123. */
  64124. static Parse(serializationObject: any): MorphTarget;
  64125. /**
  64126. * Creates a MorphTarget from mesh data
  64127. * @param mesh defines the source mesh
  64128. * @param name defines the name to use for the new target
  64129. * @param influence defines the influence to attach to the target
  64130. * @returns a new MorphTarget
  64131. */
  64132. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  64133. }
  64134. }
  64135. declare module BABYLON {
  64136. /**
  64137. * This class is used to deform meshes using morphing between different targets
  64138. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64139. */
  64140. export class MorphTargetManager {
  64141. private _targets;
  64142. private _targetInfluenceChangedObservers;
  64143. private _targetDataLayoutChangedObservers;
  64144. private _activeTargets;
  64145. private _scene;
  64146. private _influences;
  64147. private _supportsNormals;
  64148. private _supportsTangents;
  64149. private _vertexCount;
  64150. private _uniqueId;
  64151. private _tempInfluences;
  64152. /**
  64153. * Creates a new MorphTargetManager
  64154. * @param scene defines the current scene
  64155. */
  64156. constructor(scene?: Nullable<Scene>);
  64157. /**
  64158. * Gets the unique ID of this manager
  64159. */
  64160. readonly uniqueId: number;
  64161. /**
  64162. * Gets the number of vertices handled by this manager
  64163. */
  64164. readonly vertexCount: number;
  64165. /**
  64166. * Gets a boolean indicating if this manager supports morphing of normals
  64167. */
  64168. readonly supportsNormals: boolean;
  64169. /**
  64170. * Gets a boolean indicating if this manager supports morphing of tangents
  64171. */
  64172. readonly supportsTangents: boolean;
  64173. /**
  64174. * Gets the number of targets stored in this manager
  64175. */
  64176. readonly numTargets: number;
  64177. /**
  64178. * Gets the number of influencers (ie. the number of targets with influences > 0)
  64179. */
  64180. readonly numInfluencers: number;
  64181. /**
  64182. * Gets the list of influences (one per target)
  64183. */
  64184. readonly influences: Float32Array;
  64185. /**
  64186. * Gets the active target at specified index. An active target is a target with an influence > 0
  64187. * @param index defines the index to check
  64188. * @returns the requested target
  64189. */
  64190. getActiveTarget(index: number): MorphTarget;
  64191. /**
  64192. * Gets the target at specified index
  64193. * @param index defines the index to check
  64194. * @returns the requested target
  64195. */
  64196. getTarget(index: number): MorphTarget;
  64197. /**
  64198. * Add a new target to this manager
  64199. * @param target defines the target to add
  64200. */
  64201. addTarget(target: MorphTarget): void;
  64202. /**
  64203. * Removes a target from the manager
  64204. * @param target defines the target to remove
  64205. */
  64206. removeTarget(target: MorphTarget): void;
  64207. /**
  64208. * Serializes the current manager into a Serialization object
  64209. * @returns the serialized object
  64210. */
  64211. serialize(): any;
  64212. private _syncActiveTargets;
  64213. /**
  64214. * Syncrhonize the targets with all the meshes using this morph target manager
  64215. */
  64216. synchronize(): void;
  64217. /**
  64218. * Creates a new MorphTargetManager from serialized data
  64219. * @param serializationObject defines the serialized data
  64220. * @param scene defines the hosting scene
  64221. * @returns the new MorphTargetManager
  64222. */
  64223. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  64224. }
  64225. }
  64226. declare module BABYLON {
  64227. /**
  64228. * Creates an instance based on a source mesh.
  64229. */
  64230. export class InstancedMesh extends AbstractMesh {
  64231. private _sourceMesh;
  64232. private _currentLOD;
  64233. /** @hidden */
  64234. _indexInSourceMeshInstanceArray: number;
  64235. constructor(name: string, source: Mesh);
  64236. /**
  64237. * Returns the string "InstancedMesh".
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * If the source mesh receives shadows
  64242. */
  64243. readonly receiveShadows: boolean;
  64244. /**
  64245. * The material of the source mesh
  64246. */
  64247. readonly material: Nullable<Material>;
  64248. /**
  64249. * Visibility of the source mesh
  64250. */
  64251. readonly visibility: number;
  64252. /**
  64253. * Skeleton of the source mesh
  64254. */
  64255. readonly skeleton: Nullable<Skeleton>;
  64256. /**
  64257. * Rendering ground id of the source mesh
  64258. */
  64259. renderingGroupId: number;
  64260. /**
  64261. * Returns the total number of vertices (integer).
  64262. */
  64263. getTotalVertices(): number;
  64264. /**
  64265. * Returns a positive integer : the total number of indices in this mesh geometry.
  64266. * @returns the numner of indices or zero if the mesh has no geometry.
  64267. */
  64268. getTotalIndices(): number;
  64269. /**
  64270. * The source mesh of the instance
  64271. */
  64272. readonly sourceMesh: Mesh;
  64273. /**
  64274. * Is this node ready to be used/rendered
  64275. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  64276. * @return {boolean} is it ready
  64277. */
  64278. isReady(completeCheck?: boolean): boolean;
  64279. /**
  64280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  64281. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  64282. * @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.
  64283. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  64284. */
  64285. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  64286. /**
  64287. * Sets the vertex data of the mesh geometry for the requested `kind`.
  64288. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  64289. * The `data` are either a numeric array either a Float32Array.
  64290. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  64291. * 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).
  64292. * Note that a new underlying VertexBuffer object is created each call.
  64293. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  64294. *
  64295. * Possible `kind` values :
  64296. * - VertexBuffer.PositionKind
  64297. * - VertexBuffer.UVKind
  64298. * - VertexBuffer.UV2Kind
  64299. * - VertexBuffer.UV3Kind
  64300. * - VertexBuffer.UV4Kind
  64301. * - VertexBuffer.UV5Kind
  64302. * - VertexBuffer.UV6Kind
  64303. * - VertexBuffer.ColorKind
  64304. * - VertexBuffer.MatricesIndicesKind
  64305. * - VertexBuffer.MatricesIndicesExtraKind
  64306. * - VertexBuffer.MatricesWeightsKind
  64307. * - VertexBuffer.MatricesWeightsExtraKind
  64308. *
  64309. * Returns the Mesh.
  64310. */
  64311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  64312. /**
  64313. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  64314. * If the mesh has no geometry, it is simply returned as it is.
  64315. * The `data` are either a numeric array either a Float32Array.
  64316. * No new underlying VertexBuffer object is created.
  64317. * 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.
  64318. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  64319. *
  64320. * Possible `kind` values :
  64321. * - VertexBuffer.PositionKind
  64322. * - VertexBuffer.UVKind
  64323. * - VertexBuffer.UV2Kind
  64324. * - VertexBuffer.UV3Kind
  64325. * - VertexBuffer.UV4Kind
  64326. * - VertexBuffer.UV5Kind
  64327. * - VertexBuffer.UV6Kind
  64328. * - VertexBuffer.ColorKind
  64329. * - VertexBuffer.MatricesIndicesKind
  64330. * - VertexBuffer.MatricesIndicesExtraKind
  64331. * - VertexBuffer.MatricesWeightsKind
  64332. * - VertexBuffer.MatricesWeightsExtraKind
  64333. *
  64334. * Returns the Mesh.
  64335. */
  64336. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  64337. /**
  64338. * Sets the mesh indices.
  64339. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  64340. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  64341. * This method creates a new index buffer each call.
  64342. * Returns the Mesh.
  64343. */
  64344. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  64345. /**
  64346. * Boolean : True if the mesh owns the requested kind of data.
  64347. */
  64348. isVerticesDataPresent(kind: string): boolean;
  64349. /**
  64350. * Returns an array of indices (IndicesArray).
  64351. */
  64352. getIndices(): Nullable<IndicesArray>;
  64353. readonly _positions: Nullable<Vector3[]>;
  64354. /**
  64355. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  64356. * This means the mesh underlying bounding box and sphere are recomputed.
  64357. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  64358. * @returns the current mesh
  64359. */
  64360. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  64361. /** @hidden */
  64362. _preActivate(): InstancedMesh;
  64363. /** @hidden */
  64364. _activate(renderId: number): InstancedMesh;
  64365. /**
  64366. * Returns the current associated LOD AbstractMesh.
  64367. */
  64368. getLOD(camera: Camera): AbstractMesh;
  64369. /** @hidden */
  64370. _syncSubMeshes(): InstancedMesh;
  64371. /** @hidden */
  64372. _generatePointsArray(): boolean;
  64373. /**
  64374. * Creates a new InstancedMesh from the current mesh.
  64375. * - name (string) : the cloned mesh name
  64376. * - newParent (optional Node) : the optional Node to parent the clone to.
  64377. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  64378. *
  64379. * Returns the clone.
  64380. */
  64381. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  64382. /**
  64383. * Disposes the InstancedMesh.
  64384. * Returns nothing.
  64385. */
  64386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64387. }
  64388. }
  64389. declare module BABYLON {
  64390. /**
  64391. * Class for creating a cube texture
  64392. */
  64393. export class CubeTexture extends BaseTexture {
  64394. private _delayedOnLoad;
  64395. /**
  64396. * The url of the texture
  64397. */
  64398. url: string;
  64399. /**
  64400. * Gets or sets the center of the bounding box associated with the cube texture.
  64401. * It must define where the camera used to render the texture was set
  64402. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64403. */
  64404. boundingBoxPosition: Vector3;
  64405. private _boundingBoxSize;
  64406. /**
  64407. * Gets or sets the size of the bounding box associated with the cube texture
  64408. * When defined, the cubemap will switch to local mode
  64409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64410. * @example https://www.babylonjs-playground.com/#RNASML
  64411. */
  64412. /**
  64413. * Returns the bounding box size
  64414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64415. */
  64416. boundingBoxSize: Vector3;
  64417. protected _rotationY: number;
  64418. /**
  64419. * Sets texture matrix rotation angle around Y axis in radians.
  64420. */
  64421. /**
  64422. * Gets texture matrix rotation angle around Y axis radians.
  64423. */
  64424. rotationY: number;
  64425. /**
  64426. * Are mip maps generated for this texture or not.
  64427. */
  64428. readonly noMipmap: boolean;
  64429. private _noMipmap;
  64430. private _files;
  64431. private _extensions;
  64432. private _textureMatrix;
  64433. private _format;
  64434. private _createPolynomials;
  64435. /** @hidden */
  64436. _prefiltered: boolean;
  64437. /**
  64438. * Creates a cube texture from an array of image urls
  64439. * @param files defines an array of image urls
  64440. * @param scene defines the hosting scene
  64441. * @param noMipmap specifies if mip maps are not used
  64442. * @returns a cube texture
  64443. */
  64444. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  64445. /**
  64446. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  64447. * @param url defines the url of the prefiltered texture
  64448. * @param scene defines the scene the texture is attached to
  64449. * @param forcedExtension defines the extension of the file if different from the url
  64450. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64451. * @return the prefiltered texture
  64452. */
  64453. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64454. /**
  64455. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64456. * as prefiltered data.
  64457. * @param rootUrl defines the url of the texture or the root name of the six images
  64458. * @param scene defines the scene the texture is attached to
  64459. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64460. * @param noMipmap defines if mipmaps should be created or not
  64461. * @param files defines the six files to load for the different faces
  64462. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64463. * @param onError defines a callback triggered in case of error during load
  64464. * @param format defines the internal format to use for the texture once loaded
  64465. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64466. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64470. * @return the cube texture
  64471. */
  64472. 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);
  64473. /**
  64474. * Get the current class name of the texture useful for serialization or dynamic coding.
  64475. * @returns "CubeTexture"
  64476. */
  64477. getClassName(): string;
  64478. /**
  64479. * Update the url (and optional buffer) of this texture if url was null during construction.
  64480. * @param url the url of the texture
  64481. * @param forcedExtension defines the extension to use
  64482. * @param onLoad callback called when the texture is loaded (defaults to null)
  64483. */
  64484. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64485. /**
  64486. * Delays loading of the cube texture
  64487. * @param forcedExtension defines the extension to use
  64488. */
  64489. delayLoad(forcedExtension?: string): void;
  64490. /**
  64491. * Returns the reflection texture matrix
  64492. * @returns the reflection texture matrix
  64493. */
  64494. getReflectionTextureMatrix(): Matrix;
  64495. /**
  64496. * Sets the reflection texture matrix
  64497. * @param value Reflection texture matrix
  64498. */
  64499. setReflectionTextureMatrix(value: Matrix): void;
  64500. /**
  64501. * Parses text to create a cube texture
  64502. * @param parsedTexture define the serialized text to read from
  64503. * @param scene defines the hosting scene
  64504. * @param rootUrl defines the root url of the cube texture
  64505. * @returns a cube texture
  64506. */
  64507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64508. /**
  64509. * Makes a clone, or deep copy, of the cube texture
  64510. * @returns a new cube texture
  64511. */
  64512. clone(): CubeTexture;
  64513. }
  64514. }
  64515. declare module BABYLON {
  64516. /** @hidden */
  64517. export var postprocessVertexShader: {
  64518. name: string;
  64519. shader: string;
  64520. };
  64521. }
  64522. declare module BABYLON {
  64523. /**
  64524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64525. * This is the base of the follow, arc rotate cameras and Free camera
  64526. * @see http://doc.babylonjs.com/features/cameras
  64527. */
  64528. export class TargetCamera extends Camera {
  64529. private static _RigCamTransformMatrix;
  64530. private static _TargetTransformMatrix;
  64531. private static _TargetFocalPoint;
  64532. /**
  64533. * Define the current direction the camera is moving to
  64534. */
  64535. cameraDirection: Vector3;
  64536. /**
  64537. * Define the current rotation the camera is rotating to
  64538. */
  64539. cameraRotation: Vector2;
  64540. /**
  64541. * When set, the up vector of the camera will be updated by the rotation of the camera
  64542. */
  64543. updateUpVectorFromRotation: boolean;
  64544. private _tmpQuaternion;
  64545. /**
  64546. * Define the current rotation of the camera
  64547. */
  64548. rotation: Vector3;
  64549. /**
  64550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64551. */
  64552. rotationQuaternion: Quaternion;
  64553. /**
  64554. * Define the current speed of the camera
  64555. */
  64556. speed: number;
  64557. /**
  64558. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64559. * around all axis.
  64560. */
  64561. noRotationConstraint: boolean;
  64562. /**
  64563. * Define the current target of the camera as an object or a position.
  64564. */
  64565. lockedTarget: any;
  64566. /** @hidden */
  64567. _currentTarget: Vector3;
  64568. /** @hidden */
  64569. _initialFocalDistance: number;
  64570. /** @hidden */
  64571. _viewMatrix: Matrix;
  64572. /** @hidden */
  64573. _camMatrix: Matrix;
  64574. /** @hidden */
  64575. _cameraTransformMatrix: Matrix;
  64576. /** @hidden */
  64577. _cameraRotationMatrix: Matrix;
  64578. /** @hidden */
  64579. _referencePoint: Vector3;
  64580. /** @hidden */
  64581. _transformedReferencePoint: Vector3;
  64582. protected _globalCurrentTarget: Vector3;
  64583. protected _globalCurrentUpVector: Vector3;
  64584. /** @hidden */
  64585. _reset: () => void;
  64586. private _defaultUp;
  64587. /**
  64588. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64589. * This is the base of the follow, arc rotate cameras and Free camera
  64590. * @see http://doc.babylonjs.com/features/cameras
  64591. * @param name Defines the name of the camera in the scene
  64592. * @param position Defines the start position of the camera in the scene
  64593. * @param scene Defines the scene the camera belongs to
  64594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64595. */
  64596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64597. /**
  64598. * Gets the position in front of the camera at a given distance.
  64599. * @param distance The distance from the camera we want the position to be
  64600. * @returns the position
  64601. */
  64602. getFrontPosition(distance: number): Vector3;
  64603. /** @hidden */
  64604. _getLockedTargetPosition(): Nullable<Vector3>;
  64605. private _storedPosition;
  64606. private _storedRotation;
  64607. private _storedRotationQuaternion;
  64608. /**
  64609. * Store current camera state of the camera (fov, position, rotation, etc..)
  64610. * @returns the camera
  64611. */
  64612. storeState(): Camera;
  64613. /**
  64614. * Restored camera state. You must call storeState() first
  64615. * @returns whether it was successful or not
  64616. * @hidden
  64617. */
  64618. _restoreStateValues(): boolean;
  64619. /** @hidden */
  64620. _initCache(): void;
  64621. /** @hidden */
  64622. _updateCache(ignoreParentClass?: boolean): void;
  64623. /** @hidden */
  64624. _isSynchronizedViewMatrix(): boolean;
  64625. /** @hidden */
  64626. _computeLocalCameraSpeed(): number;
  64627. /** @hidden */
  64628. setTarget(target: Vector3): void;
  64629. /**
  64630. * Return the current target position of the camera. This value is expressed in local space.
  64631. * @returns the target position
  64632. */
  64633. getTarget(): Vector3;
  64634. /** @hidden */
  64635. _decideIfNeedsToMove(): boolean;
  64636. /** @hidden */
  64637. _updatePosition(): void;
  64638. /** @hidden */
  64639. _checkInputs(): void;
  64640. protected _updateCameraRotationMatrix(): void;
  64641. /**
  64642. * 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)
  64643. * @returns the current camera
  64644. */
  64645. private _rotateUpVectorWithCameraRotationMatrix;
  64646. private _cachedRotationZ;
  64647. private _cachedQuaternionRotationZ;
  64648. /** @hidden */
  64649. _getViewMatrix(): Matrix;
  64650. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64651. /**
  64652. * @hidden
  64653. */
  64654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64655. /**
  64656. * @hidden
  64657. */
  64658. _updateRigCameras(): void;
  64659. private _getRigCamPositionAndTarget;
  64660. /**
  64661. * Gets the current object class name.
  64662. * @return the class name
  64663. */
  64664. getClassName(): string;
  64665. }
  64666. }
  64667. declare module BABYLON {
  64668. /**
  64669. * @ignore
  64670. * This is a list of all the different input types that are available in the application.
  64671. * Fo instance: ArcRotateCameraGamepadInput...
  64672. */
  64673. export var CameraInputTypes: {};
  64674. /**
  64675. * This is the contract to implement in order to create a new input class.
  64676. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64677. */
  64678. export interface ICameraInput<TCamera extends Camera> {
  64679. /**
  64680. * Defines the camera the input is attached to.
  64681. */
  64682. camera: Nullable<TCamera>;
  64683. /**
  64684. * Gets the class name of the current intput.
  64685. * @returns the class name
  64686. */
  64687. getClassName(): string;
  64688. /**
  64689. * Get the friendly name associated with the input class.
  64690. * @returns the input friendly name
  64691. */
  64692. getSimpleName(): string;
  64693. /**
  64694. * Attach the input controls to a specific dom element to get the input from.
  64695. * @param element Defines the element the controls should be listened from
  64696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64697. */
  64698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64699. /**
  64700. * Detach the current controls from the specified dom element.
  64701. * @param element Defines the element to stop listening the inputs from
  64702. */
  64703. detachControl(element: Nullable<HTMLElement>): void;
  64704. /**
  64705. * Update the current camera state depending on the inputs that have been used this frame.
  64706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64707. */
  64708. checkInputs?: () => void;
  64709. }
  64710. /**
  64711. * Represents a map of input types to input instance or input index to input instance.
  64712. */
  64713. export interface CameraInputsMap<TCamera extends Camera> {
  64714. /**
  64715. * Accessor to the input by input type.
  64716. */
  64717. [name: string]: ICameraInput<TCamera>;
  64718. /**
  64719. * Accessor to the input by input index.
  64720. */
  64721. [idx: number]: ICameraInput<TCamera>;
  64722. }
  64723. /**
  64724. * This represents the input manager used within a camera.
  64725. * It helps dealing with all the different kind of input attached to a camera.
  64726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64727. */
  64728. export class CameraInputsManager<TCamera extends Camera> {
  64729. /**
  64730. * Defines the list of inputs attahed to the camera.
  64731. */
  64732. attached: CameraInputsMap<TCamera>;
  64733. /**
  64734. * Defines the dom element the camera is collecting inputs from.
  64735. * This is null if the controls have not been attached.
  64736. */
  64737. attachedElement: Nullable<HTMLElement>;
  64738. /**
  64739. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64740. */
  64741. noPreventDefault: boolean;
  64742. /**
  64743. * Defined the camera the input manager belongs to.
  64744. */
  64745. camera: TCamera;
  64746. /**
  64747. * Update the current camera state depending on the inputs that have been used this frame.
  64748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64749. */
  64750. checkInputs: () => void;
  64751. /**
  64752. * Instantiate a new Camera Input Manager.
  64753. * @param camera Defines the camera the input manager blongs to
  64754. */
  64755. constructor(camera: TCamera);
  64756. /**
  64757. * Add an input method to a camera
  64758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64759. * @param input camera input method
  64760. */
  64761. add(input: ICameraInput<TCamera>): void;
  64762. /**
  64763. * Remove a specific input method from a camera
  64764. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64765. * @param inputToRemove camera input method
  64766. */
  64767. remove(inputToRemove: ICameraInput<TCamera>): void;
  64768. /**
  64769. * Remove a specific input type from a camera
  64770. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64771. * @param inputType the type of the input to remove
  64772. */
  64773. removeByType(inputType: string): void;
  64774. private _addCheckInputs;
  64775. /**
  64776. * Attach the input controls to the currently attached dom element to listen the events from.
  64777. * @param input Defines the input to attach
  64778. */
  64779. attachInput(input: ICameraInput<TCamera>): void;
  64780. /**
  64781. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64782. * @param element Defines the dom element to collect the events from
  64783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64784. */
  64785. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64786. /**
  64787. * Detach the current manager inputs controls from a specific dom element.
  64788. * @param element Defines the dom element to collect the events from
  64789. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64790. */
  64791. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64792. /**
  64793. * Rebuild the dynamic inputCheck function from the current list of
  64794. * defined inputs in the manager.
  64795. */
  64796. rebuildInputCheck(): void;
  64797. /**
  64798. * Remove all attached input methods from a camera
  64799. */
  64800. clear(): void;
  64801. /**
  64802. * Serialize the current input manager attached to a camera.
  64803. * This ensures than once parsed,
  64804. * the input associated to the camera will be identical to the current ones
  64805. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64806. */
  64807. serialize(serializedCamera: any): void;
  64808. /**
  64809. * Parses an input manager serialized JSON to restore the previous list of inputs
  64810. * and states associated to a camera.
  64811. * @param parsedCamera Defines the JSON to parse
  64812. */
  64813. parse(parsedCamera: any): void;
  64814. }
  64815. }
  64816. declare module BABYLON {
  64817. /**
  64818. * Gather the list of keyboard event types as constants.
  64819. */
  64820. export class KeyboardEventTypes {
  64821. /**
  64822. * The keydown event is fired when a key becomes active (pressed).
  64823. */
  64824. static readonly KEYDOWN: number;
  64825. /**
  64826. * The keyup event is fired when a key has been released.
  64827. */
  64828. static readonly KEYUP: number;
  64829. }
  64830. /**
  64831. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64832. */
  64833. export class KeyboardInfo {
  64834. /**
  64835. * Defines the type of event (KeyboardEventTypes)
  64836. */
  64837. type: number;
  64838. /**
  64839. * Defines the related dom event
  64840. */
  64841. event: KeyboardEvent;
  64842. /**
  64843. * Instantiates a new keyboard info.
  64844. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64845. * @param type Defines the type of event (KeyboardEventTypes)
  64846. * @param event Defines the related dom event
  64847. */
  64848. constructor(
  64849. /**
  64850. * Defines the type of event (KeyboardEventTypes)
  64851. */
  64852. type: number,
  64853. /**
  64854. * Defines the related dom event
  64855. */
  64856. event: KeyboardEvent);
  64857. }
  64858. /**
  64859. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64860. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64861. */
  64862. export class KeyboardInfoPre extends KeyboardInfo {
  64863. /**
  64864. * Defines the type of event (KeyboardEventTypes)
  64865. */
  64866. type: number;
  64867. /**
  64868. * Defines the related dom event
  64869. */
  64870. event: KeyboardEvent;
  64871. /**
  64872. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64873. */
  64874. skipOnPointerObservable: boolean;
  64875. /**
  64876. * Instantiates a new keyboard pre info.
  64877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64878. * @param type Defines the type of event (KeyboardEventTypes)
  64879. * @param event Defines the related dom event
  64880. */
  64881. constructor(
  64882. /**
  64883. * Defines the type of event (KeyboardEventTypes)
  64884. */
  64885. type: number,
  64886. /**
  64887. * Defines the related dom event
  64888. */
  64889. event: KeyboardEvent);
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /**
  64894. * Manage the keyboard inputs to control the movement of a free camera.
  64895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64896. */
  64897. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64898. /**
  64899. * Defines the camera the input is attached to.
  64900. */
  64901. camera: FreeCamera;
  64902. /**
  64903. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64904. */
  64905. keysUp: number[];
  64906. /**
  64907. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64908. */
  64909. keysDown: number[];
  64910. /**
  64911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64912. */
  64913. keysLeft: number[];
  64914. /**
  64915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64916. */
  64917. keysRight: number[];
  64918. private _keys;
  64919. private _onCanvasBlurObserver;
  64920. private _onKeyboardObserver;
  64921. private _engine;
  64922. private _scene;
  64923. /**
  64924. * Attach the input controls to a specific dom element to get the input from.
  64925. * @param element Defines the element the controls should be listened from
  64926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64927. */
  64928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64929. /**
  64930. * Detach the current controls from the specified dom element.
  64931. * @param element Defines the element to stop listening the inputs from
  64932. */
  64933. detachControl(element: Nullable<HTMLElement>): void;
  64934. /**
  64935. * Update the current camera state depending on the inputs that have been used this frame.
  64936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64937. */
  64938. checkInputs(): void;
  64939. /**
  64940. * Gets the class name of the current intput.
  64941. * @returns the class name
  64942. */
  64943. getClassName(): string;
  64944. /** @hidden */
  64945. _onLostFocus(): void;
  64946. /**
  64947. * Get the friendly name associated with the input class.
  64948. * @returns the input friendly name
  64949. */
  64950. getSimpleName(): string;
  64951. }
  64952. }
  64953. declare module BABYLON {
  64954. /**
  64955. * Interface used to define ActionEvent
  64956. */
  64957. export interface IActionEvent {
  64958. /** The mesh or sprite that triggered the action */
  64959. source: any;
  64960. /** The X mouse cursor position at the time of the event */
  64961. pointerX: number;
  64962. /** The Y mouse cursor position at the time of the event */
  64963. pointerY: number;
  64964. /** The mesh that is currently pointed at (can be null) */
  64965. meshUnderPointer: Nullable<AbstractMesh>;
  64966. /** the original (browser) event that triggered the ActionEvent */
  64967. sourceEvent?: any;
  64968. /** additional data for the event */
  64969. additionalData?: any;
  64970. }
  64971. /**
  64972. * ActionEvent is the event being sent when an action is triggered.
  64973. */
  64974. export class ActionEvent implements IActionEvent {
  64975. /** The mesh or sprite that triggered the action */
  64976. source: any;
  64977. /** The X mouse cursor position at the time of the event */
  64978. pointerX: number;
  64979. /** The Y mouse cursor position at the time of the event */
  64980. pointerY: number;
  64981. /** The mesh that is currently pointed at (can be null) */
  64982. meshUnderPointer: Nullable<AbstractMesh>;
  64983. /** the original (browser) event that triggered the ActionEvent */
  64984. sourceEvent?: any;
  64985. /** additional data for the event */
  64986. additionalData?: any;
  64987. /**
  64988. * Creates a new ActionEvent
  64989. * @param source The mesh or sprite that triggered the action
  64990. * @param pointerX The X mouse cursor position at the time of the event
  64991. * @param pointerY The Y mouse cursor position at the time of the event
  64992. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  64993. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  64994. * @param additionalData additional data for the event
  64995. */
  64996. constructor(
  64997. /** The mesh or sprite that triggered the action */
  64998. source: any,
  64999. /** The X mouse cursor position at the time of the event */
  65000. pointerX: number,
  65001. /** The Y mouse cursor position at the time of the event */
  65002. pointerY: number,
  65003. /** The mesh that is currently pointed at (can be null) */
  65004. meshUnderPointer: Nullable<AbstractMesh>,
  65005. /** the original (browser) event that triggered the ActionEvent */
  65006. sourceEvent?: any,
  65007. /** additional data for the event */
  65008. additionalData?: any);
  65009. /**
  65010. * Helper function to auto-create an ActionEvent from a source mesh.
  65011. * @param source The source mesh that triggered the event
  65012. * @param evt The original (browser) event
  65013. * @param additionalData additional data for the event
  65014. * @returns the new ActionEvent
  65015. */
  65016. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  65017. /**
  65018. * Helper function to auto-create an ActionEvent from a source sprite
  65019. * @param source The source sprite that triggered the event
  65020. * @param scene Scene associated with the sprite
  65021. * @param evt The original (browser) event
  65022. * @param additionalData additional data for the event
  65023. * @returns the new ActionEvent
  65024. */
  65025. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  65026. /**
  65027. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  65028. * @param scene the scene where the event occurred
  65029. * @param evt The original (browser) event
  65030. * @returns the new ActionEvent
  65031. */
  65032. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  65033. /**
  65034. * Helper function to auto-create an ActionEvent from a primitive
  65035. * @param prim defines the target primitive
  65036. * @param pointerPos defines the pointer position
  65037. * @param evt The original (browser) event
  65038. * @param additionalData additional data for the event
  65039. * @returns the new ActionEvent
  65040. */
  65041. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /**
  65046. * Interface describing all the common properties and methods a shadow light needs to implement.
  65047. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65048. * as well as binding the different shadow properties to the effects.
  65049. */
  65050. export interface IShadowLight extends Light {
  65051. /**
  65052. * The light id in the scene (used in scene.findLighById for instance)
  65053. */
  65054. id: string;
  65055. /**
  65056. * The position the shdow will be casted from.
  65057. */
  65058. position: Vector3;
  65059. /**
  65060. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65061. */
  65062. direction: Vector3;
  65063. /**
  65064. * The transformed position. Position of the light in world space taking parenting in account.
  65065. */
  65066. transformedPosition: Vector3;
  65067. /**
  65068. * The transformed direction. Direction of the light in world space taking parenting in account.
  65069. */
  65070. transformedDirection: Vector3;
  65071. /**
  65072. * The friendly name of the light in the scene.
  65073. */
  65074. name: string;
  65075. /**
  65076. * Defines the shadow projection clipping minimum z value.
  65077. */
  65078. shadowMinZ: number;
  65079. /**
  65080. * Defines the shadow projection clipping maximum z value.
  65081. */
  65082. shadowMaxZ: number;
  65083. /**
  65084. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65085. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65086. */
  65087. computeTransformedInformation(): boolean;
  65088. /**
  65089. * Gets the scene the light belongs to.
  65090. * @returns The scene
  65091. */
  65092. getScene(): Scene;
  65093. /**
  65094. * Callback defining a custom Projection Matrix Builder.
  65095. * This can be used to override the default projection matrix computation.
  65096. */
  65097. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65098. /**
  65099. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65100. * @param matrix The materix to updated with the projection information
  65101. * @param viewMatrix The transform matrix of the light
  65102. * @param renderList The list of mesh to render in the map
  65103. * @returns The current light
  65104. */
  65105. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65106. /**
  65107. * Gets the current depth scale used in ESM.
  65108. * @returns The scale
  65109. */
  65110. getDepthScale(): number;
  65111. /**
  65112. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65113. * @returns true if a cube texture needs to be use
  65114. */
  65115. needCube(): boolean;
  65116. /**
  65117. * Detects if the projection matrix requires to be recomputed this frame.
  65118. * @returns true if it requires to be recomputed otherwise, false.
  65119. */
  65120. needProjectionMatrixCompute(): boolean;
  65121. /**
  65122. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65123. */
  65124. forceProjectionMatrixCompute(): void;
  65125. /**
  65126. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65127. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65128. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65129. */
  65130. getShadowDirection(faceIndex?: number): Vector3;
  65131. /**
  65132. * Gets the minZ used for shadow according to both the scene and the light.
  65133. * @param activeCamera The camera we are returning the min for
  65134. * @returns the depth min z
  65135. */
  65136. getDepthMinZ(activeCamera: Camera): number;
  65137. /**
  65138. * Gets the maxZ used for shadow according to both the scene and the light.
  65139. * @param activeCamera The camera we are returning the max for
  65140. * @returns the depth max z
  65141. */
  65142. getDepthMaxZ(activeCamera: Camera): number;
  65143. }
  65144. /**
  65145. * Base implementation IShadowLight
  65146. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65147. */
  65148. export abstract class ShadowLight extends Light implements IShadowLight {
  65149. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65150. protected _position: Vector3;
  65151. protected _setPosition(value: Vector3): void;
  65152. /**
  65153. * Sets the position the shadow will be casted from. Also use as the light position for both
  65154. * point and spot lights.
  65155. */
  65156. /**
  65157. * Sets the position the shadow will be casted from. Also use as the light position for both
  65158. * point and spot lights.
  65159. */
  65160. position: Vector3;
  65161. protected _direction: Vector3;
  65162. protected _setDirection(value: Vector3): void;
  65163. /**
  65164. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65165. * Also use as the light direction on spot and directional lights.
  65166. */
  65167. /**
  65168. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65169. * Also use as the light direction on spot and directional lights.
  65170. */
  65171. direction: Vector3;
  65172. private _shadowMinZ;
  65173. /**
  65174. * Gets the shadow projection clipping minimum z value.
  65175. */
  65176. /**
  65177. * Sets the shadow projection clipping minimum z value.
  65178. */
  65179. shadowMinZ: number;
  65180. private _shadowMaxZ;
  65181. /**
  65182. * Sets the shadow projection clipping maximum z value.
  65183. */
  65184. /**
  65185. * Gets the shadow projection clipping maximum z value.
  65186. */
  65187. shadowMaxZ: number;
  65188. /**
  65189. * Callback defining a custom Projection Matrix Builder.
  65190. * This can be used to override the default projection matrix computation.
  65191. */
  65192. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65193. /**
  65194. * The transformed position. Position of the light in world space taking parenting in account.
  65195. */
  65196. transformedPosition: Vector3;
  65197. /**
  65198. * The transformed direction. Direction of the light in world space taking parenting in account.
  65199. */
  65200. transformedDirection: Vector3;
  65201. private _needProjectionMatrixCompute;
  65202. /**
  65203. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65204. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65205. */
  65206. computeTransformedInformation(): boolean;
  65207. /**
  65208. * Return the depth scale used for the shadow map.
  65209. * @returns the depth scale.
  65210. */
  65211. getDepthScale(): number;
  65212. /**
  65213. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65214. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65215. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65216. */
  65217. getShadowDirection(faceIndex?: number): Vector3;
  65218. /**
  65219. * Returns the ShadowLight absolute position in the World.
  65220. * @returns the position vector in world space
  65221. */
  65222. getAbsolutePosition(): Vector3;
  65223. /**
  65224. * Sets the ShadowLight direction toward the passed target.
  65225. * @param target The point tot target in local space
  65226. * @returns the updated ShadowLight direction
  65227. */
  65228. setDirectionToTarget(target: Vector3): Vector3;
  65229. /**
  65230. * Returns the light rotation in euler definition.
  65231. * @returns the x y z rotation in local space.
  65232. */
  65233. getRotation(): Vector3;
  65234. /**
  65235. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65236. * @returns true if a cube texture needs to be use
  65237. */
  65238. needCube(): boolean;
  65239. /**
  65240. * Detects if the projection matrix requires to be recomputed this frame.
  65241. * @returns true if it requires to be recomputed otherwise, false.
  65242. */
  65243. needProjectionMatrixCompute(): boolean;
  65244. /**
  65245. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65246. */
  65247. forceProjectionMatrixCompute(): void;
  65248. /** @hidden */
  65249. _initCache(): void;
  65250. /** @hidden */
  65251. _isSynchronized(): boolean;
  65252. /**
  65253. * Computes the world matrix of the node
  65254. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65255. * @returns the world matrix
  65256. */
  65257. computeWorldMatrix(force?: boolean): Matrix;
  65258. /**
  65259. * Gets the minZ used for shadow according to both the scene and the light.
  65260. * @param activeCamera The camera we are returning the min for
  65261. * @returns the depth min z
  65262. */
  65263. getDepthMinZ(activeCamera: Camera): number;
  65264. /**
  65265. * Gets the maxZ used for shadow according to both the scene and the light.
  65266. * @param activeCamera The camera we are returning the max for
  65267. * @returns the depth max z
  65268. */
  65269. getDepthMaxZ(activeCamera: Camera): number;
  65270. /**
  65271. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65272. * @param matrix The materix to updated with the projection information
  65273. * @param viewMatrix The transform matrix of the light
  65274. * @param renderList The list of mesh to render in the map
  65275. * @returns The current light
  65276. */
  65277. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65278. }
  65279. }
  65280. declare module BABYLON {
  65281. /**
  65282. * "Static Class" containing the most commonly used helper while dealing with material for
  65283. * rendering purpose.
  65284. *
  65285. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65286. *
  65287. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65288. */
  65289. export class MaterialHelper {
  65290. /**
  65291. * Bind the current view position to an effect.
  65292. * @param effect The effect to be bound
  65293. * @param scene The scene the eyes position is used from
  65294. */
  65295. static BindEyePosition(effect: Effect, scene: Scene): void;
  65296. /**
  65297. * Helps preparing the defines values about the UVs in used in the effect.
  65298. * UVs are shared as much as we can accross channels in the shaders.
  65299. * @param texture The texture we are preparing the UVs for
  65300. * @param defines The defines to update
  65301. * @param key The channel key "diffuse", "specular"... used in the shader
  65302. */
  65303. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65304. /**
  65305. * Binds a texture matrix value to its corrsponding uniform
  65306. * @param texture The texture to bind the matrix for
  65307. * @param uniformBuffer The uniform buffer receivin the data
  65308. * @param key The channel key "diffuse", "specular"... used in the shader
  65309. */
  65310. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65311. /**
  65312. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65313. * @param mesh defines the current mesh
  65314. * @param scene defines the current scene
  65315. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65316. * @param pointsCloud defines if point cloud rendering has to be turned on
  65317. * @param fogEnabled defines if fog has to be turned on
  65318. * @param alphaTest defines if alpha testing has to be turned on
  65319. * @param defines defines the current list of defines
  65320. */
  65321. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65322. /**
  65323. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65324. * @param scene defines the current scene
  65325. * @param engine defines the current engine
  65326. * @param defines specifies the list of active defines
  65327. * @param useInstances defines if instances have to be turned on
  65328. * @param useClipPlane defines if clip plane have to be turned on
  65329. */
  65330. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65331. /**
  65332. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65333. * @param mesh The mesh containing the geometry data we will draw
  65334. * @param defines The defines to update
  65335. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65336. * @param useBones Precise whether bones should be used or not (override mesh info)
  65337. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65338. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65339. * @returns false if defines are considered not dirty and have not been checked
  65340. */
  65341. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65342. /**
  65343. * Prepares the defines related to the light information passed in parameter
  65344. * @param scene The scene we are intending to draw
  65345. * @param mesh The mesh the effect is compiling for
  65346. * @param defines The defines to update
  65347. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65348. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65349. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65350. * @returns true if normals will be required for the rest of the effect
  65351. */
  65352. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65353. /**
  65354. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65355. * that won t be acctive due to defines being turned off.
  65356. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65357. * @param samplersList The samplers list
  65358. * @param defines The defines helping in the list generation
  65359. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65360. */
  65361. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65362. /**
  65363. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65364. * @param defines The defines to update while falling back
  65365. * @param fallbacks The authorized effect fallbacks
  65366. * @param maxSimultaneousLights The maximum number of lights allowed
  65367. * @param rank the current rank of the Effect
  65368. * @returns The newly affected rank
  65369. */
  65370. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65371. /**
  65372. * Prepares the list of attributes required for morph targets according to the effect defines.
  65373. * @param attribs The current list of supported attribs
  65374. * @param mesh The mesh to prepare the morph targets attributes for
  65375. * @param defines The current Defines of the effect
  65376. */
  65377. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65378. /**
  65379. * Prepares the list of attributes required for bones according to the effect defines.
  65380. * @param attribs The current list of supported attribs
  65381. * @param mesh The mesh to prepare the bones attributes for
  65382. * @param defines The current Defines of the effect
  65383. * @param fallbacks The current efffect fallback strategy
  65384. */
  65385. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  65386. /**
  65387. * Prepares the list of attributes required for instances according to the effect defines.
  65388. * @param attribs The current list of supported attribs
  65389. * @param defines The current Defines of the effect
  65390. */
  65391. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  65392. /**
  65393. * Binds the light shadow information to the effect for the given mesh.
  65394. * @param light The light containing the generator
  65395. * @param scene The scene the lights belongs to
  65396. * @param mesh The mesh we are binding the information to render
  65397. * @param lightIndex The light index in the effect used to render the mesh
  65398. * @param effect The effect we are binding the data to
  65399. */
  65400. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  65401. /**
  65402. * Binds the light information to the effect.
  65403. * @param light The light containing the generator
  65404. * @param effect The effect we are binding the data to
  65405. * @param lightIndex The light index in the effect used to render
  65406. */
  65407. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  65408. /**
  65409. * Binds the lights information from the scene to the effect for the given mesh.
  65410. * @param scene The scene the lights belongs to
  65411. * @param mesh The mesh we are binding the information to render
  65412. * @param effect The effect we are binding the data to
  65413. * @param defines The generated defines for the effect
  65414. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65415. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65416. */
  65417. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  65418. private static _tempFogColor;
  65419. /**
  65420. * Binds the fog information from the scene to the effect for the given mesh.
  65421. * @param scene The scene the lights belongs to
  65422. * @param mesh The mesh we are binding the information to render
  65423. * @param effect The effect we are binding the data to
  65424. * @param linearSpace Defines if the fog effect is applied in linear space
  65425. */
  65426. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  65427. /**
  65428. * Binds the bones information from the mesh to the effect.
  65429. * @param mesh The mesh we are binding the information to render
  65430. * @param effect The effect we are binding the data to
  65431. */
  65432. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  65433. /**
  65434. * Binds the morph targets information from the mesh to the effect.
  65435. * @param abstractMesh The mesh we are binding the information to render
  65436. * @param effect The effect we are binding the data to
  65437. */
  65438. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  65439. /**
  65440. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65441. * @param defines The generated defines used in the effect
  65442. * @param effect The effect we are binding the data to
  65443. * @param scene The scene we are willing to render with logarithmic scale for
  65444. */
  65445. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  65446. /**
  65447. * Binds the clip plane information from the scene to the effect.
  65448. * @param scene The scene the clip plane information are extracted from
  65449. * @param effect The effect we are binding the data to
  65450. */
  65451. static BindClipPlane(effect: Effect, scene: Scene): void;
  65452. }
  65453. }
  65454. declare module BABYLON {
  65455. /** @hidden */
  65456. export var kernelBlurVaryingDeclaration: {
  65457. name: string;
  65458. shader: string;
  65459. };
  65460. }
  65461. declare module BABYLON {
  65462. /** @hidden */
  65463. export var kernelBlurFragment: {
  65464. name: string;
  65465. shader: string;
  65466. };
  65467. }
  65468. declare module BABYLON {
  65469. /** @hidden */
  65470. export var kernelBlurFragment2: {
  65471. name: string;
  65472. shader: string;
  65473. };
  65474. }
  65475. declare module BABYLON {
  65476. /** @hidden */
  65477. export var kernelBlurPixelShader: {
  65478. name: string;
  65479. shader: string;
  65480. };
  65481. }
  65482. declare module BABYLON {
  65483. /** @hidden */
  65484. export var kernelBlurVertex: {
  65485. name: string;
  65486. shader: string;
  65487. };
  65488. }
  65489. declare module BABYLON {
  65490. /** @hidden */
  65491. export var kernelBlurVertexShader: {
  65492. name: string;
  65493. shader: string;
  65494. };
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * The Blur Post Process which blurs an image based on a kernel and direction.
  65499. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  65500. */
  65501. export class BlurPostProcess extends PostProcess {
  65502. /** The direction in which to blur the image. */
  65503. direction: Vector2;
  65504. private blockCompilation;
  65505. protected _kernel: number;
  65506. protected _idealKernel: number;
  65507. protected _packedFloat: boolean;
  65508. private _staticDefines;
  65509. /**
  65510. * Sets the length in pixels of the blur sample region
  65511. */
  65512. /**
  65513. * Gets the length in pixels of the blur sample region
  65514. */
  65515. kernel: number;
  65516. /**
  65517. * Sets wether or not the blur needs to unpack/repack floats
  65518. */
  65519. /**
  65520. * Gets wether or not the blur is unpacking/repacking floats
  65521. */
  65522. packedFloat: boolean;
  65523. /**
  65524. * Creates a new instance BlurPostProcess
  65525. * @param name The name of the effect.
  65526. * @param direction The direction in which to blur the image.
  65527. * @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.
  65528. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  65529. * @param camera The camera to apply the render pass to.
  65530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65531. * @param engine The engine which the post process will be applied. (default: current engine)
  65532. * @param reusable If the post process can be reused on the same frame. (default: false)
  65533. * @param textureType Type of textures used when performing the post process. (default: 0)
  65534. * @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)
  65535. */
  65536. constructor(name: string,
  65537. /** The direction in which to blur the image. */
  65538. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  65539. /**
  65540. * Updates the effect with the current post process compile time values and recompiles the shader.
  65541. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65542. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65543. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65544. * @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
  65545. * @param onCompiled Called when the shader has been compiled.
  65546. * @param onError Called if there is an error when compiling a shader.
  65547. */
  65548. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65549. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65550. /**
  65551. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  65552. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  65553. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  65554. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  65555. * The gaps between physical kernels are compensated for in the weighting of the samples
  65556. * @param idealKernel Ideal blur kernel.
  65557. * @return Nearest best kernel.
  65558. */
  65559. protected _nearestBestKernel(idealKernel: number): number;
  65560. /**
  65561. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  65562. * @param x The point on the Gaussian distribution to sample.
  65563. * @return the value of the Gaussian function at x.
  65564. */
  65565. protected _gaussianWeight(x: number): number;
  65566. /**
  65567. * Generates a string that can be used as a floating point number in GLSL.
  65568. * @param x Value to print.
  65569. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  65570. * @return GLSL float string.
  65571. */
  65572. protected _glslFloat(x: number, decimalFigures?: number): string;
  65573. }
  65574. }
  65575. declare module BABYLON {
  65576. /** @hidden */
  65577. export var shadowMapPixelShader: {
  65578. name: string;
  65579. shader: string;
  65580. };
  65581. }
  65582. declare module BABYLON {
  65583. /** @hidden */
  65584. export var bonesDeclaration: {
  65585. name: string;
  65586. shader: string;
  65587. };
  65588. }
  65589. declare module BABYLON {
  65590. /** @hidden */
  65591. export var morphTargetsVertexGlobalDeclaration: {
  65592. name: string;
  65593. shader: string;
  65594. };
  65595. }
  65596. declare module BABYLON {
  65597. /** @hidden */
  65598. export var morphTargetsVertexDeclaration: {
  65599. name: string;
  65600. shader: string;
  65601. };
  65602. }
  65603. declare module BABYLON {
  65604. /** @hidden */
  65605. export var instancesDeclaration: {
  65606. name: string;
  65607. shader: string;
  65608. };
  65609. }
  65610. declare module BABYLON {
  65611. /** @hidden */
  65612. export var helperFunctions: {
  65613. name: string;
  65614. shader: string;
  65615. };
  65616. }
  65617. declare module BABYLON {
  65618. /** @hidden */
  65619. export var morphTargetsVertex: {
  65620. name: string;
  65621. shader: string;
  65622. };
  65623. }
  65624. declare module BABYLON {
  65625. /** @hidden */
  65626. export var instancesVertex: {
  65627. name: string;
  65628. shader: string;
  65629. };
  65630. }
  65631. declare module BABYLON {
  65632. /** @hidden */
  65633. export var bonesVertex: {
  65634. name: string;
  65635. shader: string;
  65636. };
  65637. }
  65638. declare module BABYLON {
  65639. /** @hidden */
  65640. export var shadowMapVertexShader: {
  65641. name: string;
  65642. shader: string;
  65643. };
  65644. }
  65645. declare module BABYLON {
  65646. /** @hidden */
  65647. export var depthBoxBlurPixelShader: {
  65648. name: string;
  65649. shader: string;
  65650. };
  65651. }
  65652. declare module BABYLON {
  65653. /**
  65654. * Defines the options associated with the creation of a custom shader for a shadow generator.
  65655. */
  65656. export interface ICustomShaderOptions {
  65657. /**
  65658. * Gets or sets the custom shader name to use
  65659. */
  65660. shaderName: string;
  65661. /**
  65662. * The list of attribute names used in the shader
  65663. */
  65664. attributes?: string[];
  65665. /**
  65666. * The list of unifrom names used in the shader
  65667. */
  65668. uniforms?: string[];
  65669. /**
  65670. * The list of sampler names used in the shader
  65671. */
  65672. samplers?: string[];
  65673. /**
  65674. * The list of defines used in the shader
  65675. */
  65676. defines?: string[];
  65677. }
  65678. /**
  65679. * Interface to implement to create a shadow generator compatible with BJS.
  65680. */
  65681. export interface IShadowGenerator {
  65682. /**
  65683. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  65684. * @returns The render target texture if present otherwise, null
  65685. */
  65686. getShadowMap(): Nullable<RenderTargetTexture>;
  65687. /**
  65688. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  65689. * @returns The render target texture if the shadow map is present otherwise, null
  65690. */
  65691. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  65692. /**
  65693. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  65694. * @param subMesh The submesh we want to render in the shadow map
  65695. * @param useInstances Defines wether will draw in the map using instances
  65696. * @returns true if ready otherwise, false
  65697. */
  65698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65699. /**
  65700. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65701. * @param defines Defines of the material we want to update
  65702. * @param lightIndex Index of the light in the enabled light list of the material
  65703. */
  65704. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  65705. /**
  65706. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65707. * defined in the generator but impacting the effect).
  65708. * It implies the unifroms available on the materials are the standard BJS ones.
  65709. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65710. * @param effect The effect we are binfing the information for
  65711. */
  65712. bindShadowLight(lightIndex: string, effect: Effect): void;
  65713. /**
  65714. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  65715. * (eq to shadow prjection matrix * light transform matrix)
  65716. * @returns The transform matrix used to create the shadow map
  65717. */
  65718. getTransformMatrix(): Matrix;
  65719. /**
  65720. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  65721. * Cube and 2D textures for instance.
  65722. */
  65723. recreateShadowMap(): void;
  65724. /**
  65725. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65726. * @param onCompiled Callback triggered at the and of the effects compilation
  65727. * @param options Sets of optional options forcing the compilation with different modes
  65728. */
  65729. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  65730. useInstances: boolean;
  65731. }>): void;
  65732. /**
  65733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65734. * @param options Sets of optional options forcing the compilation with different modes
  65735. * @returns A promise that resolves when the compilation completes
  65736. */
  65737. forceCompilationAsync(options?: Partial<{
  65738. useInstances: boolean;
  65739. }>): Promise<void>;
  65740. /**
  65741. * Serializes the shadow generator setup to a json object.
  65742. * @returns The serialized JSON object
  65743. */
  65744. serialize(): any;
  65745. /**
  65746. * Disposes the Shadow map and related Textures and effects.
  65747. */
  65748. dispose(): void;
  65749. }
  65750. /**
  65751. * Default implementation IShadowGenerator.
  65752. * This is the main object responsible of generating shadows in the framework.
  65753. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  65754. */
  65755. export class ShadowGenerator implements IShadowGenerator {
  65756. /**
  65757. * Shadow generator mode None: no filtering applied.
  65758. */
  65759. static readonly FILTER_NONE: number;
  65760. /**
  65761. * Shadow generator mode ESM: Exponential Shadow Mapping.
  65762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65763. */
  65764. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  65765. /**
  65766. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  65767. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  65768. */
  65769. static readonly FILTER_POISSONSAMPLING: number;
  65770. /**
  65771. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  65772. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65773. */
  65774. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  65775. /**
  65776. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  65777. * edge artifacts on steep falloff.
  65778. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65779. */
  65780. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  65781. /**
  65782. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  65783. * edge artifacts on steep falloff.
  65784. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65785. */
  65786. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  65787. /**
  65788. * Shadow generator mode PCF: Percentage Closer Filtering
  65789. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65790. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  65791. */
  65792. static readonly FILTER_PCF: number;
  65793. /**
  65794. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  65795. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65796. * Contact Hardening
  65797. */
  65798. static readonly FILTER_PCSS: number;
  65799. /**
  65800. * Reserved for PCF and PCSS
  65801. * Highest Quality.
  65802. *
  65803. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  65804. *
  65805. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  65806. */
  65807. static readonly QUALITY_HIGH: number;
  65808. /**
  65809. * Reserved for PCF and PCSS
  65810. * Good tradeoff for quality/perf cross devices
  65811. *
  65812. * Execute PCF on a 3*3 kernel.
  65813. *
  65814. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  65815. */
  65816. static readonly QUALITY_MEDIUM: number;
  65817. /**
  65818. * Reserved for PCF and PCSS
  65819. * The lowest quality but the fastest.
  65820. *
  65821. * Execute PCF on a 1*1 kernel.
  65822. *
  65823. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  65824. */
  65825. static readonly QUALITY_LOW: number;
  65826. /** Gets or sets the custom shader name to use */
  65827. customShaderOptions: ICustomShaderOptions;
  65828. /**
  65829. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  65830. */
  65831. onBeforeShadowMapRenderObservable: Observable<Effect>;
  65832. private _bias;
  65833. /**
  65834. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  65835. */
  65836. /**
  65837. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  65838. */
  65839. bias: number;
  65840. private _normalBias;
  65841. /**
  65842. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65843. */
  65844. /**
  65845. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65846. */
  65847. normalBias: number;
  65848. private _blurBoxOffset;
  65849. /**
  65850. * Gets the blur box offset: offset applied during the blur pass.
  65851. * Only useful if useKernelBlur = false
  65852. */
  65853. /**
  65854. * Sets the blur box offset: offset applied during the blur pass.
  65855. * Only useful if useKernelBlur = false
  65856. */
  65857. blurBoxOffset: number;
  65858. private _blurScale;
  65859. /**
  65860. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  65861. * 2 means half of the size.
  65862. */
  65863. /**
  65864. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  65865. * 2 means half of the size.
  65866. */
  65867. blurScale: number;
  65868. private _blurKernel;
  65869. /**
  65870. * Gets the blur kernel: kernel size of the blur pass.
  65871. * Only useful if useKernelBlur = true
  65872. */
  65873. /**
  65874. * Sets the blur kernel: kernel size of the blur pass.
  65875. * Only useful if useKernelBlur = true
  65876. */
  65877. blurKernel: number;
  65878. private _useKernelBlur;
  65879. /**
  65880. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  65881. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65882. */
  65883. /**
  65884. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  65885. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65886. */
  65887. useKernelBlur: boolean;
  65888. private _depthScale;
  65889. /**
  65890. * Gets the depth scale used in ESM mode.
  65891. */
  65892. /**
  65893. * Sets the depth scale used in ESM mode.
  65894. * This can override the scale stored on the light.
  65895. */
  65896. depthScale: number;
  65897. private _filter;
  65898. /**
  65899. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  65900. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65901. */
  65902. /**
  65903. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  65904. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65905. */
  65906. filter: number;
  65907. /**
  65908. * Gets if the current filter is set to Poisson Sampling.
  65909. */
  65910. /**
  65911. * Sets the current filter to Poisson Sampling.
  65912. */
  65913. usePoissonSampling: boolean;
  65914. /**
  65915. * Gets if the current filter is set to ESM.
  65916. */
  65917. /**
  65918. * Sets the current filter is to ESM.
  65919. */
  65920. useExponentialShadowMap: boolean;
  65921. /**
  65922. * Gets if the current filter is set to filtered ESM.
  65923. */
  65924. /**
  65925. * Gets if the current filter is set to filtered ESM.
  65926. */
  65927. useBlurExponentialShadowMap: boolean;
  65928. /**
  65929. * Gets if the current filter is set to "close ESM" (using the inverse of the
  65930. * exponential to prevent steep falloff artifacts).
  65931. */
  65932. /**
  65933. * Sets the current filter to "close ESM" (using the inverse of the
  65934. * exponential to prevent steep falloff artifacts).
  65935. */
  65936. useCloseExponentialShadowMap: boolean;
  65937. /**
  65938. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  65939. * exponential to prevent steep falloff artifacts).
  65940. */
  65941. /**
  65942. * Sets the current filter to filtered "close ESM" (using the inverse of the
  65943. * exponential to prevent steep falloff artifacts).
  65944. */
  65945. useBlurCloseExponentialShadowMap: boolean;
  65946. /**
  65947. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  65948. */
  65949. /**
  65950. * Sets the current filter to "PCF" (percentage closer filtering).
  65951. */
  65952. usePercentageCloserFiltering: boolean;
  65953. private _filteringQuality;
  65954. /**
  65955. * Gets the PCF or PCSS Quality.
  65956. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65957. */
  65958. /**
  65959. * Sets the PCF or PCSS Quality.
  65960. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65961. */
  65962. filteringQuality: number;
  65963. /**
  65964. * Gets if the current filter is set to "PCSS" (contact hardening).
  65965. */
  65966. /**
  65967. * Sets the current filter to "PCSS" (contact hardening).
  65968. */
  65969. useContactHardeningShadow: boolean;
  65970. private _contactHardeningLightSizeUVRatio;
  65971. /**
  65972. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  65973. * Using a ratio helps keeping shape stability independently of the map size.
  65974. *
  65975. * It does not account for the light projection as it was having too much
  65976. * instability during the light setup or during light position changes.
  65977. *
  65978. * Only valid if useContactHardeningShadow is true.
  65979. */
  65980. /**
  65981. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  65982. * Using a ratio helps keeping shape stability independently of the map size.
  65983. *
  65984. * It does not account for the light projection as it was having too much
  65985. * instability during the light setup or during light position changes.
  65986. *
  65987. * Only valid if useContactHardeningShadow is true.
  65988. */
  65989. contactHardeningLightSizeUVRatio: number;
  65990. private _darkness;
  65991. /**
  65992. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  65993. * 0 means strongest and 1 would means no shadow.
  65994. * @returns the darkness.
  65995. */
  65996. getDarkness(): number;
  65997. /**
  65998. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  65999. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66000. * @returns the shadow generator allowing fluent coding.
  66001. */
  66002. setDarkness(darkness: number): ShadowGenerator;
  66003. private _transparencyShadow;
  66004. /**
  66005. * Sets the ability to have transparent shadow (boolean).
  66006. * @param transparent True if transparent else False
  66007. * @returns the shadow generator allowing fluent coding
  66008. */
  66009. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66010. private _shadowMap;
  66011. private _shadowMap2;
  66012. /**
  66013. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66014. * @returns The render target texture if present otherwise, null
  66015. */
  66016. getShadowMap(): Nullable<RenderTargetTexture>;
  66017. /**
  66018. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66019. * @returns The render target texture if the shadow map is present otherwise, null
  66020. */
  66021. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66022. /**
  66023. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66024. * @param mesh Mesh to add
  66025. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66026. * @returns the Shadow Generator itself
  66027. */
  66028. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66029. /**
  66030. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66031. * @param mesh Mesh to remove
  66032. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66033. * @returns the Shadow Generator itself
  66034. */
  66035. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66036. /**
  66037. * Controls the extent to which the shadows fade out at the edge of the frustum
  66038. * Used only by directionals and spots
  66039. */
  66040. frustumEdgeFalloff: number;
  66041. private _light;
  66042. /**
  66043. * Returns the associated light object.
  66044. * @returns the light generating the shadow
  66045. */
  66046. getLight(): IShadowLight;
  66047. /**
  66048. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66049. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66050. * It might on the other hand introduce peter panning.
  66051. */
  66052. forceBackFacesOnly: boolean;
  66053. private _scene;
  66054. private _lightDirection;
  66055. private _effect;
  66056. private _viewMatrix;
  66057. private _projectionMatrix;
  66058. private _transformMatrix;
  66059. private _cachedPosition;
  66060. private _cachedDirection;
  66061. private _cachedDefines;
  66062. private _currentRenderID;
  66063. private _boxBlurPostprocess;
  66064. private _kernelBlurXPostprocess;
  66065. private _kernelBlurYPostprocess;
  66066. private _blurPostProcesses;
  66067. private _mapSize;
  66068. private _currentFaceIndex;
  66069. private _currentFaceIndexCache;
  66070. private _textureType;
  66071. private _defaultTextureMatrix;
  66072. /** @hidden */
  66073. static _SceneComponentInitialization: (scene: Scene) => void;
  66074. /**
  66075. * Creates a ShadowGenerator object.
  66076. * A ShadowGenerator is the required tool to use the shadows.
  66077. * Each light casting shadows needs to use its own ShadowGenerator.
  66078. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66079. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66080. * @param light The light object generating the shadows.
  66081. * @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.
  66082. */
  66083. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66084. private _initializeGenerator;
  66085. private _initializeShadowMap;
  66086. private _initializeBlurRTTAndPostProcesses;
  66087. private _renderForShadowMap;
  66088. private _renderSubMeshForShadowMap;
  66089. private _applyFilterValues;
  66090. /**
  66091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66092. * @param onCompiled Callback triggered at the and of the effects compilation
  66093. * @param options Sets of optional options forcing the compilation with different modes
  66094. */
  66095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66096. useInstances: boolean;
  66097. }>): void;
  66098. /**
  66099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66100. * @param options Sets of optional options forcing the compilation with different modes
  66101. * @returns A promise that resolves when the compilation completes
  66102. */
  66103. forceCompilationAsync(options?: Partial<{
  66104. useInstances: boolean;
  66105. }>): Promise<void>;
  66106. /**
  66107. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66108. * @param subMesh The submesh we want to render in the shadow map
  66109. * @param useInstances Defines wether will draw in the map using instances
  66110. * @returns true if ready otherwise, false
  66111. */
  66112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66113. /**
  66114. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66115. * @param defines Defines of the material we want to update
  66116. * @param lightIndex Index of the light in the enabled light list of the material
  66117. */
  66118. prepareDefines(defines: any, lightIndex: number): void;
  66119. /**
  66120. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66121. * defined in the generator but impacting the effect).
  66122. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66123. * @param effect The effect we are binfing the information for
  66124. */
  66125. bindShadowLight(lightIndex: string, effect: Effect): void;
  66126. /**
  66127. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66128. * (eq to shadow prjection matrix * light transform matrix)
  66129. * @returns The transform matrix used to create the shadow map
  66130. */
  66131. getTransformMatrix(): Matrix;
  66132. /**
  66133. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66134. * Cube and 2D textures for instance.
  66135. */
  66136. recreateShadowMap(): void;
  66137. private _disposeBlurPostProcesses;
  66138. private _disposeRTTandPostProcesses;
  66139. /**
  66140. * Disposes the ShadowGenerator.
  66141. * Returns nothing.
  66142. */
  66143. dispose(): void;
  66144. /**
  66145. * Serializes the shadow generator setup to a json object.
  66146. * @returns The serialized JSON object
  66147. */
  66148. serialize(): any;
  66149. /**
  66150. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66151. * @param parsedShadowGenerator The JSON object to parse
  66152. * @param scene The scene to create the shadow map for
  66153. * @returns The parsed shadow generator
  66154. */
  66155. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66156. }
  66157. }
  66158. declare module BABYLON {
  66159. /**
  66160. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66161. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66162. * 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.
  66163. */
  66164. export abstract class Light extends Node {
  66165. /**
  66166. * Falloff Default: light is falling off following the material specification:
  66167. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66168. */
  66169. static readonly FALLOFF_DEFAULT: number;
  66170. /**
  66171. * Falloff Physical: light is falling off following the inverse squared distance law.
  66172. */
  66173. static readonly FALLOFF_PHYSICAL: number;
  66174. /**
  66175. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66176. * to enhance interoperability with other engines.
  66177. */
  66178. static readonly FALLOFF_GLTF: number;
  66179. /**
  66180. * Falloff Standard: light is falling off like in the standard material
  66181. * to enhance interoperability with other materials.
  66182. */
  66183. static readonly FALLOFF_STANDARD: number;
  66184. /**
  66185. * If every light affecting the material is in this lightmapMode,
  66186. * material.lightmapTexture adds or multiplies
  66187. * (depends on material.useLightmapAsShadowmap)
  66188. * after every other light calculations.
  66189. */
  66190. static readonly LIGHTMAP_DEFAULT: number;
  66191. /**
  66192. * material.lightmapTexture as only diffuse lighting from this light
  66193. * adds only specular lighting from this light
  66194. * adds dynamic shadows
  66195. */
  66196. static readonly LIGHTMAP_SPECULAR: number;
  66197. /**
  66198. * material.lightmapTexture as only lighting
  66199. * no light calculation from this light
  66200. * only adds dynamic shadows from this light
  66201. */
  66202. static readonly LIGHTMAP_SHADOWSONLY: number;
  66203. /**
  66204. * Each light type uses the default quantity according to its type:
  66205. * point/spot lights use luminous intensity
  66206. * directional lights use illuminance
  66207. */
  66208. static readonly INTENSITYMODE_AUTOMATIC: number;
  66209. /**
  66210. * lumen (lm)
  66211. */
  66212. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66213. /**
  66214. * candela (lm/sr)
  66215. */
  66216. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66217. /**
  66218. * lux (lm/m^2)
  66219. */
  66220. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66221. /**
  66222. * nit (cd/m^2)
  66223. */
  66224. static readonly INTENSITYMODE_LUMINANCE: number;
  66225. /**
  66226. * Light type const id of the point light.
  66227. */
  66228. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66229. /**
  66230. * Light type const id of the directional light.
  66231. */
  66232. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66233. /**
  66234. * Light type const id of the spot light.
  66235. */
  66236. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66237. /**
  66238. * Light type const id of the hemispheric light.
  66239. */
  66240. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66241. /**
  66242. * Diffuse gives the basic color to an object.
  66243. */
  66244. diffuse: Color3;
  66245. /**
  66246. * Specular produces a highlight color on an object.
  66247. * Note: This is note affecting PBR materials.
  66248. */
  66249. specular: Color3;
  66250. /**
  66251. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66252. * falling off base on range or angle.
  66253. * This can be set to any values in Light.FALLOFF_x.
  66254. *
  66255. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66256. * other types of materials.
  66257. */
  66258. falloffType: number;
  66259. /**
  66260. * Strength of the light.
  66261. * Note: By default it is define in the framework own unit.
  66262. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66263. */
  66264. intensity: number;
  66265. private _range;
  66266. protected _inverseSquaredRange: number;
  66267. /**
  66268. * Defines how far from the source the light is impacting in scene units.
  66269. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66270. */
  66271. /**
  66272. * Defines how far from the source the light is impacting in scene units.
  66273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66274. */
  66275. range: number;
  66276. /**
  66277. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66278. * of light.
  66279. */
  66280. private _photometricScale;
  66281. private _intensityMode;
  66282. /**
  66283. * Gets the photometric scale used to interpret the intensity.
  66284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66285. */
  66286. /**
  66287. * Sets the photometric scale used to interpret the intensity.
  66288. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66289. */
  66290. intensityMode: number;
  66291. private _radius;
  66292. /**
  66293. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66294. */
  66295. /**
  66296. * sets the light radius used by PBR Materials to simulate soft area lights.
  66297. */
  66298. radius: number;
  66299. private _renderPriority;
  66300. /**
  66301. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66302. * exceeding the number allowed of the materials.
  66303. */
  66304. renderPriority: number;
  66305. private _shadowEnabled;
  66306. /**
  66307. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66308. * the current shadow generator.
  66309. */
  66310. /**
  66311. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66312. * the current shadow generator.
  66313. */
  66314. shadowEnabled: boolean;
  66315. private _includedOnlyMeshes;
  66316. /**
  66317. * Gets the only meshes impacted by this light.
  66318. */
  66319. /**
  66320. * Sets the only meshes impacted by this light.
  66321. */
  66322. includedOnlyMeshes: AbstractMesh[];
  66323. private _excludedMeshes;
  66324. /**
  66325. * Gets the meshes not impacted by this light.
  66326. */
  66327. /**
  66328. * Sets the meshes not impacted by this light.
  66329. */
  66330. excludedMeshes: AbstractMesh[];
  66331. private _excludeWithLayerMask;
  66332. /**
  66333. * Gets the layer id use to find what meshes are not impacted by the light.
  66334. * Inactive if 0
  66335. */
  66336. /**
  66337. * Sets the layer id use to find what meshes are not impacted by the light.
  66338. * Inactive if 0
  66339. */
  66340. excludeWithLayerMask: number;
  66341. private _includeOnlyWithLayerMask;
  66342. /**
  66343. * Gets the layer id use to find what meshes are impacted by the light.
  66344. * Inactive if 0
  66345. */
  66346. /**
  66347. * Sets the layer id use to find what meshes are impacted by the light.
  66348. * Inactive if 0
  66349. */
  66350. includeOnlyWithLayerMask: number;
  66351. private _lightmapMode;
  66352. /**
  66353. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66354. */
  66355. /**
  66356. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66357. */
  66358. lightmapMode: number;
  66359. /**
  66360. * Shadow generator associted to the light.
  66361. * @hidden Internal use only.
  66362. */
  66363. _shadowGenerator: Nullable<IShadowGenerator>;
  66364. /**
  66365. * @hidden Internal use only.
  66366. */
  66367. _excludedMeshesIds: string[];
  66368. /**
  66369. * @hidden Internal use only.
  66370. */
  66371. _includedOnlyMeshesIds: string[];
  66372. /**
  66373. * The current light unifom buffer.
  66374. * @hidden Internal use only.
  66375. */
  66376. _uniformBuffer: UniformBuffer;
  66377. /**
  66378. * Creates a Light object in the scene.
  66379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66380. * @param name The firendly name of the light
  66381. * @param scene The scene the light belongs too
  66382. */
  66383. constructor(name: string, scene: Scene);
  66384. protected abstract _buildUniformLayout(): void;
  66385. /**
  66386. * Sets the passed Effect "effect" with the Light information.
  66387. * @param effect The effect to update
  66388. * @param lightIndex The index of the light in the effect to update
  66389. * @returns The light
  66390. */
  66391. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  66392. /**
  66393. * Returns the string "Light".
  66394. * @returns the class name
  66395. */
  66396. getClassName(): string;
  66397. /** @hidden */
  66398. readonly _isLight: boolean;
  66399. /**
  66400. * Converts the light information to a readable string for debug purpose.
  66401. * @param fullDetails Supports for multiple levels of logging within scene loading
  66402. * @returns the human readable light info
  66403. */
  66404. toString(fullDetails?: boolean): string;
  66405. /** @hidden */
  66406. protected _syncParentEnabledState(): void;
  66407. /**
  66408. * Set the enabled state of this node.
  66409. * @param value - the new enabled state
  66410. */
  66411. setEnabled(value: boolean): void;
  66412. /**
  66413. * Returns the Light associated shadow generator if any.
  66414. * @return the associated shadow generator.
  66415. */
  66416. getShadowGenerator(): Nullable<IShadowGenerator>;
  66417. /**
  66418. * Returns a Vector3, the absolute light position in the World.
  66419. * @returns the world space position of the light
  66420. */
  66421. getAbsolutePosition(): Vector3;
  66422. /**
  66423. * Specifies if the light will affect the passed mesh.
  66424. * @param mesh The mesh to test against the light
  66425. * @return true the mesh is affected otherwise, false.
  66426. */
  66427. canAffectMesh(mesh: AbstractMesh): boolean;
  66428. /**
  66429. * Sort function to order lights for rendering.
  66430. * @param a First Light object to compare to second.
  66431. * @param b Second Light object to compare first.
  66432. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  66433. */
  66434. static CompareLightsPriority(a: Light, b: Light): number;
  66435. /**
  66436. * Releases resources associated with this node.
  66437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66439. */
  66440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66441. /**
  66442. * Returns the light type ID (integer).
  66443. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  66444. */
  66445. getTypeID(): number;
  66446. /**
  66447. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  66448. * @returns the scaled intensity in intensity mode unit
  66449. */
  66450. getScaledIntensity(): number;
  66451. /**
  66452. * Returns a new Light object, named "name", from the current one.
  66453. * @param name The name of the cloned light
  66454. * @returns the new created light
  66455. */
  66456. clone(name: string): Nullable<Light>;
  66457. /**
  66458. * Serializes the current light into a Serialization object.
  66459. * @returns the serialized object.
  66460. */
  66461. serialize(): any;
  66462. /**
  66463. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  66464. * This new light is named "name" and added to the passed scene.
  66465. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  66466. * @param name The friendly name of the light
  66467. * @param scene The scene the new light will belong to
  66468. * @returns the constructor function
  66469. */
  66470. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  66471. /**
  66472. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  66473. * @param parsedLight The JSON representation of the light
  66474. * @param scene The scene to create the parsed light in
  66475. * @returns the created light after parsing
  66476. */
  66477. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  66478. private _hookArrayForExcluded;
  66479. private _hookArrayForIncludedOnly;
  66480. private _resyncMeshes;
  66481. /**
  66482. * Forces the meshes to update their light related information in their rendering used effects
  66483. * @hidden Internal Use Only
  66484. */
  66485. _markMeshesAsLightDirty(): void;
  66486. /**
  66487. * Recomputes the cached photometric scale if needed.
  66488. */
  66489. private _computePhotometricScale;
  66490. /**
  66491. * Returns the Photometric Scale according to the light type and intensity mode.
  66492. */
  66493. private _getPhotometricScale;
  66494. /**
  66495. * Reorder the light in the scene according to their defined priority.
  66496. * @hidden Internal Use Only
  66497. */
  66498. _reorderLightsInScene(): void;
  66499. /**
  66500. * Prepares the list of defines specific to the light type.
  66501. * @param defines the list of defines
  66502. * @param lightIndex defines the index of the light for the effect
  66503. */
  66504. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  66505. }
  66506. }
  66507. declare module BABYLON {
  66508. /**
  66509. * Interface used to define Action
  66510. */
  66511. export interface IAction {
  66512. /**
  66513. * Trigger for the action
  66514. */
  66515. trigger: number;
  66516. /** the trigger, with or without parameters, for the action */
  66517. triggerOptions: any;
  66518. /**
  66519. * Gets the trigger parameters
  66520. * @returns the trigger parameters
  66521. */
  66522. getTriggerParameter(): any;
  66523. /**
  66524. * Internal only - executes current action event
  66525. * @hidden
  66526. */
  66527. _executeCurrent(evt?: ActionEvent): void;
  66528. /**
  66529. * Serialize placeholder for child classes
  66530. * @param parent of child
  66531. * @returns the serialized object
  66532. */
  66533. serialize(parent: any): any;
  66534. }
  66535. /**
  66536. * The action to be carried out following a trigger
  66537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  66538. */
  66539. export class Action implements IAction {
  66540. /** the trigger, with or without parameters, for the action */
  66541. triggerOptions: any;
  66542. /**
  66543. * Trigger for the action
  66544. */
  66545. trigger: number;
  66546. /**
  66547. * Internal only - manager for action
  66548. * @hidden
  66549. */
  66550. _actionManager: ActionManager;
  66551. private _nextActiveAction;
  66552. private _child;
  66553. private _condition?;
  66554. private _triggerParameter;
  66555. /**
  66556. * An event triggered prior to action being executed.
  66557. */
  66558. onBeforeExecuteObservable: Observable<Action>;
  66559. /**
  66560. * Creates a new Action
  66561. * @param triggerOptions the trigger, with or without parameters, for the action
  66562. * @param condition an optional determinant of action
  66563. */
  66564. constructor(
  66565. /** the trigger, with or without parameters, for the action */
  66566. triggerOptions: any, condition?: Condition);
  66567. /**
  66568. * Internal only
  66569. * @hidden
  66570. */
  66571. _prepare(): void;
  66572. /**
  66573. * Gets the trigger parameters
  66574. * @returns the trigger parameters
  66575. */
  66576. getTriggerParameter(): any;
  66577. /**
  66578. * Internal only - executes current action event
  66579. * @hidden
  66580. */
  66581. _executeCurrent(evt?: ActionEvent): void;
  66582. /**
  66583. * Execute placeholder for child classes
  66584. * @param evt optional action event
  66585. */
  66586. execute(evt?: ActionEvent): void;
  66587. /**
  66588. * Skips to next active action
  66589. */
  66590. skipToNextActiveAction(): void;
  66591. /**
  66592. * Adds action to chain of actions, may be a DoNothingAction
  66593. * @param action defines the next action to execute
  66594. * @returns The action passed in
  66595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  66596. */
  66597. then(action: Action): Action;
  66598. /**
  66599. * Internal only
  66600. * @hidden
  66601. */
  66602. _getProperty(propertyPath: string): string;
  66603. /**
  66604. * Internal only
  66605. * @hidden
  66606. */
  66607. _getEffectiveTarget(target: any, propertyPath: string): any;
  66608. /**
  66609. * Serialize placeholder for child classes
  66610. * @param parent of child
  66611. * @returns the serialized object
  66612. */
  66613. serialize(parent: any): any;
  66614. /**
  66615. * Internal only called by serialize
  66616. * @hidden
  66617. */
  66618. protected _serialize(serializedAction: any, parent?: any): any;
  66619. /**
  66620. * Internal only
  66621. * @hidden
  66622. */
  66623. static _SerializeValueAsString: (value: any) => string;
  66624. /**
  66625. * Internal only
  66626. * @hidden
  66627. */
  66628. static _GetTargetProperty: (target: Scene | Node) => {
  66629. name: string;
  66630. targetType: string;
  66631. value: string;
  66632. };
  66633. }
  66634. }
  66635. declare module BABYLON {
  66636. /**
  66637. * A Condition applied to an Action
  66638. */
  66639. export class Condition {
  66640. /**
  66641. * Internal only - manager for action
  66642. * @hidden
  66643. */
  66644. _actionManager: ActionManager;
  66645. /**
  66646. * Internal only
  66647. * @hidden
  66648. */
  66649. _evaluationId: number;
  66650. /**
  66651. * Internal only
  66652. * @hidden
  66653. */
  66654. _currentResult: boolean;
  66655. /**
  66656. * Creates a new Condition
  66657. * @param actionManager the manager of the action the condition is applied to
  66658. */
  66659. constructor(actionManager: ActionManager);
  66660. /**
  66661. * Check if the current condition is valid
  66662. * @returns a boolean
  66663. */
  66664. isValid(): boolean;
  66665. /**
  66666. * Internal only
  66667. * @hidden
  66668. */
  66669. _getProperty(propertyPath: string): string;
  66670. /**
  66671. * Internal only
  66672. * @hidden
  66673. */
  66674. _getEffectiveTarget(target: any, propertyPath: string): any;
  66675. /**
  66676. * Serialize placeholder for child classes
  66677. * @returns the serialized object
  66678. */
  66679. serialize(): any;
  66680. /**
  66681. * Internal only
  66682. * @hidden
  66683. */
  66684. protected _serialize(serializedCondition: any): any;
  66685. }
  66686. /**
  66687. * Defines specific conditional operators as extensions of Condition
  66688. */
  66689. export class ValueCondition extends Condition {
  66690. /** path to specify the property of the target the conditional operator uses */
  66691. propertyPath: string;
  66692. /** the value compared by the conditional operator against the current value of the property */
  66693. value: any;
  66694. /** the conditional operator, default ValueCondition.IsEqual */
  66695. operator: number;
  66696. /**
  66697. * Internal only
  66698. * @hidden
  66699. */
  66700. private static _IsEqual;
  66701. /**
  66702. * Internal only
  66703. * @hidden
  66704. */
  66705. private static _IsDifferent;
  66706. /**
  66707. * Internal only
  66708. * @hidden
  66709. */
  66710. private static _IsGreater;
  66711. /**
  66712. * Internal only
  66713. * @hidden
  66714. */
  66715. private static _IsLesser;
  66716. /**
  66717. * returns the number for IsEqual
  66718. */
  66719. static readonly IsEqual: number;
  66720. /**
  66721. * Returns the number for IsDifferent
  66722. */
  66723. static readonly IsDifferent: number;
  66724. /**
  66725. * Returns the number for IsGreater
  66726. */
  66727. static readonly IsGreater: number;
  66728. /**
  66729. * Returns the number for IsLesser
  66730. */
  66731. static readonly IsLesser: number;
  66732. /**
  66733. * Internal only The action manager for the condition
  66734. * @hidden
  66735. */
  66736. _actionManager: ActionManager;
  66737. /**
  66738. * Internal only
  66739. * @hidden
  66740. */
  66741. private _target;
  66742. /**
  66743. * Internal only
  66744. * @hidden
  66745. */
  66746. private _effectiveTarget;
  66747. /**
  66748. * Internal only
  66749. * @hidden
  66750. */
  66751. private _property;
  66752. /**
  66753. * Creates a new ValueCondition
  66754. * @param actionManager manager for the action the condition applies to
  66755. * @param target for the action
  66756. * @param propertyPath path to specify the property of the target the conditional operator uses
  66757. * @param value the value compared by the conditional operator against the current value of the property
  66758. * @param operator the conditional operator, default ValueCondition.IsEqual
  66759. */
  66760. constructor(actionManager: ActionManager, target: any,
  66761. /** path to specify the property of the target the conditional operator uses */
  66762. propertyPath: string,
  66763. /** the value compared by the conditional operator against the current value of the property */
  66764. value: any,
  66765. /** the conditional operator, default ValueCondition.IsEqual */
  66766. operator?: number);
  66767. /**
  66768. * Compares the given value with the property value for the specified conditional operator
  66769. * @returns the result of the comparison
  66770. */
  66771. isValid(): boolean;
  66772. /**
  66773. * Serialize the ValueCondition into a JSON compatible object
  66774. * @returns serialization object
  66775. */
  66776. serialize(): any;
  66777. /**
  66778. * Gets the name of the conditional operator for the ValueCondition
  66779. * @param operator the conditional operator
  66780. * @returns the name
  66781. */
  66782. static GetOperatorName(operator: number): string;
  66783. }
  66784. /**
  66785. * Defines a predicate condition as an extension of Condition
  66786. */
  66787. export class PredicateCondition extends Condition {
  66788. /** defines the predicate function used to validate the condition */
  66789. predicate: () => boolean;
  66790. /**
  66791. * Internal only - manager for action
  66792. * @hidden
  66793. */
  66794. _actionManager: ActionManager;
  66795. /**
  66796. * Creates a new PredicateCondition
  66797. * @param actionManager manager for the action the condition applies to
  66798. * @param predicate defines the predicate function used to validate the condition
  66799. */
  66800. constructor(actionManager: ActionManager,
  66801. /** defines the predicate function used to validate the condition */
  66802. predicate: () => boolean);
  66803. /**
  66804. * @returns the validity of the predicate condition
  66805. */
  66806. isValid(): boolean;
  66807. }
  66808. /**
  66809. * Defines a state condition as an extension of Condition
  66810. */
  66811. export class StateCondition extends Condition {
  66812. /** Value to compare with target state */
  66813. value: string;
  66814. /**
  66815. * Internal only - manager for action
  66816. * @hidden
  66817. */
  66818. _actionManager: ActionManager;
  66819. /**
  66820. * Internal only
  66821. * @hidden
  66822. */
  66823. private _target;
  66824. /**
  66825. * Creates a new StateCondition
  66826. * @param actionManager manager for the action the condition applies to
  66827. * @param target of the condition
  66828. * @param value to compare with target state
  66829. */
  66830. constructor(actionManager: ActionManager, target: any,
  66831. /** Value to compare with target state */
  66832. value: string);
  66833. /**
  66834. * Gets a boolean indicating if the current condition is met
  66835. * @returns the validity of the state
  66836. */
  66837. isValid(): boolean;
  66838. /**
  66839. * Serialize the StateCondition into a JSON compatible object
  66840. * @returns serialization object
  66841. */
  66842. serialize(): any;
  66843. }
  66844. }
  66845. declare module BABYLON {
  66846. /**
  66847. * This defines an action responsible to toggle a boolean once triggered.
  66848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66849. */
  66850. export class SwitchBooleanAction extends Action {
  66851. /**
  66852. * The path to the boolean property in the target object
  66853. */
  66854. propertyPath: string;
  66855. private _target;
  66856. private _effectiveTarget;
  66857. private _property;
  66858. /**
  66859. * Instantiate the action
  66860. * @param triggerOptions defines the trigger options
  66861. * @param target defines the object containing the boolean
  66862. * @param propertyPath defines the path to the boolean property in the target object
  66863. * @param condition defines the trigger related conditions
  66864. */
  66865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  66866. /** @hidden */
  66867. _prepare(): void;
  66868. /**
  66869. * Execute the action toggle the boolean value.
  66870. */
  66871. execute(): void;
  66872. /**
  66873. * Serializes the actions and its related information.
  66874. * @param parent defines the object to serialize in
  66875. * @returns the serialized object
  66876. */
  66877. serialize(parent: any): any;
  66878. }
  66879. /**
  66880. * This defines an action responsible to set a the state field of the target
  66881. * to a desired value once triggered.
  66882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66883. */
  66884. export class SetStateAction extends Action {
  66885. /**
  66886. * The value to store in the state field.
  66887. */
  66888. value: string;
  66889. private _target;
  66890. /**
  66891. * Instantiate the action
  66892. * @param triggerOptions defines the trigger options
  66893. * @param target defines the object containing the state property
  66894. * @param value defines the value to store in the state field
  66895. * @param condition defines the trigger related conditions
  66896. */
  66897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  66898. /**
  66899. * Execute the action and store the value on the target state property.
  66900. */
  66901. execute(): void;
  66902. /**
  66903. * Serializes the actions and its related information.
  66904. * @param parent defines the object to serialize in
  66905. * @returns the serialized object
  66906. */
  66907. serialize(parent: any): any;
  66908. }
  66909. /**
  66910. * This defines an action responsible to set a property of the target
  66911. * to a desired value once triggered.
  66912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66913. */
  66914. export class SetValueAction extends Action {
  66915. /**
  66916. * The path of the property to set in the target.
  66917. */
  66918. propertyPath: string;
  66919. /**
  66920. * The value to set in the property
  66921. */
  66922. value: any;
  66923. private _target;
  66924. private _effectiveTarget;
  66925. private _property;
  66926. /**
  66927. * Instantiate the action
  66928. * @param triggerOptions defines the trigger options
  66929. * @param target defines the object containing the property
  66930. * @param propertyPath defines the path of the property to set in the target
  66931. * @param value defines the value to set in the property
  66932. * @param condition defines the trigger related conditions
  66933. */
  66934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66935. /** @hidden */
  66936. _prepare(): void;
  66937. /**
  66938. * Execute the action and set the targetted property to the desired value.
  66939. */
  66940. execute(): void;
  66941. /**
  66942. * Serializes the actions and its related information.
  66943. * @param parent defines the object to serialize in
  66944. * @returns the serialized object
  66945. */
  66946. serialize(parent: any): any;
  66947. }
  66948. /**
  66949. * This defines an action responsible to increment the target value
  66950. * to a desired value once triggered.
  66951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66952. */
  66953. export class IncrementValueAction extends Action {
  66954. /**
  66955. * The path of the property to increment in the target.
  66956. */
  66957. propertyPath: string;
  66958. /**
  66959. * The value we should increment the property by.
  66960. */
  66961. value: any;
  66962. private _target;
  66963. private _effectiveTarget;
  66964. private _property;
  66965. /**
  66966. * Instantiate the action
  66967. * @param triggerOptions defines the trigger options
  66968. * @param target defines the object containing the property
  66969. * @param propertyPath defines the path of the property to increment in the target
  66970. * @param value defines the value value we should increment the property by
  66971. * @param condition defines the trigger related conditions
  66972. */
  66973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66974. /** @hidden */
  66975. _prepare(): void;
  66976. /**
  66977. * Execute the action and increment the target of the value amount.
  66978. */
  66979. execute(): void;
  66980. /**
  66981. * Serializes the actions and its related information.
  66982. * @param parent defines the object to serialize in
  66983. * @returns the serialized object
  66984. */
  66985. serialize(parent: any): any;
  66986. }
  66987. /**
  66988. * This defines an action responsible to start an animation once triggered.
  66989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66990. */
  66991. export class PlayAnimationAction extends Action {
  66992. /**
  66993. * Where the animation should start (animation frame)
  66994. */
  66995. from: number;
  66996. /**
  66997. * Where the animation should stop (animation frame)
  66998. */
  66999. to: number;
  67000. /**
  67001. * Define if the animation should loop or stop after the first play.
  67002. */
  67003. loop?: boolean;
  67004. private _target;
  67005. /**
  67006. * Instantiate the action
  67007. * @param triggerOptions defines the trigger options
  67008. * @param target defines the target animation or animation name
  67009. * @param from defines from where the animation should start (animation frame)
  67010. * @param end defines where the animation should stop (animation frame)
  67011. * @param loop defines if the animation should loop or stop after the first play
  67012. * @param condition defines the trigger related conditions
  67013. */
  67014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67015. /** @hidden */
  67016. _prepare(): void;
  67017. /**
  67018. * Execute the action and play the animation.
  67019. */
  67020. execute(): void;
  67021. /**
  67022. * Serializes the actions and its related information.
  67023. * @param parent defines the object to serialize in
  67024. * @returns the serialized object
  67025. */
  67026. serialize(parent: any): any;
  67027. }
  67028. /**
  67029. * This defines an action responsible to stop an animation once triggered.
  67030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67031. */
  67032. export class StopAnimationAction extends Action {
  67033. private _target;
  67034. /**
  67035. * Instantiate the action
  67036. * @param triggerOptions defines the trigger options
  67037. * @param target defines the target animation or animation name
  67038. * @param condition defines the trigger related conditions
  67039. */
  67040. constructor(triggerOptions: any, target: any, condition?: Condition);
  67041. /** @hidden */
  67042. _prepare(): void;
  67043. /**
  67044. * Execute the action and stop the animation.
  67045. */
  67046. execute(): void;
  67047. /**
  67048. * Serializes the actions and its related information.
  67049. * @param parent defines the object to serialize in
  67050. * @returns the serialized object
  67051. */
  67052. serialize(parent: any): any;
  67053. }
  67054. /**
  67055. * This defines an action responsible that does nothing once triggered.
  67056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67057. */
  67058. export class DoNothingAction extends Action {
  67059. /**
  67060. * Instantiate the action
  67061. * @param triggerOptions defines the trigger options
  67062. * @param condition defines the trigger related conditions
  67063. */
  67064. constructor(triggerOptions?: any, condition?: Condition);
  67065. /**
  67066. * Execute the action and do nothing.
  67067. */
  67068. execute(): void;
  67069. /**
  67070. * Serializes the actions and its related information.
  67071. * @param parent defines the object to serialize in
  67072. * @returns the serialized object
  67073. */
  67074. serialize(parent: any): any;
  67075. }
  67076. /**
  67077. * This defines an action responsible to trigger several actions once triggered.
  67078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67079. */
  67080. export class CombineAction extends Action {
  67081. /**
  67082. * The list of aggregated animations to run.
  67083. */
  67084. children: Action[];
  67085. /**
  67086. * Instantiate the action
  67087. * @param triggerOptions defines the trigger options
  67088. * @param children defines the list of aggregated animations to run
  67089. * @param condition defines the trigger related conditions
  67090. */
  67091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67092. /** @hidden */
  67093. _prepare(): void;
  67094. /**
  67095. * Execute the action and executes all the aggregated actions.
  67096. */
  67097. execute(evt: ActionEvent): void;
  67098. /**
  67099. * Serializes the actions and its related information.
  67100. * @param parent defines the object to serialize in
  67101. * @returns the serialized object
  67102. */
  67103. serialize(parent: any): any;
  67104. }
  67105. /**
  67106. * This defines an action responsible to run code (external event) once triggered.
  67107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67108. */
  67109. export class ExecuteCodeAction extends Action {
  67110. /**
  67111. * The callback function to run.
  67112. */
  67113. func: (evt: ActionEvent) => void;
  67114. /**
  67115. * Instantiate the action
  67116. * @param triggerOptions defines the trigger options
  67117. * @param func defines the callback function to run
  67118. * @param condition defines the trigger related conditions
  67119. */
  67120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67121. /**
  67122. * Execute the action and run the attached code.
  67123. */
  67124. execute(evt: ActionEvent): void;
  67125. }
  67126. /**
  67127. * This defines an action responsible to set the parent property of the target once triggered.
  67128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67129. */
  67130. export class SetParentAction extends Action {
  67131. private _parent;
  67132. private _target;
  67133. /**
  67134. * Instantiate the action
  67135. * @param triggerOptions defines the trigger options
  67136. * @param target defines the target containing the parent property
  67137. * @param parent defines from where the animation should start (animation frame)
  67138. * @param condition defines the trigger related conditions
  67139. */
  67140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67141. /** @hidden */
  67142. _prepare(): void;
  67143. /**
  67144. * Execute the action and set the parent property.
  67145. */
  67146. execute(): void;
  67147. /**
  67148. * Serializes the actions and its related information.
  67149. * @param parent defines the object to serialize in
  67150. * @returns the serialized object
  67151. */
  67152. serialize(parent: any): any;
  67153. }
  67154. }
  67155. declare module BABYLON {
  67156. /**
  67157. * Abstract class used to decouple action Manager from scene and meshes.
  67158. * Do not instantiate.
  67159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67160. */
  67161. export abstract class AbstractActionManager implements IDisposable {
  67162. /** Gets the list of active triggers */
  67163. static Triggers: {
  67164. [key: string]: number;
  67165. };
  67166. /** Gets the cursor to use when hovering items */
  67167. hoverCursor: string;
  67168. /** Gets the list of actions */
  67169. actions: IAction[];
  67170. /**
  67171. * Releases all associated resources
  67172. */
  67173. abstract dispose(): void;
  67174. /**
  67175. * Does this action manager has pointer triggers
  67176. */
  67177. abstract readonly hasPointerTriggers: boolean;
  67178. /**
  67179. * Does this action manager has pick triggers
  67180. */
  67181. abstract readonly hasPickTriggers: boolean;
  67182. /**
  67183. * Process a specific trigger
  67184. * @param trigger defines the trigger to process
  67185. * @param evt defines the event details to be processed
  67186. */
  67187. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  67188. /**
  67189. * Does this action manager handles actions of any of the given triggers
  67190. * @param triggers defines the triggers to be tested
  67191. * @return a boolean indicating whether one (or more) of the triggers is handled
  67192. */
  67193. abstract hasSpecificTriggers(triggers: number[]): boolean;
  67194. /**
  67195. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67196. * speed.
  67197. * @param triggerA defines the trigger to be tested
  67198. * @param triggerB defines the trigger to be tested
  67199. * @return a boolean indicating whether one (or more) of the triggers is handled
  67200. */
  67201. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67202. /**
  67203. * Does this action manager handles actions of a given trigger
  67204. * @param trigger defines the trigger to be tested
  67205. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67206. * @return whether the trigger is handled
  67207. */
  67208. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67209. /**
  67210. * Serialize this manager to a JSON object
  67211. * @param name defines the property name to store this manager
  67212. * @returns a JSON representation of this manager
  67213. */
  67214. abstract serialize(name: string): any;
  67215. /**
  67216. * Does exist one action manager with at least one trigger
  67217. **/
  67218. static readonly HasTriggers: boolean;
  67219. /**
  67220. * Does exist one action manager with at least one pick trigger
  67221. **/
  67222. static readonly HasPickTriggers: boolean;
  67223. /**
  67224. * Does exist one action manager that handles actions of a given trigger
  67225. * @param trigger defines the trigger to be tested
  67226. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  67227. **/
  67228. static HasSpecificTrigger(trigger: number): boolean;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67234. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67236. */
  67237. export class ActionManager extends AbstractActionManager {
  67238. /**
  67239. * Nothing
  67240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67241. */
  67242. static readonly NothingTrigger: number;
  67243. /**
  67244. * On pick
  67245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67246. */
  67247. static readonly OnPickTrigger: number;
  67248. /**
  67249. * On left pick
  67250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67251. */
  67252. static readonly OnLeftPickTrigger: number;
  67253. /**
  67254. * On right pick
  67255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67256. */
  67257. static readonly OnRightPickTrigger: number;
  67258. /**
  67259. * On center pick
  67260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67261. */
  67262. static readonly OnCenterPickTrigger: number;
  67263. /**
  67264. * On pick down
  67265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67266. */
  67267. static readonly OnPickDownTrigger: number;
  67268. /**
  67269. * On double pick
  67270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67271. */
  67272. static readonly OnDoublePickTrigger: number;
  67273. /**
  67274. * On pick up
  67275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67276. */
  67277. static readonly OnPickUpTrigger: number;
  67278. /**
  67279. * On pick out.
  67280. * This trigger will only be raised if you also declared a OnPickDown
  67281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67282. */
  67283. static readonly OnPickOutTrigger: number;
  67284. /**
  67285. * On long press
  67286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67287. */
  67288. static readonly OnLongPressTrigger: number;
  67289. /**
  67290. * On pointer over
  67291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67292. */
  67293. static readonly OnPointerOverTrigger: number;
  67294. /**
  67295. * On pointer out
  67296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67297. */
  67298. static readonly OnPointerOutTrigger: number;
  67299. /**
  67300. * On every frame
  67301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67302. */
  67303. static readonly OnEveryFrameTrigger: number;
  67304. /**
  67305. * On intersection enter
  67306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67307. */
  67308. static readonly OnIntersectionEnterTrigger: number;
  67309. /**
  67310. * On intersection exit
  67311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67312. */
  67313. static readonly OnIntersectionExitTrigger: number;
  67314. /**
  67315. * On key down
  67316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67317. */
  67318. static readonly OnKeyDownTrigger: number;
  67319. /**
  67320. * On key up
  67321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67322. */
  67323. static readonly OnKeyUpTrigger: number;
  67324. private _scene;
  67325. /**
  67326. * Creates a new action manager
  67327. * @param scene defines the hosting scene
  67328. */
  67329. constructor(scene: Scene);
  67330. /**
  67331. * Releases all associated resources
  67332. */
  67333. dispose(): void;
  67334. /**
  67335. * Gets hosting scene
  67336. * @returns the hosting scene
  67337. */
  67338. getScene(): Scene;
  67339. /**
  67340. * Does this action manager handles actions of any of the given triggers
  67341. * @param triggers defines the triggers to be tested
  67342. * @return a boolean indicating whether one (or more) of the triggers is handled
  67343. */
  67344. hasSpecificTriggers(triggers: number[]): boolean;
  67345. /**
  67346. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67347. * speed.
  67348. * @param triggerA defines the trigger to be tested
  67349. * @param triggerB defines the trigger to be tested
  67350. * @return a boolean indicating whether one (or more) of the triggers is handled
  67351. */
  67352. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67353. /**
  67354. * Does this action manager handles actions of a given trigger
  67355. * @param trigger defines the trigger to be tested
  67356. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67357. * @return whether the trigger is handled
  67358. */
  67359. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67360. /**
  67361. * Does this action manager has pointer triggers
  67362. */
  67363. readonly hasPointerTriggers: boolean;
  67364. /**
  67365. * Does this action manager has pick triggers
  67366. */
  67367. readonly hasPickTriggers: boolean;
  67368. /**
  67369. * Registers an action to this action manager
  67370. * @param action defines the action to be registered
  67371. * @return the action amended (prepared) after registration
  67372. */
  67373. registerAction(action: Action): Nullable<Action>;
  67374. /**
  67375. * Unregisters an action to this action manager
  67376. * @param action defines the action to be unregistered
  67377. * @return a boolean indicating whether the action has been unregistered
  67378. */
  67379. unregisterAction(action: Action): Boolean;
  67380. /**
  67381. * Process a specific trigger
  67382. * @param trigger defines the trigger to process
  67383. * @param evt defines the event details to be processed
  67384. */
  67385. processTrigger(trigger: number, evt?: IActionEvent): void;
  67386. /** @hidden */
  67387. _getEffectiveTarget(target: any, propertyPath: string): any;
  67388. /** @hidden */
  67389. _getProperty(propertyPath: string): string;
  67390. /**
  67391. * Serialize this manager to a JSON object
  67392. * @param name defines the property name to store this manager
  67393. * @returns a JSON representation of this manager
  67394. */
  67395. serialize(name: string): any;
  67396. /**
  67397. * Creates a new ActionManager from a JSON data
  67398. * @param parsedActions defines the JSON data to read from
  67399. * @param object defines the hosting mesh
  67400. * @param scene defines the hosting scene
  67401. */
  67402. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67403. /**
  67404. * Get a trigger name by index
  67405. * @param trigger defines the trigger index
  67406. * @returns a trigger name
  67407. */
  67408. static GetTriggerName(trigger: number): string;
  67409. }
  67410. }
  67411. declare module BABYLON {
  67412. /**
  67413. * Class representing a ray with position and direction
  67414. */
  67415. export class Ray {
  67416. /** origin point */
  67417. origin: Vector3;
  67418. /** direction */
  67419. direction: Vector3;
  67420. /** length of the ray */
  67421. length: number;
  67422. private static readonly TmpVector3;
  67423. private _tmpRay;
  67424. /**
  67425. * Creates a new ray
  67426. * @param origin origin point
  67427. * @param direction direction
  67428. * @param length length of the ray
  67429. */
  67430. constructor(
  67431. /** origin point */
  67432. origin: Vector3,
  67433. /** direction */
  67434. direction: Vector3,
  67435. /** length of the ray */
  67436. length?: number);
  67437. /**
  67438. * Checks if the ray intersects a box
  67439. * @param minimum bound of the box
  67440. * @param maximum bound of the box
  67441. * @param intersectionTreshold extra extend to be added to the box in all direction
  67442. * @returns if the box was hit
  67443. */
  67444. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67445. /**
  67446. * Checks if the ray intersects a box
  67447. * @param box the bounding box to check
  67448. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67449. * @returns if the box was hit
  67450. */
  67451. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67452. /**
  67453. * If the ray hits a sphere
  67454. * @param sphere the bounding sphere to check
  67455. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  67456. * @returns true if it hits the sphere
  67457. */
  67458. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  67459. /**
  67460. * If the ray hits a triange
  67461. * @param vertex0 triangle vertex
  67462. * @param vertex1 triangle vertex
  67463. * @param vertex2 triangle vertex
  67464. * @returns intersection information if hit
  67465. */
  67466. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  67467. /**
  67468. * Checks if ray intersects a plane
  67469. * @param plane the plane to check
  67470. * @returns the distance away it was hit
  67471. */
  67472. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  67473. /**
  67474. * Checks if ray intersects a mesh
  67475. * @param mesh the mesh to check
  67476. * @param fastCheck if only the bounding box should checked
  67477. * @returns picking info of the intersecton
  67478. */
  67479. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  67480. /**
  67481. * Checks if ray intersects a mesh
  67482. * @param meshes the meshes to check
  67483. * @param fastCheck if only the bounding box should checked
  67484. * @param results array to store result in
  67485. * @returns Array of picking infos
  67486. */
  67487. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  67488. private _comparePickingInfo;
  67489. private static smallnum;
  67490. private static rayl;
  67491. /**
  67492. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  67493. * @param sega the first point of the segment to test the intersection against
  67494. * @param segb the second point of the segment to test the intersection against
  67495. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  67496. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  67497. */
  67498. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  67499. /**
  67500. * Update the ray from viewport position
  67501. * @param x position
  67502. * @param y y position
  67503. * @param viewportWidth viewport width
  67504. * @param viewportHeight viewport height
  67505. * @param world world matrix
  67506. * @param view view matrix
  67507. * @param projection projection matrix
  67508. * @returns this ray updated
  67509. */
  67510. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67511. /**
  67512. * Creates a ray with origin and direction of 0,0,0
  67513. * @returns the new ray
  67514. */
  67515. static Zero(): Ray;
  67516. /**
  67517. * Creates a new ray from screen space and viewport
  67518. * @param x position
  67519. * @param y y position
  67520. * @param viewportWidth viewport width
  67521. * @param viewportHeight viewport height
  67522. * @param world world matrix
  67523. * @param view view matrix
  67524. * @param projection projection matrix
  67525. * @returns new ray
  67526. */
  67527. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67528. /**
  67529. * 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
  67530. * transformed to the given world matrix.
  67531. * @param origin The origin point
  67532. * @param end The end point
  67533. * @param world a matrix to transform the ray to. Default is the identity matrix.
  67534. * @returns the new ray
  67535. */
  67536. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  67537. /**
  67538. * Transforms a ray by a matrix
  67539. * @param ray ray to transform
  67540. * @param matrix matrix to apply
  67541. * @returns the resulting new ray
  67542. */
  67543. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  67544. /**
  67545. * Transforms a ray by a matrix
  67546. * @param ray ray to transform
  67547. * @param matrix matrix to apply
  67548. * @param result ray to store result in
  67549. */
  67550. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  67551. /**
  67552. * Unproject a ray from screen space to object space
  67553. * @param sourceX defines the screen space x coordinate to use
  67554. * @param sourceY defines the screen space y coordinate to use
  67555. * @param viewportWidth defines the current width of the viewport
  67556. * @param viewportHeight defines the current height of the viewport
  67557. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67558. * @param view defines the view matrix to use
  67559. * @param projection defines the projection matrix to use
  67560. */
  67561. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  67562. }
  67563. interface Scene {
  67564. /** @hidden */
  67565. _tempPickingRay: Nullable<Ray>;
  67566. /** @hidden */
  67567. _cachedRayForTransform: Ray;
  67568. /** @hidden */
  67569. _pickWithRayInverseMatrix: Matrix;
  67570. /** @hidden */
  67571. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67572. /** @hidden */
  67573. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  67574. }
  67575. }
  67576. declare module BABYLON {
  67577. /**
  67578. * Groups all the scene component constants in one place to ease maintenance.
  67579. * @hidden
  67580. */
  67581. export class SceneComponentConstants {
  67582. static readonly NAME_EFFECTLAYER: string;
  67583. static readonly NAME_LAYER: string;
  67584. static readonly NAME_LENSFLARESYSTEM: string;
  67585. static readonly NAME_BOUNDINGBOXRENDERER: string;
  67586. static readonly NAME_PARTICLESYSTEM: string;
  67587. static readonly NAME_GAMEPAD: string;
  67588. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  67589. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  67590. static readonly NAME_DEPTHRENDERER: string;
  67591. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  67592. static readonly NAME_SPRITE: string;
  67593. static readonly NAME_OUTLINERENDERER: string;
  67594. static readonly NAME_PROCEDURALTEXTURE: string;
  67595. static readonly NAME_SHADOWGENERATOR: string;
  67596. static readonly NAME_OCTREE: string;
  67597. static readonly NAME_PHYSICSENGINE: string;
  67598. static readonly NAME_AUDIO: string;
  67599. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  67600. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67601. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  67602. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67603. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  67604. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  67605. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  67606. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  67607. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  67608. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  67609. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  67610. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  67611. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  67612. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  67613. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  67614. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  67615. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  67616. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  67617. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  67618. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  67619. static readonly STEP_AFTERRENDER_AUDIO: number;
  67620. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  67621. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  67622. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  67623. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  67624. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  67625. static readonly STEP_POINTERMOVE_SPRITE: number;
  67626. static readonly STEP_POINTERDOWN_SPRITE: number;
  67627. static readonly STEP_POINTERUP_SPRITE: number;
  67628. }
  67629. /**
  67630. * This represents a scene component.
  67631. *
  67632. * This is used to decouple the dependency the scene is having on the different workloads like
  67633. * layers, post processes...
  67634. */
  67635. export interface ISceneComponent {
  67636. /**
  67637. * The name of the component. Each component must have a unique name.
  67638. */
  67639. name: string;
  67640. /**
  67641. * The scene the component belongs to.
  67642. */
  67643. scene: Scene;
  67644. /**
  67645. * Register the component to one instance of a scene.
  67646. */
  67647. register(): void;
  67648. /**
  67649. * Rebuilds the elements related to this component in case of
  67650. * context lost for instance.
  67651. */
  67652. rebuild(): void;
  67653. /**
  67654. * Disposes the component and the associated ressources.
  67655. */
  67656. dispose(): void;
  67657. }
  67658. /**
  67659. * This represents a SERIALIZABLE scene component.
  67660. *
  67661. * This extends Scene Component to add Serialization methods on top.
  67662. */
  67663. export interface ISceneSerializableComponent extends ISceneComponent {
  67664. /**
  67665. * Adds all the element from the container to the scene
  67666. * @param container the container holding the elements
  67667. */
  67668. addFromContainer(container: AbstractScene): void;
  67669. /**
  67670. * Removes all the elements in the container from the scene
  67671. * @param container contains the elements to remove
  67672. */
  67673. removeFromContainer(container: AbstractScene): void;
  67674. /**
  67675. * Serializes the component data to the specified json object
  67676. * @param serializationObject The object to serialize to
  67677. */
  67678. serialize(serializationObject: any): void;
  67679. }
  67680. /**
  67681. * Strong typing of a Mesh related stage step action
  67682. */
  67683. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  67684. /**
  67685. * Strong typing of a Evaluate Sub Mesh related stage step action
  67686. */
  67687. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  67688. /**
  67689. * Strong typing of a Active Mesh related stage step action
  67690. */
  67691. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  67692. /**
  67693. * Strong typing of a Camera related stage step action
  67694. */
  67695. export type CameraStageAction = (camera: Camera) => void;
  67696. /**
  67697. * Strong typing of a Render Target related stage step action
  67698. */
  67699. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  67700. /**
  67701. * Strong typing of a RenderingGroup related stage step action
  67702. */
  67703. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  67704. /**
  67705. * Strong typing of a Mesh Render related stage step action
  67706. */
  67707. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  67708. /**
  67709. * Strong typing of a simple stage step action
  67710. */
  67711. export type SimpleStageAction = () => void;
  67712. /**
  67713. * Strong typing of a render target action.
  67714. */
  67715. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  67716. /**
  67717. * Strong typing of a pointer move action.
  67718. */
  67719. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  67720. /**
  67721. * Strong typing of a pointer up/down action.
  67722. */
  67723. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  67724. /**
  67725. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  67726. * @hidden
  67727. */
  67728. export class Stage<T extends Function> extends Array<{
  67729. index: number;
  67730. component: ISceneComponent;
  67731. action: T;
  67732. }> {
  67733. /**
  67734. * Hide ctor from the rest of the world.
  67735. * @param items The items to add.
  67736. */
  67737. private constructor();
  67738. /**
  67739. * Creates a new Stage.
  67740. * @returns A new instance of a Stage
  67741. */
  67742. static Create<T extends Function>(): Stage<T>;
  67743. /**
  67744. * Registers a step in an ordered way in the targeted stage.
  67745. * @param index Defines the position to register the step in
  67746. * @param component Defines the component attached to the step
  67747. * @param action Defines the action to launch during the step
  67748. */
  67749. registerStep(index: number, component: ISceneComponent, action: T): void;
  67750. /**
  67751. * Clears all the steps from the stage.
  67752. */
  67753. clear(): void;
  67754. }
  67755. }
  67756. declare module BABYLON {
  67757. interface Scene {
  67758. /** @hidden */
  67759. _pointerOverSprite: Nullable<Sprite>;
  67760. /** @hidden */
  67761. _pickedDownSprite: Nullable<Sprite>;
  67762. /** @hidden */
  67763. _tempSpritePickingRay: Nullable<Ray>;
  67764. /**
  67765. * All of the sprite managers added to this scene
  67766. * @see http://doc.babylonjs.com/babylon101/sprites
  67767. */
  67768. spriteManagers: Array<ISpriteManager>;
  67769. /**
  67770. * An event triggered when sprites rendering is about to start
  67771. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67772. */
  67773. onBeforeSpritesRenderingObservable: Observable<Scene>;
  67774. /**
  67775. * An event triggered when sprites rendering is done
  67776. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67777. */
  67778. onAfterSpritesRenderingObservable: Observable<Scene>;
  67779. /** @hidden */
  67780. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67781. /** Launch a ray to try to pick a sprite in the scene
  67782. * @param x position on screen
  67783. * @param y position on screen
  67784. * @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
  67785. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67786. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  67787. * @returns a PickingInfo
  67788. */
  67789. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67790. /** Use the given ray to pick a sprite in the scene
  67791. * @param ray The ray (in world space) to use to pick meshes
  67792. * @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
  67793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67794. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  67795. * @returns a PickingInfo
  67796. */
  67797. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67798. /**
  67799. * Force the sprite under the pointer
  67800. * @param sprite defines the sprite to use
  67801. */
  67802. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  67803. /**
  67804. * Gets the sprite under the pointer
  67805. * @returns a Sprite or null if no sprite is under the pointer
  67806. */
  67807. getPointerOverSprite(): Nullable<Sprite>;
  67808. }
  67809. /**
  67810. * Defines the sprite scene component responsible to manage sprites
  67811. * in a given scene.
  67812. */
  67813. export class SpriteSceneComponent implements ISceneComponent {
  67814. /**
  67815. * The component name helpfull to identify the component in the list of scene components.
  67816. */
  67817. readonly name: string;
  67818. /**
  67819. * The scene the component belongs to.
  67820. */
  67821. scene: Scene;
  67822. /** @hidden */
  67823. private _spritePredicate;
  67824. /**
  67825. * Creates a new instance of the component for the given scene
  67826. * @param scene Defines the scene to register the component in
  67827. */
  67828. constructor(scene: Scene);
  67829. /**
  67830. * Registers the component in a given scene
  67831. */
  67832. register(): void;
  67833. /**
  67834. * Rebuilds the elements related to this component in case of
  67835. * context lost for instance.
  67836. */
  67837. rebuild(): void;
  67838. /**
  67839. * Disposes the component and the associated ressources.
  67840. */
  67841. dispose(): void;
  67842. private _pickSpriteButKeepRay;
  67843. private _pointerMove;
  67844. private _pointerDown;
  67845. private _pointerUp;
  67846. }
  67847. }
  67848. declare module BABYLON {
  67849. /** @hidden */
  67850. export var fogFragmentDeclaration: {
  67851. name: string;
  67852. shader: string;
  67853. };
  67854. }
  67855. declare module BABYLON {
  67856. /** @hidden */
  67857. export var fogFragment: {
  67858. name: string;
  67859. shader: string;
  67860. };
  67861. }
  67862. declare module BABYLON {
  67863. /** @hidden */
  67864. export var spritesPixelShader: {
  67865. name: string;
  67866. shader: string;
  67867. };
  67868. }
  67869. declare module BABYLON {
  67870. /** @hidden */
  67871. export var fogVertexDeclaration: {
  67872. name: string;
  67873. shader: string;
  67874. };
  67875. }
  67876. declare module BABYLON {
  67877. /** @hidden */
  67878. export var spritesVertexShader: {
  67879. name: string;
  67880. shader: string;
  67881. };
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Defines the minimum interface to fullfil in order to be a sprite manager.
  67886. */
  67887. export interface ISpriteManager extends IDisposable {
  67888. /**
  67889. * Restricts the camera to viewing objects with the same layerMask.
  67890. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  67891. */
  67892. layerMask: number;
  67893. /**
  67894. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  67895. */
  67896. isPickable: boolean;
  67897. /**
  67898. * Specifies the rendering group id for this mesh (0 by default)
  67899. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  67900. */
  67901. renderingGroupId: number;
  67902. /**
  67903. * Defines the list of sprites managed by the manager.
  67904. */
  67905. sprites: Array<Sprite>;
  67906. /**
  67907. * Tests the intersection of a sprite with a specific ray.
  67908. * @param ray The ray we are sending to test the collision
  67909. * @param camera The camera space we are sending rays in
  67910. * @param predicate A predicate allowing excluding sprites from the list of object to test
  67911. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  67912. * @returns picking info or null.
  67913. */
  67914. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67915. /**
  67916. * Renders the list of sprites on screen.
  67917. */
  67918. render(): void;
  67919. }
  67920. /**
  67921. * Class used to manage multiple sprites on the same spritesheet
  67922. * @see http://doc.babylonjs.com/babylon101/sprites
  67923. */
  67924. export class SpriteManager implements ISpriteManager {
  67925. /** defines the manager's name */
  67926. name: string;
  67927. /** Gets the list of sprites */
  67928. sprites: Sprite[];
  67929. /** Gets or sets the rendering group id (0 by default) */
  67930. renderingGroupId: number;
  67931. /** Gets or sets camera layer mask */
  67932. layerMask: number;
  67933. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  67934. fogEnabled: boolean;
  67935. /** Gets or sets a boolean indicating if the sprites are pickable */
  67936. isPickable: boolean;
  67937. /** Defines the default width of a cell in the spritesheet */
  67938. cellWidth: number;
  67939. /** Defines the default height of a cell in the spritesheet */
  67940. cellHeight: number;
  67941. /**
  67942. * An event triggered when the manager is disposed.
  67943. */
  67944. onDisposeObservable: Observable<SpriteManager>;
  67945. private _onDisposeObserver;
  67946. /**
  67947. * Callback called when the manager is disposed
  67948. */
  67949. onDispose: () => void;
  67950. private _capacity;
  67951. private _spriteTexture;
  67952. private _epsilon;
  67953. private _scene;
  67954. private _vertexData;
  67955. private _buffer;
  67956. private _vertexBuffers;
  67957. private _indexBuffer;
  67958. private _effectBase;
  67959. private _effectFog;
  67960. /**
  67961. * Gets or sets the spritesheet texture
  67962. */
  67963. texture: Texture;
  67964. /**
  67965. * Creates a new sprite manager
  67966. * @param name defines the manager's name
  67967. * @param imgUrl defines the sprite sheet url
  67968. * @param capacity defines the maximum allowed number of sprites
  67969. * @param cellSize defines the size of a sprite cell
  67970. * @param scene defines the hosting scene
  67971. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67972. * @param samplingMode defines the smapling mode to use with spritesheet
  67973. */
  67974. constructor(
  67975. /** defines the manager's name */
  67976. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  67977. private _appendSpriteVertex;
  67978. /**
  67979. * Intersects the sprites with a ray
  67980. * @param ray defines the ray to intersect with
  67981. * @param camera defines the current active camera
  67982. * @param predicate defines a predicate used to select candidate sprites
  67983. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  67984. * @returns null if no hit or a PickingInfo
  67985. */
  67986. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67987. /**
  67988. * Render all child sprites
  67989. */
  67990. render(): void;
  67991. /**
  67992. * Release associated resources
  67993. */
  67994. dispose(): void;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /**
  67999. * Class used to represent a sprite
  68000. * @see http://doc.babylonjs.com/babylon101/sprites
  68001. */
  68002. export class Sprite {
  68003. /** defines the name */
  68004. name: string;
  68005. /** Gets or sets the current world position */
  68006. position: Vector3;
  68007. /** Gets or sets the main color */
  68008. color: Color4;
  68009. /** Gets or sets the width */
  68010. width: number;
  68011. /** Gets or sets the height */
  68012. height: number;
  68013. /** Gets or sets rotation angle */
  68014. angle: number;
  68015. /** Gets or sets the cell index in the sprite sheet */
  68016. cellIndex: number;
  68017. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68018. invertU: number;
  68019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68020. invertV: number;
  68021. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68022. disposeWhenFinishedAnimating: boolean;
  68023. /** Gets the list of attached animations */
  68024. animations: Animation[];
  68025. /** Gets or sets a boolean indicating if the sprite can be picked */
  68026. isPickable: boolean;
  68027. /**
  68028. * Gets or sets the associated action manager
  68029. */
  68030. actionManager: Nullable<ActionManager>;
  68031. private _animationStarted;
  68032. private _loopAnimation;
  68033. private _fromIndex;
  68034. private _toIndex;
  68035. private _delay;
  68036. private _direction;
  68037. private _manager;
  68038. private _time;
  68039. private _onAnimationEnd;
  68040. /**
  68041. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68042. */
  68043. isVisible: boolean;
  68044. /**
  68045. * Gets or sets the sprite size
  68046. */
  68047. size: number;
  68048. /**
  68049. * Creates a new Sprite
  68050. * @param name defines the name
  68051. * @param manager defines the manager
  68052. */
  68053. constructor(
  68054. /** defines the name */
  68055. name: string, manager: ISpriteManager);
  68056. /**
  68057. * Starts an animation
  68058. * @param from defines the initial key
  68059. * @param to defines the end key
  68060. * @param loop defines if the animation must loop
  68061. * @param delay defines the start delay (in ms)
  68062. * @param onAnimationEnd defines a callback to call when animation ends
  68063. */
  68064. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68065. /** Stops current animation (if any) */
  68066. stopAnimation(): void;
  68067. /** @hidden */
  68068. _animate(deltaTime: number): void;
  68069. /** Release associated resources */
  68070. dispose(): void;
  68071. }
  68072. }
  68073. declare module BABYLON {
  68074. /**
  68075. * Information about the result of picking within a scene
  68076. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68077. */
  68078. export class PickingInfo {
  68079. /** @hidden */
  68080. _pickingUnavailable: boolean;
  68081. /**
  68082. * If the pick collided with an object
  68083. */
  68084. hit: boolean;
  68085. /**
  68086. * Distance away where the pick collided
  68087. */
  68088. distance: number;
  68089. /**
  68090. * The location of pick collision
  68091. */
  68092. pickedPoint: Nullable<Vector3>;
  68093. /**
  68094. * The mesh corresponding the the pick collision
  68095. */
  68096. pickedMesh: Nullable<AbstractMesh>;
  68097. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68098. bu: number;
  68099. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68100. bv: number;
  68101. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68102. faceId: number;
  68103. /** Id of the the submesh that was picked */
  68104. subMeshId: number;
  68105. /** If a sprite was picked, this will be the sprite the pick collided with */
  68106. pickedSprite: Nullable<Sprite>;
  68107. /**
  68108. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68109. */
  68110. originMesh: Nullable<AbstractMesh>;
  68111. /**
  68112. * The ray that was used to perform the picking.
  68113. */
  68114. ray: Nullable<Ray>;
  68115. /**
  68116. * Gets the normal correspodning to the face the pick collided with
  68117. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68118. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68119. * @returns The normal correspodning to the face the pick collided with
  68120. */
  68121. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68122. /**
  68123. * Gets the texture coordinates of where the pick occured
  68124. * @returns the vector containing the coordnates of the texture
  68125. */
  68126. getTextureCoordinates(): Nullable<Vector2>;
  68127. }
  68128. }
  68129. declare module BABYLON {
  68130. /**
  68131. * Gather the list of pointer event types as constants.
  68132. */
  68133. export class PointerEventTypes {
  68134. /**
  68135. * 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.
  68136. */
  68137. static readonly POINTERDOWN: number;
  68138. /**
  68139. * The pointerup event is fired when a pointer is no longer active.
  68140. */
  68141. static readonly POINTERUP: number;
  68142. /**
  68143. * The pointermove event is fired when a pointer changes coordinates.
  68144. */
  68145. static readonly POINTERMOVE: number;
  68146. /**
  68147. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68148. */
  68149. static readonly POINTERWHEEL: number;
  68150. /**
  68151. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68152. */
  68153. static readonly POINTERPICK: number;
  68154. /**
  68155. * The pointertap event is fired when a the object has been touched and released without drag.
  68156. */
  68157. static readonly POINTERTAP: number;
  68158. /**
  68159. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68160. */
  68161. static readonly POINTERDOUBLETAP: number;
  68162. }
  68163. /**
  68164. * Base class of pointer info types.
  68165. */
  68166. export class PointerInfoBase {
  68167. /**
  68168. * Defines the type of event (PointerEventTypes)
  68169. */
  68170. type: number;
  68171. /**
  68172. * Defines the related dom event
  68173. */
  68174. event: PointerEvent | MouseWheelEvent;
  68175. /**
  68176. * Instantiates the base class of pointers info.
  68177. * @param type Defines the type of event (PointerEventTypes)
  68178. * @param event Defines the related dom event
  68179. */
  68180. constructor(
  68181. /**
  68182. * Defines the type of event (PointerEventTypes)
  68183. */
  68184. type: number,
  68185. /**
  68186. * Defines the related dom event
  68187. */
  68188. event: PointerEvent | MouseWheelEvent);
  68189. }
  68190. /**
  68191. * This class is used to store pointer related info for the onPrePointerObservable event.
  68192. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68193. */
  68194. export class PointerInfoPre extends PointerInfoBase {
  68195. /**
  68196. * Ray from a pointer if availible (eg. 6dof controller)
  68197. */
  68198. ray: Nullable<Ray>;
  68199. /**
  68200. * Defines the local position of the pointer on the canvas.
  68201. */
  68202. localPosition: Vector2;
  68203. /**
  68204. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68205. */
  68206. skipOnPointerObservable: boolean;
  68207. /**
  68208. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68209. * @param type Defines the type of event (PointerEventTypes)
  68210. * @param event Defines the related dom event
  68211. * @param localX Defines the local x coordinates of the pointer when the event occured
  68212. * @param localY Defines the local y coordinates of the pointer when the event occured
  68213. */
  68214. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68215. }
  68216. /**
  68217. * This type contains all the data related to a pointer event in Babylon.js.
  68218. * 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.
  68219. */
  68220. export class PointerInfo extends PointerInfoBase {
  68221. /**
  68222. * Defines the picking info associated to the info (if any)\
  68223. */
  68224. pickInfo: Nullable<PickingInfo>;
  68225. /**
  68226. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68227. * @param type Defines the type of event (PointerEventTypes)
  68228. * @param event Defines the related dom event
  68229. * @param pickInfo Defines the picking info associated to the info (if any)\
  68230. */
  68231. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68232. /**
  68233. * Defines the picking info associated to the info (if any)\
  68234. */
  68235. pickInfo: Nullable<PickingInfo>);
  68236. }
  68237. }
  68238. declare module BABYLON {
  68239. /**
  68240. * Manage the mouse inputs to control the movement of a free camera.
  68241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68242. */
  68243. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68244. /**
  68245. * Define if touch is enabled in the mouse input
  68246. */
  68247. touchEnabled: boolean;
  68248. /**
  68249. * Defines the camera the input is attached to.
  68250. */
  68251. camera: FreeCamera;
  68252. /**
  68253. * Defines the buttons associated with the input to handle camera move.
  68254. */
  68255. buttons: number[];
  68256. /**
  68257. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68258. */
  68259. angularSensibility: number;
  68260. private _pointerInput;
  68261. private _onMouseMove;
  68262. private _observer;
  68263. private previousPosition;
  68264. /**
  68265. * Manage the mouse inputs to control the movement of a free camera.
  68266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68267. * @param touchEnabled Defines if touch is enabled or not
  68268. */
  68269. constructor(
  68270. /**
  68271. * Define if touch is enabled in the mouse input
  68272. */
  68273. touchEnabled?: boolean);
  68274. /**
  68275. * Attach the input controls to a specific dom element to get the input from.
  68276. * @param element Defines the element the controls should be listened from
  68277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68278. */
  68279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68280. /**
  68281. * Detach the current controls from the specified dom element.
  68282. * @param element Defines the element to stop listening the inputs from
  68283. */
  68284. detachControl(element: Nullable<HTMLElement>): void;
  68285. /**
  68286. * Gets the class name of the current intput.
  68287. * @returns the class name
  68288. */
  68289. getClassName(): string;
  68290. /**
  68291. * Get the friendly name associated with the input class.
  68292. * @returns the input friendly name
  68293. */
  68294. getSimpleName(): string;
  68295. }
  68296. }
  68297. declare module BABYLON {
  68298. /**
  68299. * Manage the touch inputs to control the movement of a free camera.
  68300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68301. */
  68302. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68303. /**
  68304. * Defines the camera the input is attached to.
  68305. */
  68306. camera: FreeCamera;
  68307. /**
  68308. * Defines the touch sensibility for rotation.
  68309. * The higher the faster.
  68310. */
  68311. touchAngularSensibility: number;
  68312. /**
  68313. * Defines the touch sensibility for move.
  68314. * The higher the faster.
  68315. */
  68316. touchMoveSensibility: number;
  68317. private _offsetX;
  68318. private _offsetY;
  68319. private _pointerPressed;
  68320. private _pointerInput;
  68321. private _observer;
  68322. private _onLostFocus;
  68323. /**
  68324. * Attach the input controls to a specific dom element to get the input from.
  68325. * @param element Defines the element the controls should be listened from
  68326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68327. */
  68328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68329. /**
  68330. * Detach the current controls from the specified dom element.
  68331. * @param element Defines the element to stop listening the inputs from
  68332. */
  68333. detachControl(element: Nullable<HTMLElement>): void;
  68334. /**
  68335. * Update the current camera state depending on the inputs that have been used this frame.
  68336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68337. */
  68338. checkInputs(): void;
  68339. /**
  68340. * Gets the class name of the current intput.
  68341. * @returns the class name
  68342. */
  68343. getClassName(): string;
  68344. /**
  68345. * Get the friendly name associated with the input class.
  68346. * @returns the input friendly name
  68347. */
  68348. getSimpleName(): string;
  68349. }
  68350. }
  68351. declare module BABYLON {
  68352. /**
  68353. * Default Inputs manager for the FreeCamera.
  68354. * It groups all the default supported inputs for ease of use.
  68355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68356. */
  68357. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68358. /**
  68359. * Instantiates a new FreeCameraInputsManager.
  68360. * @param camera Defines the camera the inputs belong to
  68361. */
  68362. constructor(camera: FreeCamera);
  68363. /**
  68364. * Add keyboard input support to the input manager.
  68365. * @returns the current input manager
  68366. */
  68367. addKeyboard(): FreeCameraInputsManager;
  68368. /**
  68369. * Add mouse input support to the input manager.
  68370. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68371. * @returns the current input manager
  68372. */
  68373. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68374. /**
  68375. * Add touch input support to the input manager.
  68376. * @returns the current input manager
  68377. */
  68378. addTouch(): FreeCameraInputsManager;
  68379. }
  68380. }
  68381. declare module BABYLON {
  68382. /**
  68383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68384. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68386. */
  68387. export class FreeCamera extends TargetCamera {
  68388. /**
  68389. * Define the collision ellipsoid of the camera.
  68390. * This is helpful to simulate a camera body like the player body around the camera
  68391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68392. */
  68393. ellipsoid: Vector3;
  68394. /**
  68395. * Define an offset for the position of the ellipsoid around the camera.
  68396. * This can be helpful to determine the center of the body near the gravity center of the body
  68397. * instead of its head.
  68398. */
  68399. ellipsoidOffset: Vector3;
  68400. /**
  68401. * Enable or disable collisions of the camera with the rest of the scene objects.
  68402. */
  68403. checkCollisions: boolean;
  68404. /**
  68405. * Enable or disable gravity on the camera.
  68406. */
  68407. applyGravity: boolean;
  68408. /**
  68409. * Define the input manager associated to the camera.
  68410. */
  68411. inputs: FreeCameraInputsManager;
  68412. /**
  68413. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68414. * Higher values reduce sensitivity.
  68415. */
  68416. /**
  68417. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68418. * Higher values reduce sensitivity.
  68419. */
  68420. angularSensibility: number;
  68421. /**
  68422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68423. */
  68424. keysUp: number[];
  68425. /**
  68426. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68427. */
  68428. keysDown: number[];
  68429. /**
  68430. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68431. */
  68432. keysLeft: number[];
  68433. /**
  68434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68435. */
  68436. keysRight: number[];
  68437. /**
  68438. * Event raised when the camera collide with a mesh in the scene.
  68439. */
  68440. onCollide: (collidedMesh: AbstractMesh) => void;
  68441. private _collider;
  68442. private _needMoveForGravity;
  68443. private _oldPosition;
  68444. private _diffPosition;
  68445. private _newPosition;
  68446. /** @hidden */
  68447. _localDirection: Vector3;
  68448. /** @hidden */
  68449. _transformedDirection: Vector3;
  68450. /**
  68451. * Instantiates a Free Camera.
  68452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68453. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68455. * @param name Define the name of the camera in the scene
  68456. * @param position Define the start position of the camera in the scene
  68457. * @param scene Define the scene the camera belongs to
  68458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68459. */
  68460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68461. /**
  68462. * Attached controls to the current camera.
  68463. * @param element Defines the element the controls should be listened from
  68464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68465. */
  68466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68467. /**
  68468. * Detach the current controls from the camera.
  68469. * The camera will stop reacting to inputs.
  68470. * @param element Defines the element to stop listening the inputs from
  68471. */
  68472. detachControl(element: HTMLElement): void;
  68473. private _collisionMask;
  68474. /**
  68475. * Define a collision mask to limit the list of object the camera can collide with
  68476. */
  68477. collisionMask: number;
  68478. /** @hidden */
  68479. _collideWithWorld(displacement: Vector3): void;
  68480. private _onCollisionPositionChange;
  68481. /** @hidden */
  68482. _checkInputs(): void;
  68483. /** @hidden */
  68484. _decideIfNeedsToMove(): boolean;
  68485. /** @hidden */
  68486. _updatePosition(): void;
  68487. /**
  68488. * Destroy the camera and release the current resources hold by it.
  68489. */
  68490. dispose(): void;
  68491. /**
  68492. * Gets the current object class name.
  68493. * @return the class name
  68494. */
  68495. getClassName(): string;
  68496. }
  68497. }
  68498. declare module BABYLON {
  68499. /**
  68500. * Represents a gamepad control stick position
  68501. */
  68502. export class StickValues {
  68503. /**
  68504. * The x component of the control stick
  68505. */
  68506. x: number;
  68507. /**
  68508. * The y component of the control stick
  68509. */
  68510. y: number;
  68511. /**
  68512. * Initializes the gamepad x and y control stick values
  68513. * @param x The x component of the gamepad control stick value
  68514. * @param y The y component of the gamepad control stick value
  68515. */
  68516. constructor(
  68517. /**
  68518. * The x component of the control stick
  68519. */
  68520. x: number,
  68521. /**
  68522. * The y component of the control stick
  68523. */
  68524. y: number);
  68525. }
  68526. /**
  68527. * An interface which manages callbacks for gamepad button changes
  68528. */
  68529. export interface GamepadButtonChanges {
  68530. /**
  68531. * Called when a gamepad has been changed
  68532. */
  68533. changed: boolean;
  68534. /**
  68535. * Called when a gamepad press event has been triggered
  68536. */
  68537. pressChanged: boolean;
  68538. /**
  68539. * Called when a touch event has been triggered
  68540. */
  68541. touchChanged: boolean;
  68542. /**
  68543. * Called when a value has changed
  68544. */
  68545. valueChanged: boolean;
  68546. }
  68547. /**
  68548. * Represents a gamepad
  68549. */
  68550. export class Gamepad {
  68551. /**
  68552. * The id of the gamepad
  68553. */
  68554. id: string;
  68555. /**
  68556. * The index of the gamepad
  68557. */
  68558. index: number;
  68559. /**
  68560. * The browser gamepad
  68561. */
  68562. browserGamepad: any;
  68563. /**
  68564. * Specifies what type of gamepad this represents
  68565. */
  68566. type: number;
  68567. private _leftStick;
  68568. private _rightStick;
  68569. /** @hidden */
  68570. _isConnected: boolean;
  68571. private _leftStickAxisX;
  68572. private _leftStickAxisY;
  68573. private _rightStickAxisX;
  68574. private _rightStickAxisY;
  68575. /**
  68576. * Triggered when the left control stick has been changed
  68577. */
  68578. private _onleftstickchanged;
  68579. /**
  68580. * Triggered when the right control stick has been changed
  68581. */
  68582. private _onrightstickchanged;
  68583. /**
  68584. * Represents a gamepad controller
  68585. */
  68586. static GAMEPAD: number;
  68587. /**
  68588. * Represents a generic controller
  68589. */
  68590. static GENERIC: number;
  68591. /**
  68592. * Represents an XBox controller
  68593. */
  68594. static XBOX: number;
  68595. /**
  68596. * Represents a pose-enabled controller
  68597. */
  68598. static POSE_ENABLED: number;
  68599. /**
  68600. * Specifies whether the left control stick should be Y-inverted
  68601. */
  68602. protected _invertLeftStickY: boolean;
  68603. /**
  68604. * Specifies if the gamepad has been connected
  68605. */
  68606. readonly isConnected: boolean;
  68607. /**
  68608. * Initializes the gamepad
  68609. * @param id The id of the gamepad
  68610. * @param index The index of the gamepad
  68611. * @param browserGamepad The browser gamepad
  68612. * @param leftStickX The x component of the left joystick
  68613. * @param leftStickY The y component of the left joystick
  68614. * @param rightStickX The x component of the right joystick
  68615. * @param rightStickY The y component of the right joystick
  68616. */
  68617. constructor(
  68618. /**
  68619. * The id of the gamepad
  68620. */
  68621. id: string,
  68622. /**
  68623. * The index of the gamepad
  68624. */
  68625. index: number,
  68626. /**
  68627. * The browser gamepad
  68628. */
  68629. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  68630. /**
  68631. * Callback triggered when the left joystick has changed
  68632. * @param callback
  68633. */
  68634. onleftstickchanged(callback: (values: StickValues) => void): void;
  68635. /**
  68636. * Callback triggered when the right joystick has changed
  68637. * @param callback
  68638. */
  68639. onrightstickchanged(callback: (values: StickValues) => void): void;
  68640. /**
  68641. * Gets the left joystick
  68642. */
  68643. /**
  68644. * Sets the left joystick values
  68645. */
  68646. leftStick: StickValues;
  68647. /**
  68648. * Gets the right joystick
  68649. */
  68650. /**
  68651. * Sets the right joystick value
  68652. */
  68653. rightStick: StickValues;
  68654. /**
  68655. * Updates the gamepad joystick positions
  68656. */
  68657. update(): void;
  68658. /**
  68659. * Disposes the gamepad
  68660. */
  68661. dispose(): void;
  68662. }
  68663. /**
  68664. * Represents a generic gamepad
  68665. */
  68666. export class GenericPad extends Gamepad {
  68667. private _buttons;
  68668. private _onbuttondown;
  68669. private _onbuttonup;
  68670. /**
  68671. * Observable triggered when a button has been pressed
  68672. */
  68673. onButtonDownObservable: Observable<number>;
  68674. /**
  68675. * Observable triggered when a button has been released
  68676. */
  68677. onButtonUpObservable: Observable<number>;
  68678. /**
  68679. * Callback triggered when a button has been pressed
  68680. * @param callback Called when a button has been pressed
  68681. */
  68682. onbuttondown(callback: (buttonPressed: number) => void): void;
  68683. /**
  68684. * Callback triggered when a button has been released
  68685. * @param callback Called when a button has been released
  68686. */
  68687. onbuttonup(callback: (buttonReleased: number) => void): void;
  68688. /**
  68689. * Initializes the generic gamepad
  68690. * @param id The id of the generic gamepad
  68691. * @param index The index of the generic gamepad
  68692. * @param browserGamepad The browser gamepad
  68693. */
  68694. constructor(id: string, index: number, browserGamepad: any);
  68695. private _setButtonValue;
  68696. /**
  68697. * Updates the generic gamepad
  68698. */
  68699. update(): void;
  68700. /**
  68701. * Disposes the generic gamepad
  68702. */
  68703. dispose(): void;
  68704. }
  68705. }
  68706. declare module BABYLON {
  68707. /**
  68708. * 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.
  68709. * @see https://doc.babylonjs.com/how_to/transformnode
  68710. */
  68711. export class TransformNode extends Node {
  68712. /**
  68713. * Object will not rotate to face the camera
  68714. */
  68715. static BILLBOARDMODE_NONE: number;
  68716. /**
  68717. * Object will rotate to face the camera but only on the x axis
  68718. */
  68719. static BILLBOARDMODE_X: number;
  68720. /**
  68721. * Object will rotate to face the camera but only on the y axis
  68722. */
  68723. static BILLBOARDMODE_Y: number;
  68724. /**
  68725. * Object will rotate to face the camera but only on the z axis
  68726. */
  68727. static BILLBOARDMODE_Z: number;
  68728. /**
  68729. * Object will rotate to face the camera
  68730. */
  68731. static BILLBOARDMODE_ALL: number;
  68732. private _forward;
  68733. private _forwardInverted;
  68734. private _up;
  68735. private _right;
  68736. private _rightInverted;
  68737. private _position;
  68738. private _rotation;
  68739. private _rotationQuaternion;
  68740. protected _scaling: Vector3;
  68741. protected _isDirty: boolean;
  68742. private _transformToBoneReferal;
  68743. /**
  68744. * Set the billboard mode. Default is 0.
  68745. *
  68746. * | Value | Type | Description |
  68747. * | --- | --- | --- |
  68748. * | 0 | BILLBOARDMODE_NONE | |
  68749. * | 1 | BILLBOARDMODE_X | |
  68750. * | 2 | BILLBOARDMODE_Y | |
  68751. * | 4 | BILLBOARDMODE_Z | |
  68752. * | 7 | BILLBOARDMODE_ALL | |
  68753. *
  68754. */
  68755. billboardMode: number;
  68756. /**
  68757. * 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
  68758. */
  68759. scalingDeterminant: number;
  68760. /**
  68761. * Sets the distance of the object to max, often used by skybox
  68762. */
  68763. infiniteDistance: boolean;
  68764. /**
  68765. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  68766. * By default the system will update normals to compensate
  68767. */
  68768. ignoreNonUniformScaling: boolean;
  68769. /** @hidden */
  68770. _poseMatrix: Matrix;
  68771. /** @hidden */
  68772. _localMatrix: Matrix;
  68773. private _absolutePosition;
  68774. private _pivotMatrix;
  68775. private _pivotMatrixInverse;
  68776. protected _postMultiplyPivotMatrix: boolean;
  68777. protected _isWorldMatrixFrozen: boolean;
  68778. /** @hidden */
  68779. _indexInSceneTransformNodesArray: number;
  68780. /**
  68781. * An event triggered after the world matrix is updated
  68782. */
  68783. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  68784. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  68785. /**
  68786. * Gets a string identifying the name of the class
  68787. * @returns "TransformNode" string
  68788. */
  68789. getClassName(): string;
  68790. /**
  68791. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  68792. */
  68793. position: Vector3;
  68794. /**
  68795. * 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)).
  68796. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  68797. */
  68798. rotation: Vector3;
  68799. /**
  68800. * 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)).
  68801. */
  68802. scaling: Vector3;
  68803. /**
  68804. * 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).
  68805. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  68806. */
  68807. rotationQuaternion: Nullable<Quaternion>;
  68808. /**
  68809. * The forward direction of that transform in world space.
  68810. */
  68811. readonly forward: Vector3;
  68812. /**
  68813. * The up direction of that transform in world space.
  68814. */
  68815. readonly up: Vector3;
  68816. /**
  68817. * The right direction of that transform in world space.
  68818. */
  68819. readonly right: Vector3;
  68820. /**
  68821. * Copies the parameter passed Matrix into the mesh Pose matrix.
  68822. * @param matrix the matrix to copy the pose from
  68823. * @returns this TransformNode.
  68824. */
  68825. updatePoseMatrix(matrix: Matrix): TransformNode;
  68826. /**
  68827. * Returns the mesh Pose matrix.
  68828. * @returns the pose matrix
  68829. */
  68830. getPoseMatrix(): Matrix;
  68831. /** @hidden */
  68832. _isSynchronized(): boolean;
  68833. /** @hidden */
  68834. _initCache(): void;
  68835. /**
  68836. * Flag the transform node as dirty (Forcing it to update everything)
  68837. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  68838. * @returns this transform node
  68839. */
  68840. markAsDirty(property: string): TransformNode;
  68841. /**
  68842. * Returns the current mesh absolute position.
  68843. * Returns a Vector3.
  68844. */
  68845. readonly absolutePosition: Vector3;
  68846. /**
  68847. * Sets a new matrix to apply before all other transformation
  68848. * @param matrix defines the transform matrix
  68849. * @returns the current TransformNode
  68850. */
  68851. setPreTransformMatrix(matrix: Matrix): TransformNode;
  68852. /**
  68853. * Sets a new pivot matrix to the current node
  68854. * @param matrix defines the new pivot matrix to use
  68855. * @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
  68856. * @returns the current TransformNode
  68857. */
  68858. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  68859. /**
  68860. * Returns the mesh pivot matrix.
  68861. * Default : Identity.
  68862. * @returns the matrix
  68863. */
  68864. getPivotMatrix(): Matrix;
  68865. /**
  68866. * Prevents the World matrix to be computed any longer.
  68867. * @returns the TransformNode.
  68868. */
  68869. freezeWorldMatrix(): TransformNode;
  68870. /**
  68871. * Allows back the World matrix computation.
  68872. * @returns the TransformNode.
  68873. */
  68874. unfreezeWorldMatrix(): this;
  68875. /**
  68876. * True if the World matrix has been frozen.
  68877. */
  68878. readonly isWorldMatrixFrozen: boolean;
  68879. /**
  68880. * Retuns the mesh absolute position in the World.
  68881. * @returns a Vector3.
  68882. */
  68883. getAbsolutePosition(): Vector3;
  68884. /**
  68885. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  68886. * @param absolutePosition the absolute position to set
  68887. * @returns the TransformNode.
  68888. */
  68889. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  68890. /**
  68891. * Sets the mesh position in its local space.
  68892. * @param vector3 the position to set in localspace
  68893. * @returns the TransformNode.
  68894. */
  68895. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  68896. /**
  68897. * Returns the mesh position in the local space from the current World matrix values.
  68898. * @returns a new Vector3.
  68899. */
  68900. getPositionExpressedInLocalSpace(): Vector3;
  68901. /**
  68902. * Translates the mesh along the passed Vector3 in its local space.
  68903. * @param vector3 the distance to translate in localspace
  68904. * @returns the TransformNode.
  68905. */
  68906. locallyTranslate(vector3: Vector3): TransformNode;
  68907. private static _lookAtVectorCache;
  68908. /**
  68909. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  68910. * @param targetPoint the position (must be in same space as current mesh) to look at
  68911. * @param yawCor optional yaw (y-axis) correction in radians
  68912. * @param pitchCor optional pitch (x-axis) correction in radians
  68913. * @param rollCor optional roll (z-axis) correction in radians
  68914. * @param space the choosen space of the target
  68915. * @returns the TransformNode.
  68916. */
  68917. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  68918. /**
  68919. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68920. * This Vector3 is expressed in the World space.
  68921. * @param localAxis axis to rotate
  68922. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68923. */
  68924. getDirection(localAxis: Vector3): Vector3;
  68925. /**
  68926. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  68927. * localAxis is expressed in the mesh local space.
  68928. * result is computed in the Wordl space from the mesh World matrix.
  68929. * @param localAxis axis to rotate
  68930. * @param result the resulting transformnode
  68931. * @returns this TransformNode.
  68932. */
  68933. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  68934. /**
  68935. * Sets this transform node rotation to the given local axis.
  68936. * @param localAxis the axis in local space
  68937. * @param yawCor optional yaw (y-axis) correction in radians
  68938. * @param pitchCor optional pitch (x-axis) correction in radians
  68939. * @param rollCor optional roll (z-axis) correction in radians
  68940. * @returns this TransformNode
  68941. */
  68942. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  68943. /**
  68944. * Sets a new pivot point to the current node
  68945. * @param point defines the new pivot point to use
  68946. * @param space defines if the point is in world or local space (local by default)
  68947. * @returns the current TransformNode
  68948. */
  68949. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  68950. /**
  68951. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  68952. * @returns the pivot point
  68953. */
  68954. getPivotPoint(): Vector3;
  68955. /**
  68956. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  68957. * @param result the vector3 to store the result
  68958. * @returns this TransformNode.
  68959. */
  68960. getPivotPointToRef(result: Vector3): TransformNode;
  68961. /**
  68962. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  68963. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  68964. */
  68965. getAbsolutePivotPoint(): Vector3;
  68966. /**
  68967. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  68968. * @param result vector3 to store the result
  68969. * @returns this TransformNode.
  68970. */
  68971. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  68972. /**
  68973. * Defines the passed node as the parent of the current node.
  68974. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  68975. * @param node the node ot set as the parent
  68976. * @returns this TransformNode.
  68977. */
  68978. setParent(node: Nullable<Node>): TransformNode;
  68979. private _nonUniformScaling;
  68980. /**
  68981. * True if the scaling property of this object is non uniform eg. (1,2,1)
  68982. */
  68983. readonly nonUniformScaling: boolean;
  68984. /** @hidden */
  68985. _updateNonUniformScalingState(value: boolean): boolean;
  68986. /**
  68987. * Attach the current TransformNode to another TransformNode associated with a bone
  68988. * @param bone Bone affecting the TransformNode
  68989. * @param affectedTransformNode TransformNode associated with the bone
  68990. * @returns this object
  68991. */
  68992. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  68993. /**
  68994. * Detach the transform node if its associated with a bone
  68995. * @returns this object
  68996. */
  68997. detachFromBone(): TransformNode;
  68998. private static _rotationAxisCache;
  68999. /**
  69000. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  69001. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69002. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69003. * The passed axis is also normalized.
  69004. * @param axis the axis to rotate around
  69005. * @param amount the amount to rotate in radians
  69006. * @param space Space to rotate in (Default: local)
  69007. * @returns the TransformNode.
  69008. */
  69009. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  69010. /**
  69011. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  69012. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69013. * The passed axis is also normalized. .
  69014. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  69015. * @param point the point to rotate around
  69016. * @param axis the axis to rotate around
  69017. * @param amount the amount to rotate in radians
  69018. * @returns the TransformNode
  69019. */
  69020. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  69021. /**
  69022. * Translates the mesh along the axis vector for the passed distance in the given space.
  69023. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69024. * @param axis the axis to translate in
  69025. * @param distance the distance to translate
  69026. * @param space Space to rotate in (Default: local)
  69027. * @returns the TransformNode.
  69028. */
  69029. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  69030. /**
  69031. * Adds a rotation step to the mesh current rotation.
  69032. * x, y, z are Euler angles expressed in radians.
  69033. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  69034. * This means this rotation is made in the mesh local space only.
  69035. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  69036. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  69037. * ```javascript
  69038. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  69039. * ```
  69040. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  69041. * 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.
  69042. * @param x Rotation to add
  69043. * @param y Rotation to add
  69044. * @param z Rotation to add
  69045. * @returns the TransformNode.
  69046. */
  69047. addRotation(x: number, y: number, z: number): TransformNode;
  69048. /**
  69049. * Computes the world matrix of the node
  69050. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69051. * @returns the world matrix
  69052. */
  69053. computeWorldMatrix(force?: boolean): Matrix;
  69054. protected _afterComputeWorldMatrix(): void;
  69055. /**
  69056. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  69057. * @param func callback function to add
  69058. *
  69059. * @returns the TransformNode.
  69060. */
  69061. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69062. /**
  69063. * Removes a registered callback function.
  69064. * @param func callback function to remove
  69065. * @returns the TransformNode.
  69066. */
  69067. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69068. /**
  69069. * Gets the position of the current mesh in camera space
  69070. * @param camera defines the camera to use
  69071. * @returns a position
  69072. */
  69073. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  69074. /**
  69075. * Returns the distance from the mesh to the active camera
  69076. * @param camera defines the camera to use
  69077. * @returns the distance
  69078. */
  69079. getDistanceToCamera(camera?: Nullable<Camera>): number;
  69080. /**
  69081. * Clone the current transform node
  69082. * @param name Name of the new clone
  69083. * @param newParent New parent for the clone
  69084. * @param doNotCloneChildren Do not clone children hierarchy
  69085. * @returns the new transform node
  69086. */
  69087. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  69088. /**
  69089. * Serializes the objects information.
  69090. * @param currentSerializationObject defines the object to serialize in
  69091. * @returns the serialized object
  69092. */
  69093. serialize(currentSerializationObject?: any): any;
  69094. /**
  69095. * Returns a new TransformNode object parsed from the source provided.
  69096. * @param parsedTransformNode is the source.
  69097. * @param scene the scne the object belongs to
  69098. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  69099. * @returns a new TransformNode object parsed from the source provided.
  69100. */
  69101. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  69102. /**
  69103. * Get all child-transformNodes of this node
  69104. * @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
  69105. * @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
  69106. * @returns an array of TransformNode
  69107. */
  69108. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  69109. /**
  69110. * Releases resources associated with this transform node.
  69111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69113. */
  69114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69115. }
  69116. }
  69117. declare module BABYLON {
  69118. /**
  69119. * Defines the types of pose enabled controllers that are supported
  69120. */
  69121. export enum PoseEnabledControllerType {
  69122. /**
  69123. * HTC Vive
  69124. */
  69125. VIVE = 0,
  69126. /**
  69127. * Oculus Rift
  69128. */
  69129. OCULUS = 1,
  69130. /**
  69131. * Windows mixed reality
  69132. */
  69133. WINDOWS = 2,
  69134. /**
  69135. * Samsung gear VR
  69136. */
  69137. GEAR_VR = 3,
  69138. /**
  69139. * Google Daydream
  69140. */
  69141. DAYDREAM = 4,
  69142. /**
  69143. * Generic
  69144. */
  69145. GENERIC = 5
  69146. }
  69147. /**
  69148. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69149. */
  69150. export interface MutableGamepadButton {
  69151. /**
  69152. * Value of the button/trigger
  69153. */
  69154. value: number;
  69155. /**
  69156. * If the button/trigger is currently touched
  69157. */
  69158. touched: boolean;
  69159. /**
  69160. * If the button/trigger is currently pressed
  69161. */
  69162. pressed: boolean;
  69163. }
  69164. /**
  69165. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69166. * @hidden
  69167. */
  69168. export interface ExtendedGamepadButton extends GamepadButton {
  69169. /**
  69170. * If the button/trigger is currently pressed
  69171. */
  69172. readonly pressed: boolean;
  69173. /**
  69174. * If the button/trigger is currently touched
  69175. */
  69176. readonly touched: boolean;
  69177. /**
  69178. * Value of the button/trigger
  69179. */
  69180. readonly value: number;
  69181. }
  69182. /** @hidden */
  69183. export interface _GamePadFactory {
  69184. /**
  69185. * Returns wether or not the current gamepad can be created for this type of controller.
  69186. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69187. * @returns true if it can be created, otherwise false
  69188. */
  69189. canCreate(gamepadInfo: any): boolean;
  69190. /**
  69191. * Creates a new instance of the Gamepad.
  69192. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69193. * @returns the new gamepad instance
  69194. */
  69195. create(gamepadInfo: any): Gamepad;
  69196. }
  69197. /**
  69198. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69199. */
  69200. export class PoseEnabledControllerHelper {
  69201. /** @hidden */
  69202. static _ControllerFactories: _GamePadFactory[];
  69203. /** @hidden */
  69204. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69205. /**
  69206. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69207. * @param vrGamepad the gamepad to initialized
  69208. * @returns a vr controller of the type the gamepad identified as
  69209. */
  69210. static InitiateController(vrGamepad: any): Gamepad;
  69211. }
  69212. /**
  69213. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69214. */
  69215. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69216. private _deviceRoomPosition;
  69217. private _deviceRoomRotationQuaternion;
  69218. /**
  69219. * The device position in babylon space
  69220. */
  69221. devicePosition: Vector3;
  69222. /**
  69223. * The device rotation in babylon space
  69224. */
  69225. deviceRotationQuaternion: Quaternion;
  69226. /**
  69227. * The scale factor of the device in babylon space
  69228. */
  69229. deviceScaleFactor: number;
  69230. /**
  69231. * (Likely devicePosition should be used instead) The device position in its room space
  69232. */
  69233. position: Vector3;
  69234. /**
  69235. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69236. */
  69237. rotationQuaternion: Quaternion;
  69238. /**
  69239. * The type of controller (Eg. Windows mixed reality)
  69240. */
  69241. controllerType: PoseEnabledControllerType;
  69242. protected _calculatedPosition: Vector3;
  69243. private _calculatedRotation;
  69244. /**
  69245. * The raw pose from the device
  69246. */
  69247. rawPose: DevicePose;
  69248. private _trackPosition;
  69249. private _maxRotationDistFromHeadset;
  69250. private _draggedRoomRotation;
  69251. /**
  69252. * @hidden
  69253. */
  69254. _disableTrackPosition(fixedPosition: Vector3): void;
  69255. /**
  69256. * Internal, the mesh attached to the controller
  69257. * @hidden
  69258. */
  69259. _mesh: Nullable<AbstractMesh>;
  69260. private _poseControlledCamera;
  69261. private _leftHandSystemQuaternion;
  69262. /**
  69263. * Internal, matrix used to convert room space to babylon space
  69264. * @hidden
  69265. */
  69266. _deviceToWorld: Matrix;
  69267. /**
  69268. * Node to be used when casting a ray from the controller
  69269. * @hidden
  69270. */
  69271. _pointingPoseNode: Nullable<TransformNode>;
  69272. /**
  69273. * Name of the child mesh that can be used to cast a ray from the controller
  69274. */
  69275. static readonly POINTING_POSE: string;
  69276. /**
  69277. * Creates a new PoseEnabledController from a gamepad
  69278. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69279. */
  69280. constructor(browserGamepad: any);
  69281. private _workingMatrix;
  69282. /**
  69283. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69284. */
  69285. update(): void;
  69286. /**
  69287. * Updates only the pose device and mesh without doing any button event checking
  69288. */
  69289. protected _updatePoseAndMesh(): void;
  69290. /**
  69291. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69292. * @param poseData raw pose fromthe device
  69293. */
  69294. updateFromDevice(poseData: DevicePose): void;
  69295. /**
  69296. * @hidden
  69297. */
  69298. _meshAttachedObservable: Observable<AbstractMesh>;
  69299. /**
  69300. * Attaches a mesh to the controller
  69301. * @param mesh the mesh to be attached
  69302. */
  69303. attachToMesh(mesh: AbstractMesh): void;
  69304. /**
  69305. * Attaches the controllers mesh to a camera
  69306. * @param camera the camera the mesh should be attached to
  69307. */
  69308. attachToPoseControlledCamera(camera: TargetCamera): void;
  69309. /**
  69310. * Disposes of the controller
  69311. */
  69312. dispose(): void;
  69313. /**
  69314. * The mesh that is attached to the controller
  69315. */
  69316. readonly mesh: Nullable<AbstractMesh>;
  69317. /**
  69318. * Gets the ray of the controller in the direction the controller is pointing
  69319. * @param length the length the resulting ray should be
  69320. * @returns a ray in the direction the controller is pointing
  69321. */
  69322. getForwardRay(length?: number): Ray;
  69323. }
  69324. }
  69325. declare module BABYLON {
  69326. /**
  69327. * Defines the WebVRController object that represents controllers tracked in 3D space
  69328. */
  69329. export abstract class WebVRController extends PoseEnabledController {
  69330. /**
  69331. * Internal, the default controller model for the controller
  69332. */
  69333. protected _defaultModel: AbstractMesh;
  69334. /**
  69335. * Fired when the trigger state has changed
  69336. */
  69337. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69338. /**
  69339. * Fired when the main button state has changed
  69340. */
  69341. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69342. /**
  69343. * Fired when the secondary button state has changed
  69344. */
  69345. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69346. /**
  69347. * Fired when the pad state has changed
  69348. */
  69349. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69350. /**
  69351. * Fired when controllers stick values have changed
  69352. */
  69353. onPadValuesChangedObservable: Observable<StickValues>;
  69354. /**
  69355. * Array of button availible on the controller
  69356. */
  69357. protected _buttons: Array<MutableGamepadButton>;
  69358. private _onButtonStateChange;
  69359. /**
  69360. * Fired when a controller button's state has changed
  69361. * @param callback the callback containing the button that was modified
  69362. */
  69363. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69364. /**
  69365. * X and Y axis corrisponding to the controllers joystick
  69366. */
  69367. pad: StickValues;
  69368. /**
  69369. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69370. */
  69371. hand: string;
  69372. /**
  69373. * The default controller model for the controller
  69374. */
  69375. readonly defaultModel: AbstractMesh;
  69376. /**
  69377. * Creates a new WebVRController from a gamepad
  69378. * @param vrGamepad the gamepad that the WebVRController should be created from
  69379. */
  69380. constructor(vrGamepad: any);
  69381. /**
  69382. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69383. */
  69384. update(): void;
  69385. /**
  69386. * Function to be called when a button is modified
  69387. */
  69388. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69389. /**
  69390. * Loads a mesh and attaches it to the controller
  69391. * @param scene the scene the mesh should be added to
  69392. * @param meshLoaded callback for when the mesh has been loaded
  69393. */
  69394. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69395. private _setButtonValue;
  69396. private _changes;
  69397. private _checkChanges;
  69398. /**
  69399. * Disposes of th webVRCOntroller
  69400. */
  69401. dispose(): void;
  69402. }
  69403. }
  69404. declare module BABYLON {
  69405. /**
  69406. * The HemisphericLight simulates the ambient environment light,
  69407. * so the passed direction is the light reflection direction, not the incoming direction.
  69408. */
  69409. export class HemisphericLight extends Light {
  69410. /**
  69411. * The groundColor is the light in the opposite direction to the one specified during creation.
  69412. * 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.
  69413. */
  69414. groundColor: Color3;
  69415. /**
  69416. * The light reflection direction, not the incoming direction.
  69417. */
  69418. direction: Vector3;
  69419. /**
  69420. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69421. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69422. * The HemisphericLight can't cast shadows.
  69423. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69424. * @param name The friendly name of the light
  69425. * @param direction The direction of the light reflection
  69426. * @param scene The scene the light belongs to
  69427. */
  69428. constructor(name: string, direction: Vector3, scene: Scene);
  69429. protected _buildUniformLayout(): void;
  69430. /**
  69431. * Returns the string "HemisphericLight".
  69432. * @return The class name
  69433. */
  69434. getClassName(): string;
  69435. /**
  69436. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69437. * Returns the updated direction.
  69438. * @param target The target the direction should point to
  69439. * @return The computed direction
  69440. */
  69441. setDirectionToTarget(target: Vector3): Vector3;
  69442. /**
  69443. * Returns the shadow generator associated to the light.
  69444. * @returns Always null for hemispheric lights because it does not support shadows.
  69445. */
  69446. getShadowGenerator(): Nullable<IShadowGenerator>;
  69447. /**
  69448. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69449. * @param effect The effect to update
  69450. * @param lightIndex The index of the light in the effect to update
  69451. * @returns The hemispheric light
  69452. */
  69453. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69454. /**
  69455. * Computes the world matrix of the node
  69456. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69457. * @param useWasUpdatedFlag defines a reserved property
  69458. * @returns the world matrix
  69459. */
  69460. computeWorldMatrix(): Matrix;
  69461. /**
  69462. * Returns the integer 3.
  69463. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69464. */
  69465. getTypeID(): number;
  69466. /**
  69467. * Prepares the list of defines specific to the light type.
  69468. * @param defines the list of defines
  69469. * @param lightIndex defines the index of the light for the effect
  69470. */
  69471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69472. }
  69473. }
  69474. declare module BABYLON {
  69475. /**
  69476. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69477. * IMPORTANT!! The data is right-hand data.
  69478. * @export
  69479. * @interface DevicePose
  69480. */
  69481. export interface DevicePose {
  69482. /**
  69483. * The position of the device, values in array are [x,y,z].
  69484. */
  69485. readonly position: Nullable<Float32Array>;
  69486. /**
  69487. * The linearVelocity of the device, values in array are [x,y,z].
  69488. */
  69489. readonly linearVelocity: Nullable<Float32Array>;
  69490. /**
  69491. * The linearAcceleration of the device, values in array are [x,y,z].
  69492. */
  69493. readonly linearAcceleration: Nullable<Float32Array>;
  69494. /**
  69495. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69496. */
  69497. readonly orientation: Nullable<Float32Array>;
  69498. /**
  69499. * The angularVelocity of the device, values in array are [x,y,z].
  69500. */
  69501. readonly angularVelocity: Nullable<Float32Array>;
  69502. /**
  69503. * The angularAcceleration of the device, values in array are [x,y,z].
  69504. */
  69505. readonly angularAcceleration: Nullable<Float32Array>;
  69506. }
  69507. /**
  69508. * Interface representing a pose controlled object in Babylon.
  69509. * A pose controlled object has both regular pose values as well as pose values
  69510. * from an external device such as a VR head mounted display
  69511. */
  69512. export interface PoseControlled {
  69513. /**
  69514. * The position of the object in babylon space.
  69515. */
  69516. position: Vector3;
  69517. /**
  69518. * The rotation quaternion of the object in babylon space.
  69519. */
  69520. rotationQuaternion: Quaternion;
  69521. /**
  69522. * The position of the device in babylon space.
  69523. */
  69524. devicePosition?: Vector3;
  69525. /**
  69526. * The rotation quaternion of the device in babylon space.
  69527. */
  69528. deviceRotationQuaternion: Quaternion;
  69529. /**
  69530. * The raw pose coming from the device.
  69531. */
  69532. rawPose: Nullable<DevicePose>;
  69533. /**
  69534. * The scale of the device to be used when translating from device space to babylon space.
  69535. */
  69536. deviceScaleFactor: number;
  69537. /**
  69538. * Updates the poseControlled values based on the input device pose.
  69539. * @param poseData the pose data to update the object with
  69540. */
  69541. updateFromDevice(poseData: DevicePose): void;
  69542. }
  69543. /**
  69544. * Set of options to customize the webVRCamera
  69545. */
  69546. export interface WebVROptions {
  69547. /**
  69548. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69549. */
  69550. trackPosition?: boolean;
  69551. /**
  69552. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69553. */
  69554. positionScale?: number;
  69555. /**
  69556. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69557. */
  69558. displayName?: string;
  69559. /**
  69560. * Should the native controller meshes be initialized. (default: true)
  69561. */
  69562. controllerMeshes?: boolean;
  69563. /**
  69564. * Creating a default HemiLight only on controllers. (default: true)
  69565. */
  69566. defaultLightingOnControllers?: boolean;
  69567. /**
  69568. * If you don't want to use the default VR button of the helper. (default: false)
  69569. */
  69570. useCustomVRButton?: boolean;
  69571. /**
  69572. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69573. */
  69574. customVRButton?: HTMLButtonElement;
  69575. /**
  69576. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69577. */
  69578. rayLength?: number;
  69579. /**
  69580. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69581. */
  69582. defaultHeight?: number;
  69583. }
  69584. /**
  69585. * This represents a WebVR camera.
  69586. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69587. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69588. */
  69589. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69590. private webVROptions;
  69591. /**
  69592. * @hidden
  69593. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69594. */
  69595. _vrDevice: any;
  69596. /**
  69597. * The rawPose of the vrDevice.
  69598. */
  69599. rawPose: Nullable<DevicePose>;
  69600. private _onVREnabled;
  69601. private _specsVersion;
  69602. private _attached;
  69603. private _frameData;
  69604. protected _descendants: Array<Node>;
  69605. private _deviceRoomPosition;
  69606. /** @hidden */
  69607. _deviceRoomRotationQuaternion: Quaternion;
  69608. private _standingMatrix;
  69609. /**
  69610. * Represents device position in babylon space.
  69611. */
  69612. devicePosition: Vector3;
  69613. /**
  69614. * Represents device rotation in babylon space.
  69615. */
  69616. deviceRotationQuaternion: Quaternion;
  69617. /**
  69618. * The scale of the device to be used when translating from device space to babylon space.
  69619. */
  69620. deviceScaleFactor: number;
  69621. private _deviceToWorld;
  69622. private _worldToDevice;
  69623. /**
  69624. * References to the webVR controllers for the vrDevice.
  69625. */
  69626. controllers: Array<WebVRController>;
  69627. /**
  69628. * Emits an event when a controller is attached.
  69629. */
  69630. onControllersAttachedObservable: Observable<WebVRController[]>;
  69631. /**
  69632. * Emits an event when a controller's mesh has been loaded;
  69633. */
  69634. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69635. /**
  69636. * Emits an event when the HMD's pose has been updated.
  69637. */
  69638. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69639. private _poseSet;
  69640. /**
  69641. * If the rig cameras be used as parent instead of this camera.
  69642. */
  69643. rigParenting: boolean;
  69644. private _lightOnControllers;
  69645. private _defaultHeight?;
  69646. /**
  69647. * Instantiates a WebVRFreeCamera.
  69648. * @param name The name of the WebVRFreeCamera
  69649. * @param position The starting anchor position for the camera
  69650. * @param scene The scene the camera belongs to
  69651. * @param webVROptions a set of customizable options for the webVRCamera
  69652. */
  69653. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69654. /**
  69655. * Gets the device distance from the ground in meters.
  69656. * @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.
  69657. */
  69658. deviceDistanceToRoomGround(): number;
  69659. /**
  69660. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69661. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69662. */
  69663. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69664. /**
  69665. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69666. * @returns A promise with a boolean set to if the standing matrix is supported.
  69667. */
  69668. useStandingMatrixAsync(): Promise<boolean>;
  69669. /**
  69670. * Disposes the camera
  69671. */
  69672. dispose(): void;
  69673. /**
  69674. * Gets a vrController by name.
  69675. * @param name The name of the controller to retreive
  69676. * @returns the controller matching the name specified or null if not found
  69677. */
  69678. getControllerByName(name: string): Nullable<WebVRController>;
  69679. private _leftController;
  69680. /**
  69681. * The controller corrisponding to the users left hand.
  69682. */
  69683. readonly leftController: Nullable<WebVRController>;
  69684. private _rightController;
  69685. /**
  69686. * The controller corrisponding to the users right hand.
  69687. */
  69688. readonly rightController: Nullable<WebVRController>;
  69689. /**
  69690. * Casts a ray forward from the vrCamera's gaze.
  69691. * @param length Length of the ray (default: 100)
  69692. * @returns the ray corrisponding to the gaze
  69693. */
  69694. getForwardRay(length?: number): Ray;
  69695. /**
  69696. * @hidden
  69697. * Updates the camera based on device's frame data
  69698. */
  69699. _checkInputs(): void;
  69700. /**
  69701. * Updates the poseControlled values based on the input device pose.
  69702. * @param poseData Pose coming from the device
  69703. */
  69704. updateFromDevice(poseData: DevicePose): void;
  69705. private _htmlElementAttached;
  69706. private _detachIfAttached;
  69707. /**
  69708. * WebVR's attach control will start broadcasting frames to the device.
  69709. * Note that in certain browsers (chrome for example) this function must be called
  69710. * within a user-interaction callback. Example:
  69711. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69712. *
  69713. * @param element html element to attach the vrDevice to
  69714. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69715. */
  69716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69717. /**
  69718. * Detaches the camera from the html element and disables VR
  69719. *
  69720. * @param element html element to detach from
  69721. */
  69722. detachControl(element: HTMLElement): void;
  69723. /**
  69724. * @returns the name of this class
  69725. */
  69726. getClassName(): string;
  69727. /**
  69728. * Calls resetPose on the vrDisplay
  69729. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69730. */
  69731. resetToCurrentRotation(): void;
  69732. /**
  69733. * @hidden
  69734. * Updates the rig cameras (left and right eye)
  69735. */
  69736. _updateRigCameras(): void;
  69737. private _workingVector;
  69738. private _oneVector;
  69739. private _workingMatrix;
  69740. private updateCacheCalled;
  69741. private _correctPositionIfNotTrackPosition;
  69742. /**
  69743. * @hidden
  69744. * Updates the cached values of the camera
  69745. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69746. */
  69747. _updateCache(ignoreParentClass?: boolean): void;
  69748. /**
  69749. * @hidden
  69750. * Get current device position in babylon world
  69751. */
  69752. _computeDevicePosition(): void;
  69753. /**
  69754. * Updates the current device position and rotation in the babylon world
  69755. */
  69756. update(): void;
  69757. /**
  69758. * @hidden
  69759. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69760. * @returns an identity matrix
  69761. */
  69762. _getViewMatrix(): Matrix;
  69763. private _tmpMatrix;
  69764. /**
  69765. * This function is called by the two RIG cameras.
  69766. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69767. * @hidden
  69768. */
  69769. _getWebVRViewMatrix(): Matrix;
  69770. /** @hidden */
  69771. _getWebVRProjectionMatrix(): Matrix;
  69772. private _onGamepadConnectedObserver;
  69773. private _onGamepadDisconnectedObserver;
  69774. private _updateCacheWhenTrackingDisabledObserver;
  69775. /**
  69776. * Initializes the controllers and their meshes
  69777. */
  69778. initControllers(): void;
  69779. }
  69780. }
  69781. declare module BABYLON {
  69782. /**
  69783. * Size options for a post process
  69784. */
  69785. export type PostProcessOptions = {
  69786. width: number;
  69787. height: number;
  69788. };
  69789. /**
  69790. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69791. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69792. */
  69793. export class PostProcess {
  69794. /** Name of the PostProcess. */
  69795. name: string;
  69796. /**
  69797. * Width of the texture to apply the post process on
  69798. */
  69799. width: number;
  69800. /**
  69801. * Height of the texture to apply the post process on
  69802. */
  69803. height: number;
  69804. /**
  69805. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69806. * @hidden
  69807. */
  69808. _outputTexture: Nullable<InternalTexture>;
  69809. /**
  69810. * Sampling mode used by the shader
  69811. * See https://doc.babylonjs.com/classes/3.1/texture
  69812. */
  69813. renderTargetSamplingMode: number;
  69814. /**
  69815. * Clear color to use when screen clearing
  69816. */
  69817. clearColor: Color4;
  69818. /**
  69819. * If the buffer needs to be cleared before applying the post process. (default: true)
  69820. * Should be set to false if shader will overwrite all previous pixels.
  69821. */
  69822. autoClear: boolean;
  69823. /**
  69824. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69825. */
  69826. alphaMode: number;
  69827. /**
  69828. * Sets the setAlphaBlendConstants of the babylon engine
  69829. */
  69830. alphaConstants: Color4;
  69831. /**
  69832. * Animations to be used for the post processing
  69833. */
  69834. animations: Animation[];
  69835. /**
  69836. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69837. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69838. */
  69839. enablePixelPerfectMode: boolean;
  69840. /**
  69841. * Force the postprocess to be applied without taking in account viewport
  69842. */
  69843. forceFullscreenViewport: boolean;
  69844. /**
  69845. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69846. *
  69847. * | Value | Type | Description |
  69848. * | ----- | ----------------------------------- | ----------- |
  69849. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69850. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69851. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69852. *
  69853. */
  69854. scaleMode: number;
  69855. /**
  69856. * Force textures to be a power of two (default: false)
  69857. */
  69858. alwaysForcePOT: boolean;
  69859. private _samples;
  69860. /**
  69861. * Number of sample textures (default: 1)
  69862. */
  69863. samples: number;
  69864. /**
  69865. * Modify the scale of the post process to be the same as the viewport (default: false)
  69866. */
  69867. adaptScaleToCurrentViewport: boolean;
  69868. private _camera;
  69869. private _scene;
  69870. private _engine;
  69871. private _options;
  69872. private _reusable;
  69873. private _textureType;
  69874. /**
  69875. * Smart array of input and output textures for the post process.
  69876. * @hidden
  69877. */
  69878. _textures: SmartArray<InternalTexture>;
  69879. /**
  69880. * The index in _textures that corresponds to the output texture.
  69881. * @hidden
  69882. */
  69883. _currentRenderTextureInd: number;
  69884. private _effect;
  69885. private _samplers;
  69886. private _fragmentUrl;
  69887. private _vertexUrl;
  69888. private _parameters;
  69889. private _scaleRatio;
  69890. protected _indexParameters: any;
  69891. private _shareOutputWithPostProcess;
  69892. private _texelSize;
  69893. private _forcedOutputTexture;
  69894. /**
  69895. * Returns the fragment url or shader name used in the post process.
  69896. * @returns the fragment url or name in the shader store.
  69897. */
  69898. getEffectName(): string;
  69899. /**
  69900. * An event triggered when the postprocess is activated.
  69901. */
  69902. onActivateObservable: Observable<Camera>;
  69903. private _onActivateObserver;
  69904. /**
  69905. * A function that is added to the onActivateObservable
  69906. */
  69907. onActivate: Nullable<(camera: Camera) => void>;
  69908. /**
  69909. * An event triggered when the postprocess changes its size.
  69910. */
  69911. onSizeChangedObservable: Observable<PostProcess>;
  69912. private _onSizeChangedObserver;
  69913. /**
  69914. * A function that is added to the onSizeChangedObservable
  69915. */
  69916. onSizeChanged: (postProcess: PostProcess) => void;
  69917. /**
  69918. * An event triggered when the postprocess applies its effect.
  69919. */
  69920. onApplyObservable: Observable<Effect>;
  69921. private _onApplyObserver;
  69922. /**
  69923. * A function that is added to the onApplyObservable
  69924. */
  69925. onApply: (effect: Effect) => void;
  69926. /**
  69927. * An event triggered before rendering the postprocess
  69928. */
  69929. onBeforeRenderObservable: Observable<Effect>;
  69930. private _onBeforeRenderObserver;
  69931. /**
  69932. * A function that is added to the onBeforeRenderObservable
  69933. */
  69934. onBeforeRender: (effect: Effect) => void;
  69935. /**
  69936. * An event triggered after rendering the postprocess
  69937. */
  69938. onAfterRenderObservable: Observable<Effect>;
  69939. private _onAfterRenderObserver;
  69940. /**
  69941. * A function that is added to the onAfterRenderObservable
  69942. */
  69943. onAfterRender: (efect: Effect) => void;
  69944. /**
  69945. * 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
  69946. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  69947. */
  69948. inputTexture: InternalTexture;
  69949. /**
  69950. * Gets the camera which post process is applied to.
  69951. * @returns The camera the post process is applied to.
  69952. */
  69953. getCamera(): Camera;
  69954. /**
  69955. * Gets the texel size of the postprocess.
  69956. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  69957. */
  69958. readonly texelSize: Vector2;
  69959. /**
  69960. * Creates a new instance PostProcess
  69961. * @param name The name of the PostProcess.
  69962. * @param fragmentUrl The url of the fragment shader to be used.
  69963. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  69964. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  69965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69966. * @param camera The camera to apply the render pass to.
  69967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69968. * @param engine The engine which the post process will be applied. (default: current engine)
  69969. * @param reusable If the post process can be reused on the same frame. (default: false)
  69970. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  69971. * @param textureType Type of textures used when performing the post process. (default: 0)
  69972. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  69973. * @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
  69974. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  69975. */
  69976. constructor(
  69977. /** Name of the PostProcess. */
  69978. 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);
  69979. /**
  69980. * Gets the engine which this post process belongs to.
  69981. * @returns The engine the post process was enabled with.
  69982. */
  69983. getEngine(): Engine;
  69984. /**
  69985. * The effect that is created when initializing the post process.
  69986. * @returns The created effect corrisponding the the postprocess.
  69987. */
  69988. getEffect(): Effect;
  69989. /**
  69990. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  69991. * @param postProcess The post process to share the output with.
  69992. * @returns This post process.
  69993. */
  69994. shareOutputWith(postProcess: PostProcess): PostProcess;
  69995. /**
  69996. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  69997. * This should be called if the post process that shares output with this post process is disabled/disposed.
  69998. */
  69999. useOwnOutput(): void;
  70000. /**
  70001. * Updates the effect with the current post process compile time values and recompiles the shader.
  70002. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70003. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70004. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70005. * @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
  70006. * @param onCompiled Called when the shader has been compiled.
  70007. * @param onError Called if there is an error when compiling a shader.
  70008. */
  70009. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70010. /**
  70011. * The post process is reusable if it can be used multiple times within one frame.
  70012. * @returns If the post process is reusable
  70013. */
  70014. isReusable(): boolean;
  70015. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70016. markTextureDirty(): void;
  70017. /**
  70018. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70019. * 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.
  70020. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70021. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70022. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70023. * @returns The target texture that was bound to be written to.
  70024. */
  70025. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70026. /**
  70027. * If the post process is supported.
  70028. */
  70029. readonly isSupported: boolean;
  70030. /**
  70031. * The aspect ratio of the output texture.
  70032. */
  70033. readonly aspectRatio: number;
  70034. /**
  70035. * Get a value indicating if the post-process is ready to be used
  70036. * @returns true if the post-process is ready (shader is compiled)
  70037. */
  70038. isReady(): boolean;
  70039. /**
  70040. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70041. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70042. */
  70043. apply(): Nullable<Effect>;
  70044. private _disposeTextures;
  70045. /**
  70046. * Disposes the post process.
  70047. * @param camera The camera to dispose the post process on.
  70048. */
  70049. dispose(camera?: Camera): void;
  70050. }
  70051. }
  70052. declare module BABYLON {
  70053. /**
  70054. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70055. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70056. */
  70057. export class PostProcessManager {
  70058. private _scene;
  70059. private _indexBuffer;
  70060. private _vertexBuffers;
  70061. /**
  70062. * Creates a new instance PostProcess
  70063. * @param scene The scene that the post process is associated with.
  70064. */
  70065. constructor(scene: Scene);
  70066. private _prepareBuffers;
  70067. private _buildIndexBuffer;
  70068. /**
  70069. * Rebuilds the vertex buffers of the manager.
  70070. * @hidden
  70071. */
  70072. _rebuild(): void;
  70073. /**
  70074. * Prepares a frame to be run through a post process.
  70075. * @param sourceTexture The input texture to the post procesess. (default: null)
  70076. * @param postProcesses An array of post processes to be run. (default: null)
  70077. * @returns True if the post processes were able to be run.
  70078. * @hidden
  70079. */
  70080. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70081. /**
  70082. * Manually render a set of post processes to a texture.
  70083. * @param postProcesses An array of post processes to be run.
  70084. * @param targetTexture The target texture to render to.
  70085. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70086. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70087. * @param lodLevel defines which lod of the texture to render to
  70088. */
  70089. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70090. /**
  70091. * Finalize the result of the output of the postprocesses.
  70092. * @param doNotPresent If true the result will not be displayed to the screen.
  70093. * @param targetTexture The target texture to render to.
  70094. * @param faceIndex The index of the face to bind the target texture to.
  70095. * @param postProcesses The array of post processes to render.
  70096. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70097. * @hidden
  70098. */
  70099. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70100. /**
  70101. * Disposes of the post process manager.
  70102. */
  70103. dispose(): void;
  70104. }
  70105. }
  70106. declare module BABYLON {
  70107. /**
  70108. * Raw texture can help creating a texture directly from an array of data.
  70109. * This can be super useful if you either get the data from an uncompressed source or
  70110. * if you wish to create your texture pixel by pixel.
  70111. */
  70112. export class RawTexture extends Texture {
  70113. /**
  70114. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70115. */
  70116. format: number;
  70117. private _engine;
  70118. /**
  70119. * Instantiates a new RawTexture.
  70120. * Raw texture can help creating a texture directly from an array of data.
  70121. * This can be super useful if you either get the data from an uncompressed source or
  70122. * if you wish to create your texture pixel by pixel.
  70123. * @param data define the array of data to use to create the texture
  70124. * @param width define the width of the texture
  70125. * @param height define the height of the texture
  70126. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70127. * @param scene define the scene the texture belongs to
  70128. * @param generateMipMaps define whether mip maps should be generated or not
  70129. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70130. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70131. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70132. */
  70133. constructor(data: ArrayBufferView, width: number, height: number,
  70134. /**
  70135. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70136. */
  70137. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  70138. /**
  70139. * Updates the texture underlying data.
  70140. * @param data Define the new data of the texture
  70141. */
  70142. update(data: ArrayBufferView): void;
  70143. /**
  70144. * Creates a luminance texture from some data.
  70145. * @param data Define the texture data
  70146. * @param width Define the width of the texture
  70147. * @param height Define the height of the texture
  70148. * @param scene Define the scene the texture belongs to
  70149. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70150. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70151. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70152. * @returns the luminance texture
  70153. */
  70154. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70155. /**
  70156. * Creates a luminance alpha texture from some data.
  70157. * @param data Define the texture data
  70158. * @param width Define the width of the texture
  70159. * @param height Define the height of the texture
  70160. * @param scene Define the scene the texture belongs to
  70161. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70162. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70163. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70164. * @returns the luminance alpha texture
  70165. */
  70166. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70167. /**
  70168. * Creates an alpha texture from some data.
  70169. * @param data Define the texture data
  70170. * @param width Define the width of the texture
  70171. * @param height Define the height of the texture
  70172. * @param scene Define the scene the texture belongs to
  70173. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70174. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70175. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70176. * @returns the alpha texture
  70177. */
  70178. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70179. /**
  70180. * Creates a RGB texture from some data.
  70181. * @param data Define the texture data
  70182. * @param width Define the width of the texture
  70183. * @param height Define the height of the texture
  70184. * @param scene Define the scene the texture belongs to
  70185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70188. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70189. * @returns the RGB alpha texture
  70190. */
  70191. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70192. /**
  70193. * Creates a RGBA texture from some data.
  70194. * @param data Define the texture data
  70195. * @param width Define the width of the texture
  70196. * @param height Define the height of the texture
  70197. * @param scene Define the scene the texture belongs to
  70198. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70199. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70200. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70201. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70202. * @returns the RGBA texture
  70203. */
  70204. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70205. /**
  70206. * Creates a R texture from some data.
  70207. * @param data Define the texture data
  70208. * @param width Define the width of the texture
  70209. * @param height Define the height of the texture
  70210. * @param scene Define the scene the texture belongs to
  70211. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70212. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70213. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70214. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70215. * @returns the R texture
  70216. */
  70217. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70218. }
  70219. }
  70220. declare module BABYLON {
  70221. interface AbstractScene {
  70222. /**
  70223. * The list of layers (background and foreground) of the scene
  70224. */
  70225. layers: Array<Layer>;
  70226. }
  70227. /**
  70228. * Defines the layer scene component responsible to manage any layers
  70229. * in a given scene.
  70230. */
  70231. export class LayerSceneComponent implements ISceneComponent {
  70232. /**
  70233. * The component name helpfull to identify the component in the list of scene components.
  70234. */
  70235. readonly name: string;
  70236. /**
  70237. * The scene the component belongs to.
  70238. */
  70239. scene: Scene;
  70240. private _engine;
  70241. /**
  70242. * Creates a new instance of the component for the given scene
  70243. * @param scene Defines the scene to register the component in
  70244. */
  70245. constructor(scene: Scene);
  70246. /**
  70247. * Registers the component in a given scene
  70248. */
  70249. register(): void;
  70250. /**
  70251. * Rebuilds the elements related to this component in case of
  70252. * context lost for instance.
  70253. */
  70254. rebuild(): void;
  70255. /**
  70256. * Disposes the component and the associated ressources.
  70257. */
  70258. dispose(): void;
  70259. private _draw;
  70260. private _drawCameraPredicate;
  70261. private _drawCameraBackground;
  70262. private _drawCameraForeground;
  70263. private _drawRenderTargetPredicate;
  70264. private _drawRenderTargetBackground;
  70265. private _drawRenderTargetForeground;
  70266. }
  70267. }
  70268. declare module BABYLON {
  70269. /** @hidden */
  70270. export var layerPixelShader: {
  70271. name: string;
  70272. shader: string;
  70273. };
  70274. }
  70275. declare module BABYLON {
  70276. /** @hidden */
  70277. export var layerVertexShader: {
  70278. name: string;
  70279. shader: string;
  70280. };
  70281. }
  70282. declare module BABYLON {
  70283. /**
  70284. * This represents a full screen 2d layer.
  70285. * This can be useful to display a picture in the background of your scene for instance.
  70286. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70287. */
  70288. export class Layer {
  70289. /**
  70290. * Define the name of the layer.
  70291. */
  70292. name: string;
  70293. /**
  70294. * Define the texture the layer should display.
  70295. */
  70296. texture: Nullable<Texture>;
  70297. /**
  70298. * Is the layer in background or foreground.
  70299. */
  70300. isBackground: boolean;
  70301. /**
  70302. * Define the color of the layer (instead of texture).
  70303. */
  70304. color: Color4;
  70305. /**
  70306. * Define the scale of the layer in order to zoom in out of the texture.
  70307. */
  70308. scale: Vector2;
  70309. /**
  70310. * Define an offset for the layer in order to shift the texture.
  70311. */
  70312. offset: Vector2;
  70313. /**
  70314. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70315. */
  70316. alphaBlendingMode: number;
  70317. /**
  70318. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70319. * Alpha test will not mix with the background color in case of transparency.
  70320. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70321. */
  70322. alphaTest: boolean;
  70323. /**
  70324. * Define a mask to restrict the layer to only some of the scene cameras.
  70325. */
  70326. layerMask: number;
  70327. /**
  70328. * Define the list of render target the layer is visible into.
  70329. */
  70330. renderTargetTextures: RenderTargetTexture[];
  70331. /**
  70332. * Define if the layer is only used in renderTarget or if it also
  70333. * renders in the main frame buffer of the canvas.
  70334. */
  70335. renderOnlyInRenderTargetTextures: boolean;
  70336. private _scene;
  70337. private _vertexBuffers;
  70338. private _indexBuffer;
  70339. private _effect;
  70340. private _alphaTestEffect;
  70341. /**
  70342. * An event triggered when the layer is disposed.
  70343. */
  70344. onDisposeObservable: Observable<Layer>;
  70345. private _onDisposeObserver;
  70346. /**
  70347. * Back compatibility with callback before the onDisposeObservable existed.
  70348. * The set callback will be triggered when the layer has been disposed.
  70349. */
  70350. onDispose: () => void;
  70351. /**
  70352. * An event triggered before rendering the scene
  70353. */
  70354. onBeforeRenderObservable: Observable<Layer>;
  70355. private _onBeforeRenderObserver;
  70356. /**
  70357. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70358. * The set callback will be triggered just before rendering the layer.
  70359. */
  70360. onBeforeRender: () => void;
  70361. /**
  70362. * An event triggered after rendering the scene
  70363. */
  70364. onAfterRenderObservable: Observable<Layer>;
  70365. private _onAfterRenderObserver;
  70366. /**
  70367. * Back compatibility with callback before the onAfterRenderObservable existed.
  70368. * The set callback will be triggered just after rendering the layer.
  70369. */
  70370. onAfterRender: () => void;
  70371. /**
  70372. * Instantiates a new layer.
  70373. * This represents a full screen 2d layer.
  70374. * This can be useful to display a picture in the background of your scene for instance.
  70375. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70376. * @param name Define the name of the layer in the scene
  70377. * @param imgUrl Define the url of the texture to display in the layer
  70378. * @param scene Define the scene the layer belongs to
  70379. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70380. * @param color Defines a color for the layer
  70381. */
  70382. constructor(
  70383. /**
  70384. * Define the name of the layer.
  70385. */
  70386. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70387. private _createIndexBuffer;
  70388. /** @hidden */
  70389. _rebuild(): void;
  70390. /**
  70391. * Renders the layer in the scene.
  70392. */
  70393. render(): void;
  70394. /**
  70395. * Disposes and releases the associated ressources.
  70396. */
  70397. dispose(): void;
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. interface AbstractScene {
  70402. /**
  70403. * The list of procedural textures added to the scene
  70404. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70405. */
  70406. proceduralTextures: Array<ProceduralTexture>;
  70407. }
  70408. /**
  70409. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70410. * in a given scene.
  70411. */
  70412. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70413. /**
  70414. * The component name helpfull to identify the component in the list of scene components.
  70415. */
  70416. readonly name: string;
  70417. /**
  70418. * The scene the component belongs to.
  70419. */
  70420. scene: Scene;
  70421. /**
  70422. * Creates a new instance of the component for the given scene
  70423. * @param scene Defines the scene to register the component in
  70424. */
  70425. constructor(scene: Scene);
  70426. /**
  70427. * Registers the component in a given scene
  70428. */
  70429. register(): void;
  70430. /**
  70431. * Rebuilds the elements related to this component in case of
  70432. * context lost for instance.
  70433. */
  70434. rebuild(): void;
  70435. /**
  70436. * Disposes the component and the associated ressources.
  70437. */
  70438. dispose(): void;
  70439. private _beforeClear;
  70440. }
  70441. }
  70442. declare module BABYLON {
  70443. /** @hidden */
  70444. export var proceduralVertexShader: {
  70445. name: string;
  70446. shader: string;
  70447. };
  70448. }
  70449. declare module BABYLON {
  70450. /**
  70451. * 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.
  70452. * This is the base class of any Procedural texture and contains most of the shareable code.
  70453. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70454. */
  70455. export class ProceduralTexture extends Texture {
  70456. isCube: boolean;
  70457. /**
  70458. * Define if the texture is enabled or not (disabled texture will not render)
  70459. */
  70460. isEnabled: boolean;
  70461. /**
  70462. * Define if the texture must be cleared before rendering (default is true)
  70463. */
  70464. autoClear: boolean;
  70465. /**
  70466. * Callback called when the texture is generated
  70467. */
  70468. onGenerated: () => void;
  70469. /**
  70470. * Event raised when the texture is generated
  70471. */
  70472. onGeneratedObservable: Observable<ProceduralTexture>;
  70473. /** @hidden */
  70474. _generateMipMaps: boolean;
  70475. /** @hidden **/
  70476. _effect: Effect;
  70477. /** @hidden */
  70478. _textures: {
  70479. [key: string]: Texture;
  70480. };
  70481. private _size;
  70482. private _currentRefreshId;
  70483. private _refreshRate;
  70484. private _vertexBuffers;
  70485. private _indexBuffer;
  70486. private _uniforms;
  70487. private _samplers;
  70488. private _fragment;
  70489. private _floats;
  70490. private _ints;
  70491. private _floatsArrays;
  70492. private _colors3;
  70493. private _colors4;
  70494. private _vectors2;
  70495. private _vectors3;
  70496. private _matrices;
  70497. private _fallbackTexture;
  70498. private _fallbackTextureUsed;
  70499. private _engine;
  70500. private _cachedDefines;
  70501. private _contentUpdateId;
  70502. private _contentData;
  70503. /**
  70504. * Instantiates a new procedural texture.
  70505. * 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.
  70506. * This is the base class of any Procedural texture and contains most of the shareable code.
  70507. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70508. * @param name Define the name of the texture
  70509. * @param size Define the size of the texture to create
  70510. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70511. * @param scene Define the scene the texture belongs to
  70512. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70513. * @param generateMipMaps Define if the texture should creates mip maps or not
  70514. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70515. */
  70516. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70517. /**
  70518. * The effect that is created when initializing the post process.
  70519. * @returns The created effect corrisponding the the postprocess.
  70520. */
  70521. getEffect(): Effect;
  70522. /**
  70523. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70524. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70525. */
  70526. getContent(): Nullable<ArrayBufferView>;
  70527. private _createIndexBuffer;
  70528. /** @hidden */
  70529. _rebuild(): void;
  70530. /**
  70531. * Resets the texture in order to recreate its associated resources.
  70532. * This can be called in case of context loss
  70533. */
  70534. reset(): void;
  70535. protected _getDefines(): string;
  70536. /**
  70537. * Is the texture ready to be used ? (rendered at least once)
  70538. * @returns true if ready, otherwise, false.
  70539. */
  70540. isReady(): boolean;
  70541. /**
  70542. * Resets the refresh counter of the texture and start bak from scratch.
  70543. * Could be useful to regenerate the texture if it is setup to render only once.
  70544. */
  70545. resetRefreshCounter(): void;
  70546. /**
  70547. * Set the fragment shader to use in order to render the texture.
  70548. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70549. */
  70550. setFragment(fragment: any): void;
  70551. /**
  70552. * Define the refresh rate of the texture or the rendering frequency.
  70553. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70554. */
  70555. refreshRate: number;
  70556. /** @hidden */
  70557. _shouldRender(): boolean;
  70558. /**
  70559. * Get the size the texture is rendering at.
  70560. * @returns the size (texture is always squared)
  70561. */
  70562. getRenderSize(): number;
  70563. /**
  70564. * Resize the texture to new value.
  70565. * @param size Define the new size the texture should have
  70566. * @param generateMipMaps Define whether the new texture should create mip maps
  70567. */
  70568. resize(size: number, generateMipMaps: boolean): void;
  70569. private _checkUniform;
  70570. /**
  70571. * Set a texture in the shader program used to render.
  70572. * @param name Define the name of the uniform samplers as defined in the shader
  70573. * @param texture Define the texture to bind to this sampler
  70574. * @return the texture itself allowing "fluent" like uniform updates
  70575. */
  70576. setTexture(name: string, texture: Texture): ProceduralTexture;
  70577. /**
  70578. * Set a float in the shader.
  70579. * @param name Define the name of the uniform as defined in the shader
  70580. * @param value Define the value to give to the uniform
  70581. * @return the texture itself allowing "fluent" like uniform updates
  70582. */
  70583. setFloat(name: string, value: number): ProceduralTexture;
  70584. /**
  70585. * Set a int in the shader.
  70586. * @param name Define the name of the uniform as defined in the shader
  70587. * @param value Define the value to give to the uniform
  70588. * @return the texture itself allowing "fluent" like uniform updates
  70589. */
  70590. setInt(name: string, value: number): ProceduralTexture;
  70591. /**
  70592. * Set an array of floats in the shader.
  70593. * @param name Define the name of the uniform as defined in the shader
  70594. * @param value Define the value to give to the uniform
  70595. * @return the texture itself allowing "fluent" like uniform updates
  70596. */
  70597. setFloats(name: string, value: number[]): ProceduralTexture;
  70598. /**
  70599. * Set a vec3 in the shader from a Color3.
  70600. * @param name Define the name of the uniform as defined in the shader
  70601. * @param value Define the value to give to the uniform
  70602. * @return the texture itself allowing "fluent" like uniform updates
  70603. */
  70604. setColor3(name: string, value: Color3): ProceduralTexture;
  70605. /**
  70606. * Set a vec4 in the shader from a Color4.
  70607. * @param name Define the name of the uniform as defined in the shader
  70608. * @param value Define the value to give to the uniform
  70609. * @return the texture itself allowing "fluent" like uniform updates
  70610. */
  70611. setColor4(name: string, value: Color4): ProceduralTexture;
  70612. /**
  70613. * Set a vec2 in the shader from a Vector2.
  70614. * @param name Define the name of the uniform as defined in the shader
  70615. * @param value Define the value to give to the uniform
  70616. * @return the texture itself allowing "fluent" like uniform updates
  70617. */
  70618. setVector2(name: string, value: Vector2): ProceduralTexture;
  70619. /**
  70620. * Set a vec3 in the shader from a Vector3.
  70621. * @param name Define the name of the uniform as defined in the shader
  70622. * @param value Define the value to give to the uniform
  70623. * @return the texture itself allowing "fluent" like uniform updates
  70624. */
  70625. setVector3(name: string, value: Vector3): ProceduralTexture;
  70626. /**
  70627. * Set a mat4 in the shader from a MAtrix.
  70628. * @param name Define the name of the uniform as defined in the shader
  70629. * @param value Define the value to give to the uniform
  70630. * @return the texture itself allowing "fluent" like uniform updates
  70631. */
  70632. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70633. /**
  70634. * Render the texture to its associated render target.
  70635. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70636. */
  70637. render(useCameraPostProcess?: boolean): void;
  70638. /**
  70639. * Clone the texture.
  70640. * @returns the cloned texture
  70641. */
  70642. clone(): ProceduralTexture;
  70643. /**
  70644. * Dispose the texture and release its asoociated resources.
  70645. */
  70646. dispose(): void;
  70647. }
  70648. }
  70649. declare module BABYLON {
  70650. /**
  70651. * This represents the base class for particle system in Babylon.
  70652. * 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.
  70653. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70654. * @example https://doc.babylonjs.com/babylon101/particles
  70655. */
  70656. export class BaseParticleSystem {
  70657. /**
  70658. * Source color is added to the destination color without alpha affecting the result
  70659. */
  70660. static BLENDMODE_ONEONE: number;
  70661. /**
  70662. * Blend current color and particle color using particle’s alpha
  70663. */
  70664. static BLENDMODE_STANDARD: number;
  70665. /**
  70666. * Add current color and particle color multiplied by particle’s alpha
  70667. */
  70668. static BLENDMODE_ADD: number;
  70669. /**
  70670. * Multiply current color with particle color
  70671. */
  70672. static BLENDMODE_MULTIPLY: number;
  70673. /**
  70674. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70675. */
  70676. static BLENDMODE_MULTIPLYADD: number;
  70677. /**
  70678. * List of animations used by the particle system.
  70679. */
  70680. animations: Animation[];
  70681. /**
  70682. * The id of the Particle system.
  70683. */
  70684. id: string;
  70685. /**
  70686. * The friendly name of the Particle system.
  70687. */
  70688. name: string;
  70689. /**
  70690. * The rendering group used by the Particle system to chose when to render.
  70691. */
  70692. renderingGroupId: number;
  70693. /**
  70694. * The emitter represents the Mesh or position we are attaching the particle system to.
  70695. */
  70696. emitter: Nullable<AbstractMesh | Vector3>;
  70697. /**
  70698. * The maximum number of particles to emit per frame
  70699. */
  70700. emitRate: number;
  70701. /**
  70702. * If you want to launch only a few particles at once, that can be done, as well.
  70703. */
  70704. manualEmitCount: number;
  70705. /**
  70706. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70707. */
  70708. updateSpeed: number;
  70709. /**
  70710. * The amount of time the particle system is running (depends of the overall update speed).
  70711. */
  70712. targetStopDuration: number;
  70713. /**
  70714. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70715. */
  70716. disposeOnStop: boolean;
  70717. /**
  70718. * Minimum power of emitting particles.
  70719. */
  70720. minEmitPower: number;
  70721. /**
  70722. * Maximum power of emitting particles.
  70723. */
  70724. maxEmitPower: number;
  70725. /**
  70726. * Minimum life time of emitting particles.
  70727. */
  70728. minLifeTime: number;
  70729. /**
  70730. * Maximum life time of emitting particles.
  70731. */
  70732. maxLifeTime: number;
  70733. /**
  70734. * Minimum Size of emitting particles.
  70735. */
  70736. minSize: number;
  70737. /**
  70738. * Maximum Size of emitting particles.
  70739. */
  70740. maxSize: number;
  70741. /**
  70742. * Minimum scale of emitting particles on X axis.
  70743. */
  70744. minScaleX: number;
  70745. /**
  70746. * Maximum scale of emitting particles on X axis.
  70747. */
  70748. maxScaleX: number;
  70749. /**
  70750. * Minimum scale of emitting particles on Y axis.
  70751. */
  70752. minScaleY: number;
  70753. /**
  70754. * Maximum scale of emitting particles on Y axis.
  70755. */
  70756. maxScaleY: number;
  70757. /**
  70758. * Gets or sets the minimal initial rotation in radians.
  70759. */
  70760. minInitialRotation: number;
  70761. /**
  70762. * Gets or sets the maximal initial rotation in radians.
  70763. */
  70764. maxInitialRotation: number;
  70765. /**
  70766. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70767. */
  70768. minAngularSpeed: number;
  70769. /**
  70770. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70771. */
  70772. maxAngularSpeed: number;
  70773. /**
  70774. * The texture used to render each particle. (this can be a spritesheet)
  70775. */
  70776. particleTexture: Nullable<Texture>;
  70777. /**
  70778. * The layer mask we are rendering the particles through.
  70779. */
  70780. layerMask: number;
  70781. /**
  70782. * This can help using your own shader to render the particle system.
  70783. * The according effect will be created
  70784. */
  70785. customShader: any;
  70786. /**
  70787. * By default particle system starts as soon as they are created. This prevents the
  70788. * automatic start to happen and let you decide when to start emitting particles.
  70789. */
  70790. preventAutoStart: boolean;
  70791. private _noiseTexture;
  70792. /**
  70793. * Gets or sets a texture used to add random noise to particle positions
  70794. */
  70795. noiseTexture: Nullable<ProceduralTexture>;
  70796. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70797. noiseStrength: Vector3;
  70798. /**
  70799. * Callback triggered when the particle animation is ending.
  70800. */
  70801. onAnimationEnd: Nullable<() => void>;
  70802. /**
  70803. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70804. */
  70805. blendMode: number;
  70806. /**
  70807. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70808. * to override the particles.
  70809. */
  70810. forceDepthWrite: boolean;
  70811. /** 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 */
  70812. preWarmCycles: number;
  70813. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70814. preWarmStepOffset: number;
  70815. /**
  70816. * 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)
  70817. */
  70818. spriteCellChangeSpeed: number;
  70819. /**
  70820. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70821. */
  70822. startSpriteCellID: number;
  70823. /**
  70824. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70825. */
  70826. endSpriteCellID: number;
  70827. /**
  70828. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70829. */
  70830. spriteCellWidth: number;
  70831. /**
  70832. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70833. */
  70834. spriteCellHeight: number;
  70835. /**
  70836. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70837. */
  70838. spriteRandomStartCell: boolean;
  70839. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70840. translationPivot: Vector2;
  70841. /** @hidden */
  70842. protected _isAnimationSheetEnabled: boolean;
  70843. /**
  70844. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70845. */
  70846. beginAnimationOnStart: boolean;
  70847. /**
  70848. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70849. */
  70850. beginAnimationFrom: number;
  70851. /**
  70852. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70853. */
  70854. beginAnimationTo: number;
  70855. /**
  70856. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70857. */
  70858. beginAnimationLoop: boolean;
  70859. /**
  70860. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70861. */
  70862. isAnimationSheetEnabled: boolean;
  70863. /**
  70864. * Get hosting scene
  70865. * @returns the scene
  70866. */
  70867. getScene(): Scene;
  70868. /**
  70869. * You can use gravity if you want to give an orientation to your particles.
  70870. */
  70871. gravity: Vector3;
  70872. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70873. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70874. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70875. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70876. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70877. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70878. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70879. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70880. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70881. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70882. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70883. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70884. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70885. /**
  70886. * Defines the delay in milliseconds before starting the system (0 by default)
  70887. */
  70888. startDelay: number;
  70889. /**
  70890. * Gets the current list of drag gradients.
  70891. * You must use addDragGradient and removeDragGradient to udpate this list
  70892. * @returns the list of drag gradients
  70893. */
  70894. getDragGradients(): Nullable<Array<FactorGradient>>;
  70895. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70896. limitVelocityDamping: number;
  70897. /**
  70898. * Gets the current list of limit velocity gradients.
  70899. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70900. * @returns the list of limit velocity gradients
  70901. */
  70902. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70903. /**
  70904. * Gets the current list of color gradients.
  70905. * You must use addColorGradient and removeColorGradient to udpate this list
  70906. * @returns the list of color gradients
  70907. */
  70908. getColorGradients(): Nullable<Array<ColorGradient>>;
  70909. /**
  70910. * Gets the current list of size gradients.
  70911. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70912. * @returns the list of size gradients
  70913. */
  70914. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70915. /**
  70916. * Gets the current list of color remap gradients.
  70917. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70918. * @returns the list of color remap gradients
  70919. */
  70920. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70921. /**
  70922. * Gets the current list of alpha remap gradients.
  70923. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70924. * @returns the list of alpha remap gradients
  70925. */
  70926. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70927. /**
  70928. * Gets the current list of life time gradients.
  70929. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70930. * @returns the list of life time gradients
  70931. */
  70932. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70933. /**
  70934. * Gets the current list of angular speed gradients.
  70935. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70936. * @returns the list of angular speed gradients
  70937. */
  70938. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70939. /**
  70940. * Gets the current list of velocity gradients.
  70941. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70942. * @returns the list of velocity gradients
  70943. */
  70944. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70945. /**
  70946. * Gets the current list of start size gradients.
  70947. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70948. * @returns the list of start size gradients
  70949. */
  70950. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70951. /**
  70952. * Gets the current list of emit rate gradients.
  70953. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70954. * @returns the list of emit rate gradients
  70955. */
  70956. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70957. /**
  70958. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70959. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70960. */
  70961. direction1: Vector3;
  70962. /**
  70963. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70964. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70965. */
  70966. direction2: Vector3;
  70967. /**
  70968. * 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.
  70969. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70970. */
  70971. minEmitBox: Vector3;
  70972. /**
  70973. * 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.
  70974. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70975. */
  70976. maxEmitBox: Vector3;
  70977. /**
  70978. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70979. */
  70980. color1: Color4;
  70981. /**
  70982. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70983. */
  70984. color2: Color4;
  70985. /**
  70986. * Color the particle will have at the end of its lifetime
  70987. */
  70988. colorDead: Color4;
  70989. /**
  70990. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  70991. */
  70992. textureMask: Color4;
  70993. /**
  70994. * The particle emitter type defines the emitter used by the particle system.
  70995. * It can be for example box, sphere, or cone...
  70996. */
  70997. particleEmitterType: IParticleEmitterType;
  70998. /** @hidden */
  70999. _isSubEmitter: boolean;
  71000. /**
  71001. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71002. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71003. */
  71004. billboardMode: number;
  71005. protected _isBillboardBased: boolean;
  71006. /**
  71007. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71008. */
  71009. isBillboardBased: boolean;
  71010. /**
  71011. * The scene the particle system belongs to.
  71012. */
  71013. protected _scene: Scene;
  71014. /**
  71015. * Local cache of defines for image processing.
  71016. */
  71017. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71018. /**
  71019. * Default configuration related to image processing available in the standard Material.
  71020. */
  71021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71022. /**
  71023. * Gets the image processing configuration used either in this material.
  71024. */
  71025. /**
  71026. * Sets the Default image processing configuration used either in the this material.
  71027. *
  71028. * If sets to null, the scene one is in use.
  71029. */
  71030. imageProcessingConfiguration: ImageProcessingConfiguration;
  71031. /**
  71032. * Attaches a new image processing configuration to the Standard Material.
  71033. * @param configuration
  71034. */
  71035. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71036. /** @hidden */
  71037. protected _reset(): void;
  71038. /** @hidden */
  71039. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71040. /**
  71041. * Instantiates a particle system.
  71042. * 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.
  71043. * @param name The name of the particle system
  71044. */
  71045. constructor(name: string);
  71046. /**
  71047. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71050. * @returns the emitter
  71051. */
  71052. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71053. /**
  71054. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71055. * @param radius The radius of the hemisphere to emit from
  71056. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71057. * @returns the emitter
  71058. */
  71059. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71060. /**
  71061. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71062. * @param radius The radius of the sphere to emit from
  71063. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71064. * @returns the emitter
  71065. */
  71066. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71067. /**
  71068. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71069. * @param radius The radius of the sphere to emit from
  71070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71072. * @returns the emitter
  71073. */
  71074. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71075. /**
  71076. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71077. * @param radius The radius of the emission cylinder
  71078. * @param height The height of the emission cylinder
  71079. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71080. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71081. * @returns the emitter
  71082. */
  71083. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71084. /**
  71085. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71086. * @param radius The radius of the cylinder to emit from
  71087. * @param height The height of the emission cylinder
  71088. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71089. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71090. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71091. * @returns the emitter
  71092. */
  71093. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71094. /**
  71095. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71096. * @param radius The radius of the cone to emit from
  71097. * @param angle The base angle of the cone
  71098. * @returns the emitter
  71099. */
  71100. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71101. /**
  71102. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71105. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71106. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71107. * @returns the emitter
  71108. */
  71109. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71110. }
  71111. }
  71112. declare module BABYLON {
  71113. /**
  71114. * Type of sub emitter
  71115. */
  71116. export enum SubEmitterType {
  71117. /**
  71118. * Attached to the particle over it's lifetime
  71119. */
  71120. ATTACHED = 0,
  71121. /**
  71122. * Created when the particle dies
  71123. */
  71124. END = 1
  71125. }
  71126. /**
  71127. * Sub emitter class used to emit particles from an existing particle
  71128. */
  71129. export class SubEmitter {
  71130. /**
  71131. * the particle system to be used by the sub emitter
  71132. */
  71133. particleSystem: ParticleSystem;
  71134. /**
  71135. * Type of the submitter (Default: END)
  71136. */
  71137. type: SubEmitterType;
  71138. /**
  71139. * 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)
  71140. * Note: This only is supported when using an emitter of type Mesh
  71141. */
  71142. inheritDirection: boolean;
  71143. /**
  71144. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71145. */
  71146. inheritedVelocityAmount: number;
  71147. /**
  71148. * Creates a sub emitter
  71149. * @param particleSystem the particle system to be used by the sub emitter
  71150. */
  71151. constructor(
  71152. /**
  71153. * the particle system to be used by the sub emitter
  71154. */
  71155. particleSystem: ParticleSystem);
  71156. /**
  71157. * Clones the sub emitter
  71158. * @returns the cloned sub emitter
  71159. */
  71160. clone(): SubEmitter;
  71161. /**
  71162. * Serialize current object to a JSON object
  71163. * @returns the serialized object
  71164. */
  71165. serialize(): any;
  71166. /** @hidden */
  71167. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71168. /**
  71169. * Creates a new SubEmitter from a serialized JSON version
  71170. * @param serializationObject defines the JSON object to read from
  71171. * @param scene defines the hosting scene
  71172. * @param rootUrl defines the rootUrl for data loading
  71173. * @returns a new SubEmitter
  71174. */
  71175. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71176. /** Release associated resources */
  71177. dispose(): void;
  71178. }
  71179. }
  71180. declare module BABYLON {
  71181. /** @hidden */
  71182. export var clipPlaneFragmentDeclaration: {
  71183. name: string;
  71184. shader: string;
  71185. };
  71186. }
  71187. declare module BABYLON {
  71188. /** @hidden */
  71189. export var imageProcessingDeclaration: {
  71190. name: string;
  71191. shader: string;
  71192. };
  71193. }
  71194. declare module BABYLON {
  71195. /** @hidden */
  71196. export var imageProcessingFunctions: {
  71197. name: string;
  71198. shader: string;
  71199. };
  71200. }
  71201. declare module BABYLON {
  71202. /** @hidden */
  71203. export var clipPlaneFragment: {
  71204. name: string;
  71205. shader: string;
  71206. };
  71207. }
  71208. declare module BABYLON {
  71209. /** @hidden */
  71210. export var particlesPixelShader: {
  71211. name: string;
  71212. shader: string;
  71213. };
  71214. }
  71215. declare module BABYLON {
  71216. /** @hidden */
  71217. export var clipPlaneVertexDeclaration: {
  71218. name: string;
  71219. shader: string;
  71220. };
  71221. }
  71222. declare module BABYLON {
  71223. /** @hidden */
  71224. export var clipPlaneVertex: {
  71225. name: string;
  71226. shader: string;
  71227. };
  71228. }
  71229. declare module BABYLON {
  71230. /** @hidden */
  71231. export var particlesVertexShader: {
  71232. name: string;
  71233. shader: string;
  71234. };
  71235. }
  71236. declare module BABYLON {
  71237. /**
  71238. * This represents a particle system in Babylon.
  71239. * 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.
  71240. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71241. * @example https://doc.babylonjs.com/babylon101/particles
  71242. */
  71243. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71244. /**
  71245. * Billboard mode will only apply to Y axis
  71246. */
  71247. static readonly BILLBOARDMODE_Y: number;
  71248. /**
  71249. * Billboard mode will apply to all axes
  71250. */
  71251. static readonly BILLBOARDMODE_ALL: number;
  71252. /**
  71253. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71254. */
  71255. static readonly BILLBOARDMODE_STRETCHED: number;
  71256. /**
  71257. * This function can be defined to provide custom update for active particles.
  71258. * This function will be called instead of regular update (age, position, color, etc.).
  71259. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71260. */
  71261. updateFunction: (particles: Particle[]) => void;
  71262. private _emitterWorldMatrix;
  71263. /**
  71264. * This function can be defined to specify initial direction for every new particle.
  71265. * It by default use the emitterType defined function
  71266. */
  71267. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71268. /**
  71269. * This function can be defined to specify initial position for every new particle.
  71270. * It by default use the emitterType defined function
  71271. */
  71272. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71273. /**
  71274. * @hidden
  71275. */
  71276. _inheritedVelocityOffset: Vector3;
  71277. /**
  71278. * An event triggered when the system is disposed
  71279. */
  71280. onDisposeObservable: Observable<ParticleSystem>;
  71281. private _onDisposeObserver;
  71282. /**
  71283. * Sets a callback that will be triggered when the system is disposed
  71284. */
  71285. onDispose: () => void;
  71286. private _particles;
  71287. private _epsilon;
  71288. private _capacity;
  71289. private _stockParticles;
  71290. private _newPartsExcess;
  71291. private _vertexData;
  71292. private _vertexBuffer;
  71293. private _vertexBuffers;
  71294. private _spriteBuffer;
  71295. private _indexBuffer;
  71296. private _effect;
  71297. private _customEffect;
  71298. private _cachedDefines;
  71299. private _scaledColorStep;
  71300. private _colorDiff;
  71301. private _scaledDirection;
  71302. private _scaledGravity;
  71303. private _currentRenderId;
  71304. private _alive;
  71305. private _useInstancing;
  71306. private _started;
  71307. private _stopped;
  71308. private _actualFrame;
  71309. private _scaledUpdateSpeed;
  71310. private _vertexBufferSize;
  71311. /** @hidden */
  71312. _currentEmitRateGradient: Nullable<FactorGradient>;
  71313. /** @hidden */
  71314. _currentEmitRate1: number;
  71315. /** @hidden */
  71316. _currentEmitRate2: number;
  71317. /** @hidden */
  71318. _currentStartSizeGradient: Nullable<FactorGradient>;
  71319. /** @hidden */
  71320. _currentStartSize1: number;
  71321. /** @hidden */
  71322. _currentStartSize2: number;
  71323. private readonly _rawTextureWidth;
  71324. private _rampGradientsTexture;
  71325. private _useRampGradients;
  71326. /** Gets or sets a boolean indicating that ramp gradients must be used
  71327. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71328. */
  71329. useRampGradients: boolean;
  71330. /**
  71331. * 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.
  71332. * 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: [])
  71333. */
  71334. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71335. private _subEmitters;
  71336. /**
  71337. * @hidden
  71338. * If the particle systems emitter should be disposed when the particle system is disposed
  71339. */
  71340. _disposeEmitterOnDispose: boolean;
  71341. /**
  71342. * The current active Sub-systems, this property is used by the root particle system only.
  71343. */
  71344. activeSubSystems: Array<ParticleSystem>;
  71345. private _rootParticleSystem;
  71346. /**
  71347. * Gets the current list of active particles
  71348. */
  71349. readonly particles: Particle[];
  71350. /**
  71351. * Returns the string "ParticleSystem"
  71352. * @returns a string containing the class name
  71353. */
  71354. getClassName(): string;
  71355. /**
  71356. * Instantiates a particle system.
  71357. * 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.
  71358. * @param name The name of the particle system
  71359. * @param capacity The max number of particles alive at the same time
  71360. * @param scene The scene the particle system belongs to
  71361. * @param customEffect a custom effect used to change the way particles are rendered by default
  71362. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71363. * @param epsilon Offset used to render the particles
  71364. */
  71365. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71366. private _addFactorGradient;
  71367. private _removeFactorGradient;
  71368. /**
  71369. * Adds a new life time gradient
  71370. * @param gradient defines the gradient to use (between 0 and 1)
  71371. * @param factor defines the life time factor to affect to the specified gradient
  71372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71373. * @returns the current particle system
  71374. */
  71375. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71376. /**
  71377. * Remove a specific life time gradient
  71378. * @param gradient defines the gradient to remove
  71379. * @returns the current particle system
  71380. */
  71381. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71382. /**
  71383. * Adds a new size gradient
  71384. * @param gradient defines the gradient to use (between 0 and 1)
  71385. * @param factor defines the size factor to affect to the specified gradient
  71386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71387. * @returns the current particle system
  71388. */
  71389. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71390. /**
  71391. * Remove a specific size gradient
  71392. * @param gradient defines the gradient to remove
  71393. * @returns the current particle system
  71394. */
  71395. removeSizeGradient(gradient: number): IParticleSystem;
  71396. /**
  71397. * Adds a new color remap gradient
  71398. * @param gradient defines the gradient to use (between 0 and 1)
  71399. * @param min defines the color remap minimal range
  71400. * @param max defines the color remap maximal range
  71401. * @returns the current particle system
  71402. */
  71403. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71404. /**
  71405. * Remove a specific color remap gradient
  71406. * @param gradient defines the gradient to remove
  71407. * @returns the current particle system
  71408. */
  71409. removeColorRemapGradient(gradient: number): IParticleSystem;
  71410. /**
  71411. * Adds a new alpha remap gradient
  71412. * @param gradient defines the gradient to use (between 0 and 1)
  71413. * @param min defines the alpha remap minimal range
  71414. * @param max defines the alpha remap maximal range
  71415. * @returns the current particle system
  71416. */
  71417. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71418. /**
  71419. * Remove a specific alpha remap gradient
  71420. * @param gradient defines the gradient to remove
  71421. * @returns the current particle system
  71422. */
  71423. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71424. /**
  71425. * Adds a new angular speed gradient
  71426. * @param gradient defines the gradient to use (between 0 and 1)
  71427. * @param factor defines the angular speed to affect to the specified gradient
  71428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71429. * @returns the current particle system
  71430. */
  71431. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71432. /**
  71433. * Remove a specific angular speed gradient
  71434. * @param gradient defines the gradient to remove
  71435. * @returns the current particle system
  71436. */
  71437. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71438. /**
  71439. * Adds a new velocity gradient
  71440. * @param gradient defines the gradient to use (between 0 and 1)
  71441. * @param factor defines the velocity to affect to the specified gradient
  71442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71443. * @returns the current particle system
  71444. */
  71445. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71446. /**
  71447. * Remove a specific velocity gradient
  71448. * @param gradient defines the gradient to remove
  71449. * @returns the current particle system
  71450. */
  71451. removeVelocityGradient(gradient: number): IParticleSystem;
  71452. /**
  71453. * Adds a new limit velocity gradient
  71454. * @param gradient defines the gradient to use (between 0 and 1)
  71455. * @param factor defines the limit velocity value to affect to the specified gradient
  71456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71457. * @returns the current particle system
  71458. */
  71459. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71460. /**
  71461. * Remove a specific limit velocity gradient
  71462. * @param gradient defines the gradient to remove
  71463. * @returns the current particle system
  71464. */
  71465. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71466. /**
  71467. * Adds a new drag gradient
  71468. * @param gradient defines the gradient to use (between 0 and 1)
  71469. * @param factor defines the drag value to affect to the specified gradient
  71470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71471. * @returns the current particle system
  71472. */
  71473. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71474. /**
  71475. * Remove a specific drag gradient
  71476. * @param gradient defines the gradient to remove
  71477. * @returns the current particle system
  71478. */
  71479. removeDragGradient(gradient: number): IParticleSystem;
  71480. /**
  71481. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71482. * @param gradient defines the gradient to use (between 0 and 1)
  71483. * @param factor defines the emit rate value to affect to the specified gradient
  71484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71485. * @returns the current particle system
  71486. */
  71487. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71488. /**
  71489. * Remove a specific emit rate gradient
  71490. * @param gradient defines the gradient to remove
  71491. * @returns the current particle system
  71492. */
  71493. removeEmitRateGradient(gradient: number): IParticleSystem;
  71494. /**
  71495. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71496. * @param gradient defines the gradient to use (between 0 and 1)
  71497. * @param factor defines the start size value to affect to the specified gradient
  71498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71499. * @returns the current particle system
  71500. */
  71501. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71502. /**
  71503. * Remove a specific start size gradient
  71504. * @param gradient defines the gradient to remove
  71505. * @returns the current particle system
  71506. */
  71507. removeStartSizeGradient(gradient: number): IParticleSystem;
  71508. private _createRampGradientTexture;
  71509. /**
  71510. * Gets the current list of ramp gradients.
  71511. * You must use addRampGradient and removeRampGradient to udpate this list
  71512. * @returns the list of ramp gradients
  71513. */
  71514. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71515. /**
  71516. * Adds a new ramp gradient used to remap particle colors
  71517. * @param gradient defines the gradient to use (between 0 and 1)
  71518. * @param color defines the color to affect to the specified gradient
  71519. * @returns the current particle system
  71520. */
  71521. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71522. /**
  71523. * Remove a specific ramp gradient
  71524. * @param gradient defines the gradient to remove
  71525. * @returns the current particle system
  71526. */
  71527. removeRampGradient(gradient: number): ParticleSystem;
  71528. /**
  71529. * Adds a new color gradient
  71530. * @param gradient defines the gradient to use (between 0 and 1)
  71531. * @param color1 defines the color to affect to the specified gradient
  71532. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71533. * @returns this particle system
  71534. */
  71535. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71536. /**
  71537. * Remove a specific color gradient
  71538. * @param gradient defines the gradient to remove
  71539. * @returns this particle system
  71540. */
  71541. removeColorGradient(gradient: number): IParticleSystem;
  71542. private _fetchR;
  71543. protected _reset(): void;
  71544. private _resetEffect;
  71545. private _createVertexBuffers;
  71546. private _createIndexBuffer;
  71547. /**
  71548. * Gets the maximum number of particles active at the same time.
  71549. * @returns The max number of active particles.
  71550. */
  71551. getCapacity(): number;
  71552. /**
  71553. * Gets whether there are still active particles in the system.
  71554. * @returns True if it is alive, otherwise false.
  71555. */
  71556. isAlive(): boolean;
  71557. /**
  71558. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71559. * @returns True if it has been started, otherwise false.
  71560. */
  71561. isStarted(): boolean;
  71562. private _prepareSubEmitterInternalArray;
  71563. /**
  71564. * Starts the particle system and begins to emit
  71565. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71566. */
  71567. start(delay?: number): void;
  71568. /**
  71569. * Stops the particle system.
  71570. * @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.
  71571. */
  71572. stop(stopSubEmitters?: boolean): void;
  71573. /**
  71574. * Remove all active particles
  71575. */
  71576. reset(): void;
  71577. /**
  71578. * @hidden (for internal use only)
  71579. */
  71580. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71581. /**
  71582. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71583. * Its lifetime will start back at 0.
  71584. */
  71585. recycleParticle: (particle: Particle) => void;
  71586. private _stopSubEmitters;
  71587. private _createParticle;
  71588. private _removeFromRoot;
  71589. private _emitFromParticle;
  71590. private _update;
  71591. /** @hidden */
  71592. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71593. /** @hidden */
  71594. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71595. /** @hidden */
  71596. private _getEffect;
  71597. /**
  71598. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71599. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71600. */
  71601. animate(preWarmOnly?: boolean): void;
  71602. private _appendParticleVertices;
  71603. /**
  71604. * Rebuilds the particle system.
  71605. */
  71606. rebuild(): void;
  71607. /**
  71608. * Is this system ready to be used/rendered
  71609. * @return true if the system is ready
  71610. */
  71611. isReady(): boolean;
  71612. private _render;
  71613. /**
  71614. * Renders the particle system in its current state.
  71615. * @returns the current number of particles
  71616. */
  71617. render(): number;
  71618. /**
  71619. * Disposes the particle system and free the associated resources
  71620. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71621. */
  71622. dispose(disposeTexture?: boolean): void;
  71623. /**
  71624. * Clones the particle system.
  71625. * @param name The name of the cloned object
  71626. * @param newEmitter The new emitter to use
  71627. * @returns the cloned particle system
  71628. */
  71629. clone(name: string, newEmitter: any): ParticleSystem;
  71630. /**
  71631. * Serializes the particle system to a JSON object.
  71632. * @returns the JSON object
  71633. */
  71634. serialize(): any;
  71635. /** @hidden */
  71636. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71637. /** @hidden */
  71638. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71639. /**
  71640. * Parses a JSON object to create a particle system.
  71641. * @param parsedParticleSystem The JSON object to parse
  71642. * @param scene The scene to create the particle system in
  71643. * @param rootUrl The root url to use to load external dependencies like texture
  71644. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71645. * @returns the Parsed particle system
  71646. */
  71647. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71648. }
  71649. }
  71650. declare module BABYLON {
  71651. /**
  71652. * A particle represents one of the element emitted by a particle system.
  71653. * This is mainly define by its coordinates, direction, velocity and age.
  71654. */
  71655. export class Particle {
  71656. /**
  71657. * The particle system the particle belongs to.
  71658. */
  71659. particleSystem: ParticleSystem;
  71660. private static _Count;
  71661. /**
  71662. * Unique ID of the particle
  71663. */
  71664. id: number;
  71665. /**
  71666. * The world position of the particle in the scene.
  71667. */
  71668. position: Vector3;
  71669. /**
  71670. * The world direction of the particle in the scene.
  71671. */
  71672. direction: Vector3;
  71673. /**
  71674. * The color of the particle.
  71675. */
  71676. color: Color4;
  71677. /**
  71678. * The color change of the particle per step.
  71679. */
  71680. colorStep: Color4;
  71681. /**
  71682. * Defines how long will the life of the particle be.
  71683. */
  71684. lifeTime: number;
  71685. /**
  71686. * The current age of the particle.
  71687. */
  71688. age: number;
  71689. /**
  71690. * The current size of the particle.
  71691. */
  71692. size: number;
  71693. /**
  71694. * The current scale of the particle.
  71695. */
  71696. scale: Vector2;
  71697. /**
  71698. * The current angle of the particle.
  71699. */
  71700. angle: number;
  71701. /**
  71702. * Defines how fast is the angle changing.
  71703. */
  71704. angularSpeed: number;
  71705. /**
  71706. * Defines the cell index used by the particle to be rendered from a sprite.
  71707. */
  71708. cellIndex: number;
  71709. /**
  71710. * The information required to support color remapping
  71711. */
  71712. remapData: Vector4;
  71713. /** @hidden */
  71714. _randomCellOffset?: number;
  71715. /** @hidden */
  71716. _initialDirection: Nullable<Vector3>;
  71717. /** @hidden */
  71718. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71719. /** @hidden */
  71720. _initialStartSpriteCellID: number;
  71721. /** @hidden */
  71722. _initialEndSpriteCellID: number;
  71723. /** @hidden */
  71724. _currentColorGradient: Nullable<ColorGradient>;
  71725. /** @hidden */
  71726. _currentColor1: Color4;
  71727. /** @hidden */
  71728. _currentColor2: Color4;
  71729. /** @hidden */
  71730. _currentSizeGradient: Nullable<FactorGradient>;
  71731. /** @hidden */
  71732. _currentSize1: number;
  71733. /** @hidden */
  71734. _currentSize2: number;
  71735. /** @hidden */
  71736. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71737. /** @hidden */
  71738. _currentAngularSpeed1: number;
  71739. /** @hidden */
  71740. _currentAngularSpeed2: number;
  71741. /** @hidden */
  71742. _currentVelocityGradient: Nullable<FactorGradient>;
  71743. /** @hidden */
  71744. _currentVelocity1: number;
  71745. /** @hidden */
  71746. _currentVelocity2: number;
  71747. /** @hidden */
  71748. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71749. /** @hidden */
  71750. _currentLimitVelocity1: number;
  71751. /** @hidden */
  71752. _currentLimitVelocity2: number;
  71753. /** @hidden */
  71754. _currentDragGradient: Nullable<FactorGradient>;
  71755. /** @hidden */
  71756. _currentDrag1: number;
  71757. /** @hidden */
  71758. _currentDrag2: number;
  71759. /** @hidden */
  71760. _randomNoiseCoordinates1: Vector3;
  71761. /** @hidden */
  71762. _randomNoiseCoordinates2: Vector3;
  71763. /**
  71764. * Creates a new instance Particle
  71765. * @param particleSystem the particle system the particle belongs to
  71766. */
  71767. constructor(
  71768. /**
  71769. * The particle system the particle belongs to.
  71770. */
  71771. particleSystem: ParticleSystem);
  71772. private updateCellInfoFromSystem;
  71773. /**
  71774. * Defines how the sprite cell index is updated for the particle
  71775. */
  71776. updateCellIndex(): void;
  71777. /** @hidden */
  71778. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71779. /** @hidden */
  71780. _inheritParticleInfoToSubEmitters(): void;
  71781. /** @hidden */
  71782. _reset(): void;
  71783. /**
  71784. * Copy the properties of particle to another one.
  71785. * @param other the particle to copy the information to.
  71786. */
  71787. copyTo(other: Particle): void;
  71788. }
  71789. }
  71790. declare module BABYLON {
  71791. /**
  71792. * Particle emitter represents a volume emitting particles.
  71793. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71794. */
  71795. export interface IParticleEmitterType {
  71796. /**
  71797. * Called by the particle System when the direction is computed for the created particle.
  71798. * @param worldMatrix is the world matrix of the particle system
  71799. * @param directionToUpdate is the direction vector to update with the result
  71800. * @param particle is the particle we are computed the direction for
  71801. */
  71802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71803. /**
  71804. * Called by the particle System when the position is computed for the created particle.
  71805. * @param worldMatrix is the world matrix of the particle system
  71806. * @param positionToUpdate is the position vector to update with the result
  71807. * @param particle is the particle we are computed the position for
  71808. */
  71809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71810. /**
  71811. * Clones the current emitter and returns a copy of it
  71812. * @returns the new emitter
  71813. */
  71814. clone(): IParticleEmitterType;
  71815. /**
  71816. * Called by the GPUParticleSystem to setup the update shader
  71817. * @param effect defines the update shader
  71818. */
  71819. applyToShader(effect: Effect): void;
  71820. /**
  71821. * Returns a string to use to update the GPU particles update shader
  71822. * @returns the effect defines string
  71823. */
  71824. getEffectDefines(): string;
  71825. /**
  71826. * Returns a string representing the class name
  71827. * @returns a string containing the class name
  71828. */
  71829. getClassName(): string;
  71830. /**
  71831. * Serializes the particle system to a JSON object.
  71832. * @returns the JSON object
  71833. */
  71834. serialize(): any;
  71835. /**
  71836. * Parse properties from a JSON object
  71837. * @param serializationObject defines the JSON object
  71838. */
  71839. parse(serializationObject: any): void;
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /**
  71844. * Particle emitter emitting particles from the inside of a box.
  71845. * It emits the particles randomly between 2 given directions.
  71846. */
  71847. export class BoxParticleEmitter implements IParticleEmitterType {
  71848. /**
  71849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71850. */
  71851. direction1: Vector3;
  71852. /**
  71853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71854. */
  71855. direction2: Vector3;
  71856. /**
  71857. * 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.
  71858. */
  71859. minEmitBox: Vector3;
  71860. /**
  71861. * 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.
  71862. */
  71863. maxEmitBox: Vector3;
  71864. /**
  71865. * Creates a new instance BoxParticleEmitter
  71866. */
  71867. constructor();
  71868. /**
  71869. * Called by the particle System when the direction is computed for the created particle.
  71870. * @param worldMatrix is the world matrix of the particle system
  71871. * @param directionToUpdate is the direction vector to update with the result
  71872. * @param particle is the particle we are computed the direction for
  71873. */
  71874. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71875. /**
  71876. * Called by the particle System when the position is computed for the created particle.
  71877. * @param worldMatrix is the world matrix of the particle system
  71878. * @param positionToUpdate is the position vector to update with the result
  71879. * @param particle is the particle we are computed the position for
  71880. */
  71881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71882. /**
  71883. * Clones the current emitter and returns a copy of it
  71884. * @returns the new emitter
  71885. */
  71886. clone(): BoxParticleEmitter;
  71887. /**
  71888. * Called by the GPUParticleSystem to setup the update shader
  71889. * @param effect defines the update shader
  71890. */
  71891. applyToShader(effect: Effect): void;
  71892. /**
  71893. * Returns a string to use to update the GPU particles update shader
  71894. * @returns a string containng the defines string
  71895. */
  71896. getEffectDefines(): string;
  71897. /**
  71898. * Returns the string "BoxParticleEmitter"
  71899. * @returns a string containing the class name
  71900. */
  71901. getClassName(): string;
  71902. /**
  71903. * Serializes the particle system to a JSON object.
  71904. * @returns the JSON object
  71905. */
  71906. serialize(): any;
  71907. /**
  71908. * Parse properties from a JSON object
  71909. * @param serializationObject defines the JSON object
  71910. */
  71911. parse(serializationObject: any): void;
  71912. }
  71913. }
  71914. declare module BABYLON {
  71915. /**
  71916. * Particle emitter emitting particles from the inside of a cone.
  71917. * It emits the particles alongside the cone volume from the base to the particle.
  71918. * The emission direction might be randomized.
  71919. */
  71920. export class ConeParticleEmitter implements IParticleEmitterType {
  71921. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71922. directionRandomizer: number;
  71923. private _radius;
  71924. private _angle;
  71925. private _height;
  71926. /**
  71927. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71928. */
  71929. radiusRange: number;
  71930. /**
  71931. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71932. */
  71933. heightRange: number;
  71934. /**
  71935. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71936. */
  71937. emitFromSpawnPointOnly: boolean;
  71938. /**
  71939. * Gets or sets the radius of the emission cone
  71940. */
  71941. radius: number;
  71942. /**
  71943. * Gets or sets the angle of the emission cone
  71944. */
  71945. angle: number;
  71946. private _buildHeight;
  71947. /**
  71948. * Creates a new instance ConeParticleEmitter
  71949. * @param radius the radius of the emission cone (1 by default)
  71950. * @param angle the cone base angle (PI by default)
  71951. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71952. */
  71953. constructor(radius?: number, angle?: number,
  71954. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71955. directionRandomizer?: number);
  71956. /**
  71957. * Called by the particle System when the direction is computed for the created particle.
  71958. * @param worldMatrix is the world matrix of the particle system
  71959. * @param directionToUpdate is the direction vector to update with the result
  71960. * @param particle is the particle we are computed the direction for
  71961. */
  71962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71963. /**
  71964. * Called by the particle System when the position is computed for the created particle.
  71965. * @param worldMatrix is the world matrix of the particle system
  71966. * @param positionToUpdate is the position vector to update with the result
  71967. * @param particle is the particle we are computed the position for
  71968. */
  71969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71970. /**
  71971. * Clones the current emitter and returns a copy of it
  71972. * @returns the new emitter
  71973. */
  71974. clone(): ConeParticleEmitter;
  71975. /**
  71976. * Called by the GPUParticleSystem to setup the update shader
  71977. * @param effect defines the update shader
  71978. */
  71979. applyToShader(effect: Effect): void;
  71980. /**
  71981. * Returns a string to use to update the GPU particles update shader
  71982. * @returns a string containng the defines string
  71983. */
  71984. getEffectDefines(): string;
  71985. /**
  71986. * Returns the string "ConeParticleEmitter"
  71987. * @returns a string containing the class name
  71988. */
  71989. getClassName(): string;
  71990. /**
  71991. * Serializes the particle system to a JSON object.
  71992. * @returns the JSON object
  71993. */
  71994. serialize(): any;
  71995. /**
  71996. * Parse properties from a JSON object
  71997. * @param serializationObject defines the JSON object
  71998. */
  71999. parse(serializationObject: any): void;
  72000. }
  72001. }
  72002. declare module BABYLON {
  72003. /**
  72004. * Particle emitter emitting particles from the inside of a cylinder.
  72005. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72006. */
  72007. export class CylinderParticleEmitter implements IParticleEmitterType {
  72008. /**
  72009. * The radius of the emission cylinder.
  72010. */
  72011. radius: number;
  72012. /**
  72013. * The height of the emission cylinder.
  72014. */
  72015. height: number;
  72016. /**
  72017. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72018. */
  72019. radiusRange: number;
  72020. /**
  72021. * How much to randomize the particle direction [0-1].
  72022. */
  72023. directionRandomizer: number;
  72024. /**
  72025. * Creates a new instance CylinderParticleEmitter
  72026. * @param radius the radius of the emission cylinder (1 by default)
  72027. * @param height the height of the emission cylinder (1 by default)
  72028. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72029. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72030. */
  72031. constructor(
  72032. /**
  72033. * The radius of the emission cylinder.
  72034. */
  72035. radius?: number,
  72036. /**
  72037. * The height of the emission cylinder.
  72038. */
  72039. height?: number,
  72040. /**
  72041. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72042. */
  72043. radiusRange?: number,
  72044. /**
  72045. * How much to randomize the particle direction [0-1].
  72046. */
  72047. directionRandomizer?: number);
  72048. /**
  72049. * Called by the particle System when the direction is computed for the created particle.
  72050. * @param worldMatrix is the world matrix of the particle system
  72051. * @param directionToUpdate is the direction vector to update with the result
  72052. * @param particle is the particle we are computed the direction for
  72053. */
  72054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72055. /**
  72056. * Called by the particle System when the position is computed for the created particle.
  72057. * @param worldMatrix is the world matrix of the particle system
  72058. * @param positionToUpdate is the position vector to update with the result
  72059. * @param particle is the particle we are computed the position for
  72060. */
  72061. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72062. /**
  72063. * Clones the current emitter and returns a copy of it
  72064. * @returns the new emitter
  72065. */
  72066. clone(): CylinderParticleEmitter;
  72067. /**
  72068. * Called by the GPUParticleSystem to setup the update shader
  72069. * @param effect defines the update shader
  72070. */
  72071. applyToShader(effect: Effect): void;
  72072. /**
  72073. * Returns a string to use to update the GPU particles update shader
  72074. * @returns a string containng the defines string
  72075. */
  72076. getEffectDefines(): string;
  72077. /**
  72078. * Returns the string "CylinderParticleEmitter"
  72079. * @returns a string containing the class name
  72080. */
  72081. getClassName(): string;
  72082. /**
  72083. * Serializes the particle system to a JSON object.
  72084. * @returns the JSON object
  72085. */
  72086. serialize(): any;
  72087. /**
  72088. * Parse properties from a JSON object
  72089. * @param serializationObject defines the JSON object
  72090. */
  72091. parse(serializationObject: any): void;
  72092. }
  72093. /**
  72094. * Particle emitter emitting particles from the inside of a cylinder.
  72095. * It emits the particles randomly between two vectors.
  72096. */
  72097. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72098. /**
  72099. * The min limit of the emission direction.
  72100. */
  72101. direction1: Vector3;
  72102. /**
  72103. * The max limit of the emission direction.
  72104. */
  72105. direction2: Vector3;
  72106. /**
  72107. * Creates a new instance CylinderDirectedParticleEmitter
  72108. * @param radius the radius of the emission cylinder (1 by default)
  72109. * @param height the height of the emission cylinder (1 by default)
  72110. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72111. * @param direction1 the min limit of the emission direction (up vector by default)
  72112. * @param direction2 the max limit of the emission direction (up vector by default)
  72113. */
  72114. constructor(radius?: number, height?: number, radiusRange?: number,
  72115. /**
  72116. * The min limit of the emission direction.
  72117. */
  72118. direction1?: Vector3,
  72119. /**
  72120. * The max limit of the emission direction.
  72121. */
  72122. direction2?: Vector3);
  72123. /**
  72124. * Called by the particle System when the direction is computed for the created particle.
  72125. * @param worldMatrix is the world matrix of the particle system
  72126. * @param directionToUpdate is the direction vector to update with the result
  72127. * @param particle is the particle we are computed the direction for
  72128. */
  72129. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72130. /**
  72131. * Clones the current emitter and returns a copy of it
  72132. * @returns the new emitter
  72133. */
  72134. clone(): CylinderDirectedParticleEmitter;
  72135. /**
  72136. * Called by the GPUParticleSystem to setup the update shader
  72137. * @param effect defines the update shader
  72138. */
  72139. applyToShader(effect: Effect): void;
  72140. /**
  72141. * Returns a string to use to update the GPU particles update shader
  72142. * @returns a string containng the defines string
  72143. */
  72144. getEffectDefines(): string;
  72145. /**
  72146. * Returns the string "CylinderDirectedParticleEmitter"
  72147. * @returns a string containing the class name
  72148. */
  72149. getClassName(): string;
  72150. /**
  72151. * Serializes the particle system to a JSON object.
  72152. * @returns the JSON object
  72153. */
  72154. serialize(): any;
  72155. /**
  72156. * Parse properties from a JSON object
  72157. * @param serializationObject defines the JSON object
  72158. */
  72159. parse(serializationObject: any): void;
  72160. }
  72161. }
  72162. declare module BABYLON {
  72163. /**
  72164. * Particle emitter emitting particles from the inside of a hemisphere.
  72165. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72166. */
  72167. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72168. /**
  72169. * The radius of the emission hemisphere.
  72170. */
  72171. radius: number;
  72172. /**
  72173. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72174. */
  72175. radiusRange: number;
  72176. /**
  72177. * How much to randomize the particle direction [0-1].
  72178. */
  72179. directionRandomizer: number;
  72180. /**
  72181. * Creates a new instance HemisphericParticleEmitter
  72182. * @param radius the radius of the emission hemisphere (1 by default)
  72183. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72185. */
  72186. constructor(
  72187. /**
  72188. * The radius of the emission hemisphere.
  72189. */
  72190. radius?: number,
  72191. /**
  72192. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72193. */
  72194. radiusRange?: number,
  72195. /**
  72196. * How much to randomize the particle direction [0-1].
  72197. */
  72198. directionRandomizer?: number);
  72199. /**
  72200. * Called by the particle System when the direction is computed for the created particle.
  72201. * @param worldMatrix is the world matrix of the particle system
  72202. * @param directionToUpdate is the direction vector to update with the result
  72203. * @param particle is the particle we are computed the direction for
  72204. */
  72205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72206. /**
  72207. * Called by the particle System when the position is computed for the created particle.
  72208. * @param worldMatrix is the world matrix of the particle system
  72209. * @param positionToUpdate is the position vector to update with the result
  72210. * @param particle is the particle we are computed the position for
  72211. */
  72212. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72213. /**
  72214. * Clones the current emitter and returns a copy of it
  72215. * @returns the new emitter
  72216. */
  72217. clone(): HemisphericParticleEmitter;
  72218. /**
  72219. * Called by the GPUParticleSystem to setup the update shader
  72220. * @param effect defines the update shader
  72221. */
  72222. applyToShader(effect: Effect): void;
  72223. /**
  72224. * Returns a string to use to update the GPU particles update shader
  72225. * @returns a string containng the defines string
  72226. */
  72227. getEffectDefines(): string;
  72228. /**
  72229. * Returns the string "HemisphericParticleEmitter"
  72230. * @returns a string containing the class name
  72231. */
  72232. getClassName(): string;
  72233. /**
  72234. * Serializes the particle system to a JSON object.
  72235. * @returns the JSON object
  72236. */
  72237. serialize(): any;
  72238. /**
  72239. * Parse properties from a JSON object
  72240. * @param serializationObject defines the JSON object
  72241. */
  72242. parse(serializationObject: any): void;
  72243. }
  72244. }
  72245. declare module BABYLON {
  72246. /**
  72247. * Particle emitter emitting particles from a point.
  72248. * It emits the particles randomly between 2 given directions.
  72249. */
  72250. export class PointParticleEmitter implements IParticleEmitterType {
  72251. /**
  72252. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72253. */
  72254. direction1: Vector3;
  72255. /**
  72256. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72257. */
  72258. direction2: Vector3;
  72259. /**
  72260. * Creates a new instance PointParticleEmitter
  72261. */
  72262. constructor();
  72263. /**
  72264. * Called by the particle System when the direction is computed for the created particle.
  72265. * @param worldMatrix is the world matrix of the particle system
  72266. * @param directionToUpdate is the direction vector to update with the result
  72267. * @param particle is the particle we are computed the direction for
  72268. */
  72269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72270. /**
  72271. * Called by the particle System when the position is computed for the created particle.
  72272. * @param worldMatrix is the world matrix of the particle system
  72273. * @param positionToUpdate is the position vector to update with the result
  72274. * @param particle is the particle we are computed the position for
  72275. */
  72276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72277. /**
  72278. * Clones the current emitter and returns a copy of it
  72279. * @returns the new emitter
  72280. */
  72281. clone(): PointParticleEmitter;
  72282. /**
  72283. * Called by the GPUParticleSystem to setup the update shader
  72284. * @param effect defines the update shader
  72285. */
  72286. applyToShader(effect: Effect): void;
  72287. /**
  72288. * Returns a string to use to update the GPU particles update shader
  72289. * @returns a string containng the defines string
  72290. */
  72291. getEffectDefines(): string;
  72292. /**
  72293. * Returns the string "PointParticleEmitter"
  72294. * @returns a string containing the class name
  72295. */
  72296. getClassName(): string;
  72297. /**
  72298. * Serializes the particle system to a JSON object.
  72299. * @returns the JSON object
  72300. */
  72301. serialize(): any;
  72302. /**
  72303. * Parse properties from a JSON object
  72304. * @param serializationObject defines the JSON object
  72305. */
  72306. parse(serializationObject: any): void;
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. /**
  72311. * Particle emitter emitting particles from the inside of a sphere.
  72312. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72313. */
  72314. export class SphereParticleEmitter implements IParticleEmitterType {
  72315. /**
  72316. * The radius of the emission sphere.
  72317. */
  72318. radius: number;
  72319. /**
  72320. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72321. */
  72322. radiusRange: number;
  72323. /**
  72324. * How much to randomize the particle direction [0-1].
  72325. */
  72326. directionRandomizer: number;
  72327. /**
  72328. * Creates a new instance SphereParticleEmitter
  72329. * @param radius the radius of the emission sphere (1 by default)
  72330. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72331. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72332. */
  72333. constructor(
  72334. /**
  72335. * The radius of the emission sphere.
  72336. */
  72337. radius?: number,
  72338. /**
  72339. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72340. */
  72341. radiusRange?: number,
  72342. /**
  72343. * How much to randomize the particle direction [0-1].
  72344. */
  72345. directionRandomizer?: number);
  72346. /**
  72347. * Called by the particle System when the direction is computed for the created particle.
  72348. * @param worldMatrix is the world matrix of the particle system
  72349. * @param directionToUpdate is the direction vector to update with the result
  72350. * @param particle is the particle we are computed the direction for
  72351. */
  72352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72353. /**
  72354. * Called by the particle System when the position is computed for the created particle.
  72355. * @param worldMatrix is the world matrix of the particle system
  72356. * @param positionToUpdate is the position vector to update with the result
  72357. * @param particle is the particle we are computed the position for
  72358. */
  72359. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72360. /**
  72361. * Clones the current emitter and returns a copy of it
  72362. * @returns the new emitter
  72363. */
  72364. clone(): SphereParticleEmitter;
  72365. /**
  72366. * Called by the GPUParticleSystem to setup the update shader
  72367. * @param effect defines the update shader
  72368. */
  72369. applyToShader(effect: Effect): void;
  72370. /**
  72371. * Returns a string to use to update the GPU particles update shader
  72372. * @returns a string containng the defines string
  72373. */
  72374. getEffectDefines(): string;
  72375. /**
  72376. * Returns the string "SphereParticleEmitter"
  72377. * @returns a string containing the class name
  72378. */
  72379. getClassName(): string;
  72380. /**
  72381. * Serializes the particle system to a JSON object.
  72382. * @returns the JSON object
  72383. */
  72384. serialize(): any;
  72385. /**
  72386. * Parse properties from a JSON object
  72387. * @param serializationObject defines the JSON object
  72388. */
  72389. parse(serializationObject: any): void;
  72390. }
  72391. /**
  72392. * Particle emitter emitting particles from the inside of a sphere.
  72393. * It emits the particles randomly between two vectors.
  72394. */
  72395. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72396. /**
  72397. * The min limit of the emission direction.
  72398. */
  72399. direction1: Vector3;
  72400. /**
  72401. * The max limit of the emission direction.
  72402. */
  72403. direction2: Vector3;
  72404. /**
  72405. * Creates a new instance SphereDirectedParticleEmitter
  72406. * @param radius the radius of the emission sphere (1 by default)
  72407. * @param direction1 the min limit of the emission direction (up vector by default)
  72408. * @param direction2 the max limit of the emission direction (up vector by default)
  72409. */
  72410. constructor(radius?: number,
  72411. /**
  72412. * The min limit of the emission direction.
  72413. */
  72414. direction1?: Vector3,
  72415. /**
  72416. * The max limit of the emission direction.
  72417. */
  72418. direction2?: Vector3);
  72419. /**
  72420. * Called by the particle System when the direction is computed for the created particle.
  72421. * @param worldMatrix is the world matrix of the particle system
  72422. * @param directionToUpdate is the direction vector to update with the result
  72423. * @param particle is the particle we are computed the direction for
  72424. */
  72425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72426. /**
  72427. * Clones the current emitter and returns a copy of it
  72428. * @returns the new emitter
  72429. */
  72430. clone(): SphereDirectedParticleEmitter;
  72431. /**
  72432. * Called by the GPUParticleSystem to setup the update shader
  72433. * @param effect defines the update shader
  72434. */
  72435. applyToShader(effect: Effect): void;
  72436. /**
  72437. * Returns a string to use to update the GPU particles update shader
  72438. * @returns a string containng the defines string
  72439. */
  72440. getEffectDefines(): string;
  72441. /**
  72442. * Returns the string "SphereDirectedParticleEmitter"
  72443. * @returns a string containing the class name
  72444. */
  72445. getClassName(): string;
  72446. /**
  72447. * Serializes the particle system to a JSON object.
  72448. * @returns the JSON object
  72449. */
  72450. serialize(): any;
  72451. /**
  72452. * Parse properties from a JSON object
  72453. * @param serializationObject defines the JSON object
  72454. */
  72455. parse(serializationObject: any): void;
  72456. }
  72457. }
  72458. declare module BABYLON {
  72459. /**
  72460. * Interface representing a particle system in Babylon.js.
  72461. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72462. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72463. */
  72464. export interface IParticleSystem {
  72465. /**
  72466. * List of animations used by the particle system.
  72467. */
  72468. animations: Animation[];
  72469. /**
  72470. * The id of the Particle system.
  72471. */
  72472. id: string;
  72473. /**
  72474. * The name of the Particle system.
  72475. */
  72476. name: string;
  72477. /**
  72478. * The emitter represents the Mesh or position we are attaching the particle system to.
  72479. */
  72480. emitter: Nullable<AbstractMesh | Vector3>;
  72481. /**
  72482. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72483. */
  72484. isBillboardBased: boolean;
  72485. /**
  72486. * The rendering group used by the Particle system to chose when to render.
  72487. */
  72488. renderingGroupId: number;
  72489. /**
  72490. * The layer mask we are rendering the particles through.
  72491. */
  72492. layerMask: number;
  72493. /**
  72494. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72495. */
  72496. updateSpeed: number;
  72497. /**
  72498. * The amount of time the particle system is running (depends of the overall update speed).
  72499. */
  72500. targetStopDuration: number;
  72501. /**
  72502. * The texture used to render each particle. (this can be a spritesheet)
  72503. */
  72504. particleTexture: Nullable<Texture>;
  72505. /**
  72506. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72507. */
  72508. blendMode: number;
  72509. /**
  72510. * Minimum life time of emitting particles.
  72511. */
  72512. minLifeTime: number;
  72513. /**
  72514. * Maximum life time of emitting particles.
  72515. */
  72516. maxLifeTime: number;
  72517. /**
  72518. * Minimum Size of emitting particles.
  72519. */
  72520. minSize: number;
  72521. /**
  72522. * Maximum Size of emitting particles.
  72523. */
  72524. maxSize: number;
  72525. /**
  72526. * Minimum scale of emitting particles on X axis.
  72527. */
  72528. minScaleX: number;
  72529. /**
  72530. * Maximum scale of emitting particles on X axis.
  72531. */
  72532. maxScaleX: number;
  72533. /**
  72534. * Minimum scale of emitting particles on Y axis.
  72535. */
  72536. minScaleY: number;
  72537. /**
  72538. * Maximum scale of emitting particles on Y axis.
  72539. */
  72540. maxScaleY: number;
  72541. /**
  72542. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72543. */
  72544. color1: Color4;
  72545. /**
  72546. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72547. */
  72548. color2: Color4;
  72549. /**
  72550. * Color the particle will have at the end of its lifetime.
  72551. */
  72552. colorDead: Color4;
  72553. /**
  72554. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72555. */
  72556. emitRate: number;
  72557. /**
  72558. * You can use gravity if you want to give an orientation to your particles.
  72559. */
  72560. gravity: Vector3;
  72561. /**
  72562. * Minimum power of emitting particles.
  72563. */
  72564. minEmitPower: number;
  72565. /**
  72566. * Maximum power of emitting particles.
  72567. */
  72568. maxEmitPower: number;
  72569. /**
  72570. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72571. */
  72572. minAngularSpeed: number;
  72573. /**
  72574. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72575. */
  72576. maxAngularSpeed: number;
  72577. /**
  72578. * Gets or sets the minimal initial rotation in radians.
  72579. */
  72580. minInitialRotation: number;
  72581. /**
  72582. * Gets or sets the maximal initial rotation in radians.
  72583. */
  72584. maxInitialRotation: number;
  72585. /**
  72586. * The particle emitter type defines the emitter used by the particle system.
  72587. * It can be for example box, sphere, or cone...
  72588. */
  72589. particleEmitterType: Nullable<IParticleEmitterType>;
  72590. /**
  72591. * Defines the delay in milliseconds before starting the system (0 by default)
  72592. */
  72593. startDelay: number;
  72594. /**
  72595. * 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
  72596. */
  72597. preWarmCycles: number;
  72598. /**
  72599. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72600. */
  72601. preWarmStepOffset: number;
  72602. /**
  72603. * 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)
  72604. */
  72605. spriteCellChangeSpeed: number;
  72606. /**
  72607. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72608. */
  72609. startSpriteCellID: number;
  72610. /**
  72611. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72612. */
  72613. endSpriteCellID: number;
  72614. /**
  72615. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72616. */
  72617. spriteCellWidth: number;
  72618. /**
  72619. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72620. */
  72621. spriteCellHeight: number;
  72622. /**
  72623. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72624. */
  72625. spriteRandomStartCell: boolean;
  72626. /**
  72627. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72628. */
  72629. isAnimationSheetEnabled: boolean;
  72630. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72631. translationPivot: Vector2;
  72632. /**
  72633. * Gets or sets a texture used to add random noise to particle positions
  72634. */
  72635. noiseTexture: Nullable<BaseTexture>;
  72636. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72637. noiseStrength: Vector3;
  72638. /**
  72639. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72640. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72641. */
  72642. billboardMode: number;
  72643. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72644. limitVelocityDamping: number;
  72645. /**
  72646. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72647. */
  72648. beginAnimationOnStart: boolean;
  72649. /**
  72650. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72651. */
  72652. beginAnimationFrom: number;
  72653. /**
  72654. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72655. */
  72656. beginAnimationTo: number;
  72657. /**
  72658. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72659. */
  72660. beginAnimationLoop: boolean;
  72661. /**
  72662. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72663. */
  72664. disposeOnStop: boolean;
  72665. /**
  72666. * Gets the maximum number of particles active at the same time.
  72667. * @returns The max number of active particles.
  72668. */
  72669. getCapacity(): number;
  72670. /**
  72671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72672. * @returns True if it has been started, otherwise false.
  72673. */
  72674. isStarted(): boolean;
  72675. /**
  72676. * Animates the particle system for this frame.
  72677. */
  72678. animate(): void;
  72679. /**
  72680. * Renders the particle system in its current state.
  72681. * @returns the current number of particles
  72682. */
  72683. render(): number;
  72684. /**
  72685. * Dispose the particle system and frees its associated resources.
  72686. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72687. */
  72688. dispose(disposeTexture?: boolean): void;
  72689. /**
  72690. * Clones the particle system.
  72691. * @param name The name of the cloned object
  72692. * @param newEmitter The new emitter to use
  72693. * @returns the cloned particle system
  72694. */
  72695. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72696. /**
  72697. * Serializes the particle system to a JSON object.
  72698. * @returns the JSON object
  72699. */
  72700. serialize(): any;
  72701. /**
  72702. * Rebuild the particle system
  72703. */
  72704. rebuild(): void;
  72705. /**
  72706. * Starts the particle system and begins to emit
  72707. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72708. */
  72709. start(delay?: number): void;
  72710. /**
  72711. * Stops the particle system.
  72712. */
  72713. stop(): void;
  72714. /**
  72715. * Remove all active particles
  72716. */
  72717. reset(): void;
  72718. /**
  72719. * Is this system ready to be used/rendered
  72720. * @return true if the system is ready
  72721. */
  72722. isReady(): boolean;
  72723. /**
  72724. * Adds a new color gradient
  72725. * @param gradient defines the gradient to use (between 0 and 1)
  72726. * @param color1 defines the color to affect to the specified gradient
  72727. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72728. * @returns the current particle system
  72729. */
  72730. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72731. /**
  72732. * Remove a specific color gradient
  72733. * @param gradient defines the gradient to remove
  72734. * @returns the current particle system
  72735. */
  72736. removeColorGradient(gradient: number): IParticleSystem;
  72737. /**
  72738. * Adds a new size gradient
  72739. * @param gradient defines the gradient to use (between 0 and 1)
  72740. * @param factor defines the size factor to affect to the specified gradient
  72741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72742. * @returns the current particle system
  72743. */
  72744. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72745. /**
  72746. * Remove a specific size gradient
  72747. * @param gradient defines the gradient to remove
  72748. * @returns the current particle system
  72749. */
  72750. removeSizeGradient(gradient: number): IParticleSystem;
  72751. /**
  72752. * Gets the current list of color gradients.
  72753. * You must use addColorGradient and removeColorGradient to udpate this list
  72754. * @returns the list of color gradients
  72755. */
  72756. getColorGradients(): Nullable<Array<ColorGradient>>;
  72757. /**
  72758. * Gets the current list of size gradients.
  72759. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72760. * @returns the list of size gradients
  72761. */
  72762. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72763. /**
  72764. * Gets the current list of angular speed gradients.
  72765. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72766. * @returns the list of angular speed gradients
  72767. */
  72768. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72769. /**
  72770. * Adds a new angular speed gradient
  72771. * @param gradient defines the gradient to use (between 0 and 1)
  72772. * @param factor defines the angular speed to affect to the specified gradient
  72773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72774. * @returns the current particle system
  72775. */
  72776. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72777. /**
  72778. * Remove a specific angular speed gradient
  72779. * @param gradient defines the gradient to remove
  72780. * @returns the current particle system
  72781. */
  72782. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72783. /**
  72784. * Gets the current list of velocity gradients.
  72785. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72786. * @returns the list of velocity gradients
  72787. */
  72788. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72789. /**
  72790. * Adds a new velocity gradient
  72791. * @param gradient defines the gradient to use (between 0 and 1)
  72792. * @param factor defines the velocity to affect to the specified gradient
  72793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72794. * @returns the current particle system
  72795. */
  72796. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72797. /**
  72798. * Remove a specific velocity gradient
  72799. * @param gradient defines the gradient to remove
  72800. * @returns the current particle system
  72801. */
  72802. removeVelocityGradient(gradient: number): IParticleSystem;
  72803. /**
  72804. * Gets the current list of limit velocity gradients.
  72805. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72806. * @returns the list of limit velocity gradients
  72807. */
  72808. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72809. /**
  72810. * Adds a new limit velocity gradient
  72811. * @param gradient defines the gradient to use (between 0 and 1)
  72812. * @param factor defines the limit velocity to affect to the specified gradient
  72813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72814. * @returns the current particle system
  72815. */
  72816. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72817. /**
  72818. * Remove a specific limit velocity gradient
  72819. * @param gradient defines the gradient to remove
  72820. * @returns the current particle system
  72821. */
  72822. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72823. /**
  72824. * Adds a new drag gradient
  72825. * @param gradient defines the gradient to use (between 0 and 1)
  72826. * @param factor defines the drag to affect to the specified gradient
  72827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72828. * @returns the current particle system
  72829. */
  72830. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72831. /**
  72832. * Remove a specific drag gradient
  72833. * @param gradient defines the gradient to remove
  72834. * @returns the current particle system
  72835. */
  72836. removeDragGradient(gradient: number): IParticleSystem;
  72837. /**
  72838. * Gets the current list of drag gradients.
  72839. * You must use addDragGradient and removeDragGradient to udpate this list
  72840. * @returns the list of drag gradients
  72841. */
  72842. getDragGradients(): Nullable<Array<FactorGradient>>;
  72843. /**
  72844. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72845. * @param gradient defines the gradient to use (between 0 and 1)
  72846. * @param factor defines the emit rate to affect to the specified gradient
  72847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72848. * @returns the current particle system
  72849. */
  72850. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72851. /**
  72852. * Remove a specific emit rate gradient
  72853. * @param gradient defines the gradient to remove
  72854. * @returns the current particle system
  72855. */
  72856. removeEmitRateGradient(gradient: number): IParticleSystem;
  72857. /**
  72858. * Gets the current list of emit rate gradients.
  72859. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72860. * @returns the list of emit rate gradients
  72861. */
  72862. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72863. /**
  72864. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72865. * @param gradient defines the gradient to use (between 0 and 1)
  72866. * @param factor defines the start size to affect to the specified gradient
  72867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72868. * @returns the current particle system
  72869. */
  72870. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72871. /**
  72872. * Remove a specific start size gradient
  72873. * @param gradient defines the gradient to remove
  72874. * @returns the current particle system
  72875. */
  72876. removeStartSizeGradient(gradient: number): IParticleSystem;
  72877. /**
  72878. * Gets the current list of start size gradients.
  72879. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72880. * @returns the list of start size gradients
  72881. */
  72882. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72883. /**
  72884. * Adds a new life time gradient
  72885. * @param gradient defines the gradient to use (between 0 and 1)
  72886. * @param factor defines the life time factor to affect to the specified gradient
  72887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72888. * @returns the current particle system
  72889. */
  72890. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72891. /**
  72892. * Remove a specific life time gradient
  72893. * @param gradient defines the gradient to remove
  72894. * @returns the current particle system
  72895. */
  72896. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72897. /**
  72898. * Gets the current list of life time gradients.
  72899. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72900. * @returns the list of life time gradients
  72901. */
  72902. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72903. /**
  72904. * Gets the current list of color gradients.
  72905. * You must use addColorGradient and removeColorGradient to udpate this list
  72906. * @returns the list of color gradients
  72907. */
  72908. getColorGradients(): Nullable<Array<ColorGradient>>;
  72909. /**
  72910. * Adds a new ramp gradient used to remap particle colors
  72911. * @param gradient defines the gradient to use (between 0 and 1)
  72912. * @param color defines the color to affect to the specified gradient
  72913. * @returns the current particle system
  72914. */
  72915. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72916. /**
  72917. * Gets the current list of ramp gradients.
  72918. * You must use addRampGradient and removeRampGradient to udpate this list
  72919. * @returns the list of ramp gradients
  72920. */
  72921. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72922. /** Gets or sets a boolean indicating that ramp gradients must be used
  72923. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72924. */
  72925. useRampGradients: boolean;
  72926. /**
  72927. * Adds a new color remap gradient
  72928. * @param gradient defines the gradient to use (between 0 and 1)
  72929. * @param min defines the color remap minimal range
  72930. * @param max defines the color remap maximal range
  72931. * @returns the current particle system
  72932. */
  72933. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72934. /**
  72935. * Gets the current list of color remap gradients.
  72936. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72937. * @returns the list of color remap gradients
  72938. */
  72939. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72940. /**
  72941. * Adds a new alpha remap gradient
  72942. * @param gradient defines the gradient to use (between 0 and 1)
  72943. * @param min defines the alpha remap minimal range
  72944. * @param max defines the alpha remap maximal range
  72945. * @returns the current particle system
  72946. */
  72947. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72948. /**
  72949. * Gets the current list of alpha remap gradients.
  72950. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72951. * @returns the list of alpha remap gradients
  72952. */
  72953. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72954. /**
  72955. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72958. * @returns the emitter
  72959. */
  72960. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72961. /**
  72962. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72963. * @param radius The radius of the hemisphere to emit from
  72964. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72965. * @returns the emitter
  72966. */
  72967. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  72968. /**
  72969. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72970. * @param radius The radius of the sphere to emit from
  72971. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72972. * @returns the emitter
  72973. */
  72974. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  72975. /**
  72976. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72977. * @param radius The radius of the sphere to emit from
  72978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72980. * @returns the emitter
  72981. */
  72982. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72983. /**
  72984. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72985. * @param radius The radius of the emission cylinder
  72986. * @param height The height of the emission cylinder
  72987. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72988. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72989. * @returns the emitter
  72990. */
  72991. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  72992. /**
  72993. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72994. * @param radius The radius of the cylinder to emit from
  72995. * @param height The height of the emission cylinder
  72996. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72997. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72998. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72999. * @returns the emitter
  73000. */
  73001. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73002. /**
  73003. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73004. * @param radius The radius of the cone to emit from
  73005. * @param angle The base angle of the cone
  73006. * @returns the emitter
  73007. */
  73008. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73009. /**
  73010. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73013. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73014. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73015. * @returns the emitter
  73016. */
  73017. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73018. /**
  73019. * Get hosting scene
  73020. * @returns the scene
  73021. */
  73022. getScene(): Scene;
  73023. }
  73024. }
  73025. declare module BABYLON {
  73026. /** @hidden */
  73027. export var linePixelShader: {
  73028. name: string;
  73029. shader: string;
  73030. };
  73031. }
  73032. declare module BABYLON {
  73033. /** @hidden */
  73034. export var lineVertexShader: {
  73035. name: string;
  73036. shader: string;
  73037. };
  73038. }
  73039. declare module BABYLON {
  73040. interface AbstractMesh {
  73041. /**
  73042. * Disables the mesh edge rendering mode
  73043. * @returns the currentAbstractMesh
  73044. */
  73045. disableEdgesRendering(): AbstractMesh;
  73046. /**
  73047. * Enables the edge rendering mode on the mesh.
  73048. * This mode makes the mesh edges visible
  73049. * @param epsilon defines the maximal distance between two angles to detect a face
  73050. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73051. * @returns the currentAbstractMesh
  73052. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73053. */
  73054. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73055. /**
  73056. * Gets the edgesRenderer associated with the mesh
  73057. */
  73058. edgesRenderer: Nullable<EdgesRenderer>;
  73059. }
  73060. interface LinesMesh {
  73061. /**
  73062. * Enables the edge rendering mode on the mesh.
  73063. * This mode makes the mesh edges visible
  73064. * @param epsilon defines the maximal distance between two angles to detect a face
  73065. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73066. * @returns the currentAbstractMesh
  73067. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73068. */
  73069. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73070. }
  73071. interface InstancedLinesMesh {
  73072. /**
  73073. * Enables the edge rendering mode on the mesh.
  73074. * This mode makes the mesh edges visible
  73075. * @param epsilon defines the maximal distance between two angles to detect a face
  73076. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73077. * @returns the current InstancedLinesMesh
  73078. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73079. */
  73080. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73081. }
  73082. /**
  73083. * Defines the minimum contract an Edges renderer should follow.
  73084. */
  73085. export interface IEdgesRenderer extends IDisposable {
  73086. /**
  73087. * Gets or sets a boolean indicating if the edgesRenderer is active
  73088. */
  73089. isEnabled: boolean;
  73090. /**
  73091. * Renders the edges of the attached mesh,
  73092. */
  73093. render(): void;
  73094. /**
  73095. * Checks wether or not the edges renderer is ready to render.
  73096. * @return true if ready, otherwise false.
  73097. */
  73098. isReady(): boolean;
  73099. }
  73100. /**
  73101. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73102. */
  73103. export class EdgesRenderer implements IEdgesRenderer {
  73104. /**
  73105. * Define the size of the edges with an orthographic camera
  73106. */
  73107. edgesWidthScalerForOrthographic: number;
  73108. /**
  73109. * Define the size of the edges with a perspective camera
  73110. */
  73111. edgesWidthScalerForPerspective: number;
  73112. protected _source: AbstractMesh;
  73113. protected _linesPositions: number[];
  73114. protected _linesNormals: number[];
  73115. protected _linesIndices: number[];
  73116. protected _epsilon: number;
  73117. protected _indicesCount: number;
  73118. protected _lineShader: ShaderMaterial;
  73119. protected _ib: WebGLBuffer;
  73120. protected _buffers: {
  73121. [key: string]: Nullable<VertexBuffer>;
  73122. };
  73123. protected _checkVerticesInsteadOfIndices: boolean;
  73124. private _meshRebuildObserver;
  73125. private _meshDisposeObserver;
  73126. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73127. isEnabled: boolean;
  73128. /**
  73129. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73130. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73131. * @param source Mesh used to create edges
  73132. * @param epsilon sum of angles in adjacency to check for edge
  73133. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73134. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73135. */
  73136. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73137. protected _prepareRessources(): void;
  73138. /** @hidden */
  73139. _rebuild(): void;
  73140. /**
  73141. * Releases the required resources for the edges renderer
  73142. */
  73143. dispose(): void;
  73144. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73145. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73146. /**
  73147. * Checks if the pair of p0 and p1 is en edge
  73148. * @param faceIndex
  73149. * @param edge
  73150. * @param faceNormals
  73151. * @param p0
  73152. * @param p1
  73153. * @private
  73154. */
  73155. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73156. /**
  73157. * push line into the position, normal and index buffer
  73158. * @protected
  73159. */
  73160. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73161. /**
  73162. * Generates lines edges from adjacencjes
  73163. * @private
  73164. */
  73165. _generateEdgesLines(): void;
  73166. /**
  73167. * Checks wether or not the edges renderer is ready to render.
  73168. * @return true if ready, otherwise false.
  73169. */
  73170. isReady(): boolean;
  73171. /**
  73172. * Renders the edges of the attached mesh,
  73173. */
  73174. render(): void;
  73175. }
  73176. /**
  73177. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73178. */
  73179. export class LineEdgesRenderer extends EdgesRenderer {
  73180. /**
  73181. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73182. * @param source LineMesh used to generate edges
  73183. * @param epsilon not important (specified angle for edge detection)
  73184. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73185. */
  73186. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73187. /**
  73188. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73189. */
  73190. _generateEdgesLines(): void;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. /**
  73195. * This represents the object necessary to create a rendering group.
  73196. * This is exclusively used and created by the rendering manager.
  73197. * To modify the behavior, you use the available helpers in your scene or meshes.
  73198. * @hidden
  73199. */
  73200. export class RenderingGroup {
  73201. index: number;
  73202. private _scene;
  73203. private _opaqueSubMeshes;
  73204. private _transparentSubMeshes;
  73205. private _alphaTestSubMeshes;
  73206. private _depthOnlySubMeshes;
  73207. private _particleSystems;
  73208. private _spriteManagers;
  73209. private _opaqueSortCompareFn;
  73210. private _alphaTestSortCompareFn;
  73211. private _transparentSortCompareFn;
  73212. private _renderOpaque;
  73213. private _renderAlphaTest;
  73214. private _renderTransparent;
  73215. private _edgesRenderers;
  73216. onBeforeTransparentRendering: () => void;
  73217. /**
  73218. * Set the opaque sort comparison function.
  73219. * If null the sub meshes will be render in the order they were created
  73220. */
  73221. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73222. /**
  73223. * Set the alpha test sort comparison function.
  73224. * If null the sub meshes will be render in the order they were created
  73225. */
  73226. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73227. /**
  73228. * Set the transparent sort comparison function.
  73229. * If null the sub meshes will be render in the order they were created
  73230. */
  73231. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73232. /**
  73233. * Creates a new rendering group.
  73234. * @param index The rendering group index
  73235. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73236. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73237. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73238. */
  73239. 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>);
  73240. /**
  73241. * Render all the sub meshes contained in the group.
  73242. * @param customRenderFunction Used to override the default render behaviour of the group.
  73243. * @returns true if rendered some submeshes.
  73244. */
  73245. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73246. /**
  73247. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73248. * @param subMeshes The submeshes to render
  73249. */
  73250. private renderOpaqueSorted;
  73251. /**
  73252. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73253. * @param subMeshes The submeshes to render
  73254. */
  73255. private renderAlphaTestSorted;
  73256. /**
  73257. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73258. * @param subMeshes The submeshes to render
  73259. */
  73260. private renderTransparentSorted;
  73261. /**
  73262. * Renders the submeshes in a specified order.
  73263. * @param subMeshes The submeshes to sort before render
  73264. * @param sortCompareFn The comparison function use to sort
  73265. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73266. * @param transparent Specifies to activate blending if true
  73267. */
  73268. private static renderSorted;
  73269. /**
  73270. * Renders the submeshes in the order they were dispatched (no sort applied).
  73271. * @param subMeshes The submeshes to render
  73272. */
  73273. private static renderUnsorted;
  73274. /**
  73275. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73276. * are rendered back to front if in the same alpha index.
  73277. *
  73278. * @param a The first submesh
  73279. * @param b The second submesh
  73280. * @returns The result of the comparison
  73281. */
  73282. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73283. /**
  73284. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73285. * are rendered back to front.
  73286. *
  73287. * @param a The first submesh
  73288. * @param b The second submesh
  73289. * @returns The result of the comparison
  73290. */
  73291. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73292. /**
  73293. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73294. * are rendered front to back (prevent overdraw).
  73295. *
  73296. * @param a The first submesh
  73297. * @param b The second submesh
  73298. * @returns The result of the comparison
  73299. */
  73300. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73301. /**
  73302. * Resets the different lists of submeshes to prepare a new frame.
  73303. */
  73304. prepare(): void;
  73305. dispose(): void;
  73306. /**
  73307. * Inserts the submesh in its correct queue depending on its material.
  73308. * @param subMesh The submesh to dispatch
  73309. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73310. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73311. */
  73312. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73313. dispatchSprites(spriteManager: ISpriteManager): void;
  73314. dispatchParticles(particleSystem: IParticleSystem): void;
  73315. private _renderParticles;
  73316. private _renderSprites;
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * Interface describing the different options available in the rendering manager
  73322. * regarding Auto Clear between groups.
  73323. */
  73324. export interface IRenderingManagerAutoClearSetup {
  73325. /**
  73326. * Defines whether or not autoclear is enable.
  73327. */
  73328. autoClear: boolean;
  73329. /**
  73330. * Defines whether or not to autoclear the depth buffer.
  73331. */
  73332. depth: boolean;
  73333. /**
  73334. * Defines whether or not to autoclear the stencil buffer.
  73335. */
  73336. stencil: boolean;
  73337. }
  73338. /**
  73339. * This class is used by the onRenderingGroupObservable
  73340. */
  73341. export class RenderingGroupInfo {
  73342. /**
  73343. * The Scene that being rendered
  73344. */
  73345. scene: Scene;
  73346. /**
  73347. * The camera currently used for the rendering pass
  73348. */
  73349. camera: Nullable<Camera>;
  73350. /**
  73351. * The ID of the renderingGroup being processed
  73352. */
  73353. renderingGroupId: number;
  73354. }
  73355. /**
  73356. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73357. * It is enable to manage the different groups as well as the different necessary sort functions.
  73358. * This should not be used directly aside of the few static configurations
  73359. */
  73360. export class RenderingManager {
  73361. /**
  73362. * The max id used for rendering groups (not included)
  73363. */
  73364. static MAX_RENDERINGGROUPS: number;
  73365. /**
  73366. * The min id used for rendering groups (included)
  73367. */
  73368. static MIN_RENDERINGGROUPS: number;
  73369. /**
  73370. * Used to globally prevent autoclearing scenes.
  73371. */
  73372. static AUTOCLEAR: boolean;
  73373. /**
  73374. * @hidden
  73375. */
  73376. _useSceneAutoClearSetup: boolean;
  73377. private _scene;
  73378. private _renderingGroups;
  73379. private _depthStencilBufferAlreadyCleaned;
  73380. private _autoClearDepthStencil;
  73381. private _customOpaqueSortCompareFn;
  73382. private _customAlphaTestSortCompareFn;
  73383. private _customTransparentSortCompareFn;
  73384. private _renderingGroupInfo;
  73385. /**
  73386. * Instantiates a new rendering group for a particular scene
  73387. * @param scene Defines the scene the groups belongs to
  73388. */
  73389. constructor(scene: Scene);
  73390. private _clearDepthStencilBuffer;
  73391. /**
  73392. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73393. * @hidden
  73394. */
  73395. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73396. /**
  73397. * Resets the different information of the group to prepare a new frame
  73398. * @hidden
  73399. */
  73400. reset(): void;
  73401. /**
  73402. * Dispose and release the group and its associated resources.
  73403. * @hidden
  73404. */
  73405. dispose(): void;
  73406. /**
  73407. * Clear the info related to rendering groups preventing retention points during dispose.
  73408. */
  73409. freeRenderingGroups(): void;
  73410. private _prepareRenderingGroup;
  73411. /**
  73412. * Add a sprite manager to the rendering manager in order to render it this frame.
  73413. * @param spriteManager Define the sprite manager to render
  73414. */
  73415. dispatchSprites(spriteManager: ISpriteManager): void;
  73416. /**
  73417. * Add a particle system to the rendering manager in order to render it this frame.
  73418. * @param particleSystem Define the particle system to render
  73419. */
  73420. dispatchParticles(particleSystem: IParticleSystem): void;
  73421. /**
  73422. * Add a submesh to the manager in order to render it this frame
  73423. * @param subMesh The submesh to dispatch
  73424. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73425. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73426. */
  73427. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73428. /**
  73429. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73430. * This allowed control for front to back rendering or reversly depending of the special needs.
  73431. *
  73432. * @param renderingGroupId The rendering group id corresponding to its index
  73433. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73434. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73435. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73436. */
  73437. 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;
  73438. /**
  73439. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73440. *
  73441. * @param renderingGroupId The rendering group id corresponding to its index
  73442. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73443. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73444. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73445. */
  73446. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73447. /**
  73448. * Gets the current auto clear configuration for one rendering group of the rendering
  73449. * manager.
  73450. * @param index the rendering group index to get the information for
  73451. * @returns The auto clear setup for the requested rendering group
  73452. */
  73453. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73454. }
  73455. }
  73456. declare module BABYLON {
  73457. /**
  73458. * This Helps creating a texture that will be created from a camera in your scene.
  73459. * It is basically a dynamic texture that could be used to create special effects for instance.
  73460. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73461. */
  73462. export class RenderTargetTexture extends Texture {
  73463. isCube: boolean;
  73464. /**
  73465. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73466. */
  73467. static readonly REFRESHRATE_RENDER_ONCE: number;
  73468. /**
  73469. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73470. */
  73471. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73472. /**
  73473. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73474. * the central point of your effect and can save a lot of performances.
  73475. */
  73476. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73477. /**
  73478. * Use this predicate to dynamically define the list of mesh you want to render.
  73479. * If set, the renderList property will be overwritten.
  73480. */
  73481. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73482. private _renderList;
  73483. /**
  73484. * Use this list to define the list of mesh you want to render.
  73485. */
  73486. renderList: Nullable<Array<AbstractMesh>>;
  73487. private _hookArray;
  73488. /**
  73489. * Define if particles should be rendered in your texture.
  73490. */
  73491. renderParticles: boolean;
  73492. /**
  73493. * Define if sprites should be rendered in your texture.
  73494. */
  73495. renderSprites: boolean;
  73496. /**
  73497. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73498. */
  73499. coordinatesMode: number;
  73500. /**
  73501. * Define the camera used to render the texture.
  73502. */
  73503. activeCamera: Nullable<Camera>;
  73504. /**
  73505. * Override the render function of the texture with your own one.
  73506. */
  73507. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73508. /**
  73509. * Define if camera post processes should be use while rendering the texture.
  73510. */
  73511. useCameraPostProcesses: boolean;
  73512. /**
  73513. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73514. */
  73515. ignoreCameraViewport: boolean;
  73516. private _postProcessManager;
  73517. private _postProcesses;
  73518. private _resizeObserver;
  73519. /**
  73520. * An event triggered when the texture is unbind.
  73521. */
  73522. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73523. /**
  73524. * An event triggered when the texture is unbind.
  73525. */
  73526. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73527. private _onAfterUnbindObserver;
  73528. /**
  73529. * Set a after unbind callback in the texture.
  73530. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73531. */
  73532. onAfterUnbind: () => void;
  73533. /**
  73534. * An event triggered before rendering the texture
  73535. */
  73536. onBeforeRenderObservable: Observable<number>;
  73537. private _onBeforeRenderObserver;
  73538. /**
  73539. * Set a before render callback in the texture.
  73540. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73541. */
  73542. onBeforeRender: (faceIndex: number) => void;
  73543. /**
  73544. * An event triggered after rendering the texture
  73545. */
  73546. onAfterRenderObservable: Observable<number>;
  73547. private _onAfterRenderObserver;
  73548. /**
  73549. * Set a after render callback in the texture.
  73550. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73551. */
  73552. onAfterRender: (faceIndex: number) => void;
  73553. /**
  73554. * An event triggered after the texture clear
  73555. */
  73556. onClearObservable: Observable<Engine>;
  73557. private _onClearObserver;
  73558. /**
  73559. * Set a clear callback in the texture.
  73560. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73561. */
  73562. onClear: (Engine: Engine) => void;
  73563. /**
  73564. * Define the clear color of the Render Target if it should be different from the scene.
  73565. */
  73566. clearColor: Color4;
  73567. protected _size: number | {
  73568. width: number;
  73569. height: number;
  73570. };
  73571. protected _initialSizeParameter: number | {
  73572. width: number;
  73573. height: number;
  73574. } | {
  73575. ratio: number;
  73576. };
  73577. protected _sizeRatio: Nullable<number>;
  73578. /** @hidden */
  73579. _generateMipMaps: boolean;
  73580. protected _renderingManager: RenderingManager;
  73581. /** @hidden */
  73582. _waitingRenderList: string[];
  73583. protected _doNotChangeAspectRatio: boolean;
  73584. protected _currentRefreshId: number;
  73585. protected _refreshRate: number;
  73586. protected _textureMatrix: Matrix;
  73587. protected _samples: number;
  73588. protected _renderTargetOptions: RenderTargetCreationOptions;
  73589. /**
  73590. * Gets render target creation options that were used.
  73591. */
  73592. readonly renderTargetOptions: RenderTargetCreationOptions;
  73593. protected _engine: Engine;
  73594. protected _onRatioRescale(): void;
  73595. /**
  73596. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  73597. * It must define where the camera used to render the texture is set
  73598. */
  73599. boundingBoxPosition: Vector3;
  73600. private _boundingBoxSize;
  73601. /**
  73602. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  73603. * When defined, the cubemap will switch to local mode
  73604. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73605. * @example https://www.babylonjs-playground.com/#RNASML
  73606. */
  73607. boundingBoxSize: Vector3;
  73608. /**
  73609. * In case the RTT has been created with a depth texture, get the associated
  73610. * depth texture.
  73611. * Otherwise, return null.
  73612. */
  73613. depthStencilTexture: Nullable<InternalTexture>;
  73614. /**
  73615. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  73616. * or used a shadow, depth texture...
  73617. * @param name The friendly name of the texture
  73618. * @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)
  73619. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  73620. * @param generateMipMaps True if mip maps need to be generated after render.
  73621. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  73622. * @param type The type of the buffer in the RTT (int, half float, float...)
  73623. * @param isCube True if a cube texture needs to be created
  73624. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  73625. * @param generateDepthBuffer True to generate a depth buffer
  73626. * @param generateStencilBuffer True to generate a stencil buffer
  73627. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  73628. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  73629. * @param delayAllocation if the texture allocation should be delayed (default: false)
  73630. */
  73631. constructor(name: string, size: number | {
  73632. width: number;
  73633. height: number;
  73634. } | {
  73635. ratio: number;
  73636. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  73637. /**
  73638. * Creates a depth stencil texture.
  73639. * This is only available in WebGL 2 or with the depth texture extension available.
  73640. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  73641. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  73642. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  73643. */
  73644. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  73645. private _processSizeParameter;
  73646. /**
  73647. * Define the number of samples to use in case of MSAA.
  73648. * It defaults to one meaning no MSAA has been enabled.
  73649. */
  73650. samples: number;
  73651. /**
  73652. * Resets the refresh counter of the texture and start bak from scratch.
  73653. * Could be useful to regenerate the texture if it is setup to render only once.
  73654. */
  73655. resetRefreshCounter(): void;
  73656. /**
  73657. * Define the refresh rate of the texture or the rendering frequency.
  73658. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73659. */
  73660. refreshRate: number;
  73661. /**
  73662. * Adds a post process to the render target rendering passes.
  73663. * @param postProcess define the post process to add
  73664. */
  73665. addPostProcess(postProcess: PostProcess): void;
  73666. /**
  73667. * Clear all the post processes attached to the render target
  73668. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  73669. */
  73670. clearPostProcesses(dispose?: boolean): void;
  73671. /**
  73672. * Remove one of the post process from the list of attached post processes to the texture
  73673. * @param postProcess define the post process to remove from the list
  73674. */
  73675. removePostProcess(postProcess: PostProcess): void;
  73676. /** @hidden */
  73677. _shouldRender(): boolean;
  73678. /**
  73679. * Gets the actual render size of the texture.
  73680. * @returns the width of the render size
  73681. */
  73682. getRenderSize(): number;
  73683. /**
  73684. * Gets the actual render width of the texture.
  73685. * @returns the width of the render size
  73686. */
  73687. getRenderWidth(): number;
  73688. /**
  73689. * Gets the actual render height of the texture.
  73690. * @returns the height of the render size
  73691. */
  73692. getRenderHeight(): number;
  73693. /**
  73694. * Get if the texture can be rescaled or not.
  73695. */
  73696. readonly canRescale: boolean;
  73697. /**
  73698. * Resize the texture using a ratio.
  73699. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73700. */
  73701. scale(ratio: number): void;
  73702. /**
  73703. * Get the texture reflection matrix used to rotate/transform the reflection.
  73704. * @returns the reflection matrix
  73705. */
  73706. getReflectionTextureMatrix(): Matrix;
  73707. /**
  73708. * Resize the texture to a new desired size.
  73709. * Be carrefull as it will recreate all the data in the new texture.
  73710. * @param size Define the new size. It can be:
  73711. * - a number for squared texture,
  73712. * - an object containing { width: number, height: number }
  73713. * - or an object containing a ratio { ratio: number }
  73714. */
  73715. resize(size: number | {
  73716. width: number;
  73717. height: number;
  73718. } | {
  73719. ratio: number;
  73720. }): void;
  73721. /**
  73722. * Renders all the objects from the render list into the texture.
  73723. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73724. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73725. */
  73726. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73727. private _bestReflectionRenderTargetDimension;
  73728. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73729. private renderToTarget;
  73730. /**
  73731. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73732. * This allowed control for front to back rendering or reversly depending of the special needs.
  73733. *
  73734. * @param renderingGroupId The rendering group id corresponding to its index
  73735. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73736. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73737. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73738. */
  73739. 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;
  73740. /**
  73741. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73742. *
  73743. * @param renderingGroupId The rendering group id corresponding to its index
  73744. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73745. */
  73746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73747. /**
  73748. * Clones the texture.
  73749. * @returns the cloned texture
  73750. */
  73751. clone(): RenderTargetTexture;
  73752. /**
  73753. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73754. * @returns The JSON representation of the texture
  73755. */
  73756. serialize(): any;
  73757. /**
  73758. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73759. */
  73760. disposeFramebufferObjects(): void;
  73761. /**
  73762. * Dispose the texture and release its associated resources.
  73763. */
  73764. dispose(): void;
  73765. /** @hidden */
  73766. _rebuild(): void;
  73767. /**
  73768. * Clear the info related to rendering groups preventing retention point in material dispose.
  73769. */
  73770. freeRenderingGroups(): void;
  73771. }
  73772. }
  73773. declare module BABYLON {
  73774. /**
  73775. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73776. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73777. * You can then easily use it as a reflectionTexture on a flat surface.
  73778. * In case the surface is not a plane, please consider relying on reflection probes.
  73779. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73780. */
  73781. export class MirrorTexture extends RenderTargetTexture {
  73782. private scene;
  73783. /**
  73784. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  73785. * 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.
  73786. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73787. */
  73788. mirrorPlane: Plane;
  73789. /**
  73790. * Define the blur ratio used to blur the reflection if needed.
  73791. */
  73792. blurRatio: number;
  73793. /**
  73794. * Define the adaptive blur kernel used to blur the reflection if needed.
  73795. * This will autocompute the closest best match for the `blurKernel`
  73796. */
  73797. adaptiveBlurKernel: number;
  73798. /**
  73799. * Define the blur kernel used to blur the reflection if needed.
  73800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73801. */
  73802. blurKernel: number;
  73803. /**
  73804. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  73805. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73806. */
  73807. blurKernelX: number;
  73808. /**
  73809. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  73810. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73811. */
  73812. blurKernelY: number;
  73813. private _autoComputeBlurKernel;
  73814. protected _onRatioRescale(): void;
  73815. private _updateGammaSpace;
  73816. private _imageProcessingConfigChangeObserver;
  73817. private _transformMatrix;
  73818. private _mirrorMatrix;
  73819. private _savedViewMatrix;
  73820. private _blurX;
  73821. private _blurY;
  73822. private _adaptiveBlurKernel;
  73823. private _blurKernelX;
  73824. private _blurKernelY;
  73825. private _blurRatio;
  73826. /**
  73827. * Instantiates a Mirror Texture.
  73828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73830. * You can then easily use it as a reflectionTexture on a flat surface.
  73831. * In case the surface is not a plane, please consider relying on reflection probes.
  73832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73833. * @param name
  73834. * @param size
  73835. * @param scene
  73836. * @param generateMipMaps
  73837. * @param type
  73838. * @param samplingMode
  73839. * @param generateDepthBuffer
  73840. */
  73841. constructor(name: string, size: number | {
  73842. width: number;
  73843. height: number;
  73844. } | {
  73845. ratio: number;
  73846. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  73847. private _preparePostProcesses;
  73848. /**
  73849. * Clone the mirror texture.
  73850. * @returns the cloned texture
  73851. */
  73852. clone(): MirrorTexture;
  73853. /**
  73854. * Serialize the texture to a JSON representation you could use in Parse later on
  73855. * @returns the serialized JSON representation
  73856. */
  73857. serialize(): any;
  73858. /**
  73859. * Dispose the texture and release its associated resources.
  73860. */
  73861. dispose(): void;
  73862. }
  73863. }
  73864. declare module BABYLON {
  73865. /**
  73866. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  73867. * @see http://doc.babylonjs.com/babylon101/materials#texture
  73868. */
  73869. export class Texture extends BaseTexture {
  73870. /** @hidden */
  73871. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  73872. /** @hidden */
  73873. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  73874. /** @hidden */
  73875. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  73876. /** nearest is mag = nearest and min = nearest and mip = linear */
  73877. static readonly NEAREST_SAMPLINGMODE: number;
  73878. /** nearest is mag = nearest and min = nearest and mip = linear */
  73879. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  73880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73881. static readonly BILINEAR_SAMPLINGMODE: number;
  73882. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73883. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  73884. /** Trilinear is mag = linear and min = linear and mip = linear */
  73885. static readonly TRILINEAR_SAMPLINGMODE: number;
  73886. /** Trilinear is mag = linear and min = linear and mip = linear */
  73887. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  73888. /** mag = nearest and min = nearest and mip = nearest */
  73889. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  73890. /** mag = nearest and min = linear and mip = nearest */
  73891. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  73892. /** mag = nearest and min = linear and mip = linear */
  73893. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  73894. /** mag = nearest and min = linear and mip = none */
  73895. static readonly NEAREST_LINEAR: number;
  73896. /** mag = nearest and min = nearest and mip = none */
  73897. static readonly NEAREST_NEAREST: number;
  73898. /** mag = linear and min = nearest and mip = nearest */
  73899. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  73900. /** mag = linear and min = nearest and mip = linear */
  73901. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  73902. /** mag = linear and min = linear and mip = none */
  73903. static readonly LINEAR_LINEAR: number;
  73904. /** mag = linear and min = nearest and mip = none */
  73905. static readonly LINEAR_NEAREST: number;
  73906. /** Explicit coordinates mode */
  73907. static readonly EXPLICIT_MODE: number;
  73908. /** Spherical coordinates mode */
  73909. static readonly SPHERICAL_MODE: number;
  73910. /** Planar coordinates mode */
  73911. static readonly PLANAR_MODE: number;
  73912. /** Cubic coordinates mode */
  73913. static readonly CUBIC_MODE: number;
  73914. /** Projection coordinates mode */
  73915. static readonly PROJECTION_MODE: number;
  73916. /** Inverse Cubic coordinates mode */
  73917. static readonly SKYBOX_MODE: number;
  73918. /** Inverse Cubic coordinates mode */
  73919. static readonly INVCUBIC_MODE: number;
  73920. /** Equirectangular coordinates mode */
  73921. static readonly EQUIRECTANGULAR_MODE: number;
  73922. /** Equirectangular Fixed coordinates mode */
  73923. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  73924. /** Equirectangular Fixed Mirrored coordinates mode */
  73925. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73926. /** Texture is not repeating outside of 0..1 UVs */
  73927. static readonly CLAMP_ADDRESSMODE: number;
  73928. /** Texture is repeating outside of 0..1 UVs */
  73929. static readonly WRAP_ADDRESSMODE: number;
  73930. /** Texture is repeating and mirrored */
  73931. static readonly MIRROR_ADDRESSMODE: number;
  73932. /**
  73933. * 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
  73934. */
  73935. static UseSerializedUrlIfAny: boolean;
  73936. /**
  73937. * Define the url of the texture.
  73938. */
  73939. url: Nullable<string>;
  73940. /**
  73941. * Define an offset on the texture to offset the u coordinates of the UVs
  73942. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73943. */
  73944. uOffset: number;
  73945. /**
  73946. * Define an offset on the texture to offset the v coordinates of the UVs
  73947. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73948. */
  73949. vOffset: number;
  73950. /**
  73951. * Define an offset on the texture to scale the u coordinates of the UVs
  73952. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73953. */
  73954. uScale: number;
  73955. /**
  73956. * Define an offset on the texture to scale the v coordinates of the UVs
  73957. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73958. */
  73959. vScale: number;
  73960. /**
  73961. * Define an offset on the texture to rotate around the u coordinates of the UVs
  73962. * @see http://doc.babylonjs.com/how_to/more_materials
  73963. */
  73964. uAng: number;
  73965. /**
  73966. * Define an offset on the texture to rotate around the v coordinates of the UVs
  73967. * @see http://doc.babylonjs.com/how_to/more_materials
  73968. */
  73969. vAng: number;
  73970. /**
  73971. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  73972. * @see http://doc.babylonjs.com/how_to/more_materials
  73973. */
  73974. wAng: number;
  73975. /**
  73976. * Defines the center of rotation (U)
  73977. */
  73978. uRotationCenter: number;
  73979. /**
  73980. * Defines the center of rotation (V)
  73981. */
  73982. vRotationCenter: number;
  73983. /**
  73984. * Defines the center of rotation (W)
  73985. */
  73986. wRotationCenter: number;
  73987. /**
  73988. * Are mip maps generated for this texture or not.
  73989. */
  73990. readonly noMipmap: boolean;
  73991. private _noMipmap;
  73992. /** @hidden */
  73993. _invertY: boolean;
  73994. private _rowGenerationMatrix;
  73995. private _cachedTextureMatrix;
  73996. private _projectionModeMatrix;
  73997. private _t0;
  73998. private _t1;
  73999. private _t2;
  74000. private _cachedUOffset;
  74001. private _cachedVOffset;
  74002. private _cachedUScale;
  74003. private _cachedVScale;
  74004. private _cachedUAng;
  74005. private _cachedVAng;
  74006. private _cachedWAng;
  74007. private _cachedProjectionMatrixId;
  74008. private _cachedCoordinatesMode;
  74009. /** @hidden */
  74010. protected _initialSamplingMode: number;
  74011. /** @hidden */
  74012. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74013. private _deleteBuffer;
  74014. protected _format: Nullable<number>;
  74015. private _delayedOnLoad;
  74016. private _delayedOnError;
  74017. /**
  74018. * Observable triggered once the texture has been loaded.
  74019. */
  74020. onLoadObservable: Observable<Texture>;
  74021. protected _isBlocking: boolean;
  74022. /**
  74023. * Is the texture preventing material to render while loading.
  74024. * If false, a default texture will be used instead of the loading one during the preparation step.
  74025. */
  74026. isBlocking: boolean;
  74027. /**
  74028. * Get the current sampling mode associated with the texture.
  74029. */
  74030. readonly samplingMode: number;
  74031. /**
  74032. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74033. */
  74034. readonly invertY: boolean;
  74035. /**
  74036. * Instantiates a new texture.
  74037. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74038. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74039. * @param url define the url of the picture to load as a texture
  74040. * @param scene define the scene the texture will belong to
  74041. * @param noMipmap define if the texture will require mip maps or not
  74042. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74043. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74044. * @param onLoad define a callback triggered when the texture has been loaded
  74045. * @param onError define a callback triggered when an error occurred during the loading session
  74046. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74047. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74048. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74049. */
  74050. 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);
  74051. /**
  74052. * Update the url (and optional buffer) of this texture if url was null during construction.
  74053. * @param url the url of the texture
  74054. * @param buffer the buffer of the texture (defaults to null)
  74055. * @param onLoad callback called when the texture is loaded (defaults to null)
  74056. */
  74057. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74058. /**
  74059. * Finish the loading sequence of a texture flagged as delayed load.
  74060. * @hidden
  74061. */
  74062. delayLoad(): void;
  74063. private _prepareRowForTextureGeneration;
  74064. /**
  74065. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74066. * @returns the transform matrix of the texture.
  74067. */
  74068. getTextureMatrix(): Matrix;
  74069. /**
  74070. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74071. * @returns The reflection texture transform
  74072. */
  74073. getReflectionTextureMatrix(): Matrix;
  74074. /**
  74075. * Clones the texture.
  74076. * @returns the cloned texture
  74077. */
  74078. clone(): Texture;
  74079. /**
  74080. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74081. * @returns The JSON representation of the texture
  74082. */
  74083. serialize(): any;
  74084. /**
  74085. * Get the current class name of the texture useful for serialization or dynamic coding.
  74086. * @returns "Texture"
  74087. */
  74088. getClassName(): string;
  74089. /**
  74090. * Dispose the texture and release its associated resources.
  74091. */
  74092. dispose(): void;
  74093. /**
  74094. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74095. * @param parsedTexture Define the JSON representation of the texture
  74096. * @param scene Define the scene the parsed texture should be instantiated in
  74097. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74098. * @returns The parsed texture if successful
  74099. */
  74100. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74101. /**
  74102. * Creates a texture from its base 64 representation.
  74103. * @param data Define the base64 payload without the data: prefix
  74104. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74105. * @param scene Define the scene the texture should belong to
  74106. * @param noMipmap Forces the texture to not create mip map information if true
  74107. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74108. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74109. * @param onLoad define a callback triggered when the texture has been loaded
  74110. * @param onError define a callback triggered when an error occurred during the loading session
  74111. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74112. * @returns the created texture
  74113. */
  74114. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74115. /**
  74116. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74117. * @param data Define the base64 payload without the data: prefix
  74118. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74119. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74120. * @param scene Define the scene the texture should belong to
  74121. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74122. * @param noMipmap Forces the texture to not create mip map information if true
  74123. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74124. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74125. * @param onLoad define a callback triggered when the texture has been loaded
  74126. * @param onError define a callback triggered when an error occurred during the loading session
  74127. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74128. * @returns the created texture
  74129. */
  74130. 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;
  74131. }
  74132. }
  74133. declare module BABYLON {
  74134. /**
  74135. * Defines the options associated with the creation of a shader material.
  74136. */
  74137. export interface IShaderMaterialOptions {
  74138. /**
  74139. * Does the material work in alpha blend mode
  74140. */
  74141. needAlphaBlending: boolean;
  74142. /**
  74143. * Does the material work in alpha test mode
  74144. */
  74145. needAlphaTesting: boolean;
  74146. /**
  74147. * The list of attribute names used in the shader
  74148. */
  74149. attributes: string[];
  74150. /**
  74151. * The list of unifrom names used in the shader
  74152. */
  74153. uniforms: string[];
  74154. /**
  74155. * The list of UBO names used in the shader
  74156. */
  74157. uniformBuffers: string[];
  74158. /**
  74159. * The list of sampler names used in the shader
  74160. */
  74161. samplers: string[];
  74162. /**
  74163. * The list of defines used in the shader
  74164. */
  74165. defines: string[];
  74166. }
  74167. /**
  74168. * 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.
  74169. *
  74170. * This returned material effects how the mesh will look based on the code in the shaders.
  74171. *
  74172. * @see http://doc.babylonjs.com/how_to/shader_material
  74173. */
  74174. export class ShaderMaterial extends Material {
  74175. private _shaderPath;
  74176. private _options;
  74177. private _textures;
  74178. private _textureArrays;
  74179. private _floats;
  74180. private _ints;
  74181. private _floatsArrays;
  74182. private _colors3;
  74183. private _colors3Arrays;
  74184. private _colors4;
  74185. private _vectors2;
  74186. private _vectors3;
  74187. private _vectors4;
  74188. private _matrices;
  74189. private _matrices3x3;
  74190. private _matrices2x2;
  74191. private _vectors2Arrays;
  74192. private _vectors3Arrays;
  74193. private _cachedWorldViewMatrix;
  74194. private _renderId;
  74195. /**
  74196. * Instantiate a new shader material.
  74197. * 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.
  74198. * This returned material effects how the mesh will look based on the code in the shaders.
  74199. * @see http://doc.babylonjs.com/how_to/shader_material
  74200. * @param name Define the name of the material in the scene
  74201. * @param scene Define the scene the material belongs to
  74202. * @param shaderPath Defines the route to the shader code in one of three ways:
  74203. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74204. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74205. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74206. * @param options Define the options used to create the shader
  74207. */
  74208. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74209. /**
  74210. * Gets the current class name of the material e.g. "ShaderMaterial"
  74211. * Mainly use in serialization.
  74212. * @returns the class name
  74213. */
  74214. getClassName(): string;
  74215. /**
  74216. * Specifies if the material will require alpha blending
  74217. * @returns a boolean specifying if alpha blending is needed
  74218. */
  74219. needAlphaBlending(): boolean;
  74220. /**
  74221. * Specifies if this material should be rendered in alpha test mode
  74222. * @returns a boolean specifying if an alpha test is needed.
  74223. */
  74224. needAlphaTesting(): boolean;
  74225. private _checkUniform;
  74226. /**
  74227. * Set a texture in the shader.
  74228. * @param name Define the name of the uniform samplers as defined in the shader
  74229. * @param texture Define the texture to bind to this sampler
  74230. * @return the material itself allowing "fluent" like uniform updates
  74231. */
  74232. setTexture(name: string, texture: Texture): ShaderMaterial;
  74233. /**
  74234. * Set a texture array in the shader.
  74235. * @param name Define the name of the uniform sampler array as defined in the shader
  74236. * @param textures Define the list of textures to bind to this sampler
  74237. * @return the material itself allowing "fluent" like uniform updates
  74238. */
  74239. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74240. /**
  74241. * Set a float in the shader.
  74242. * @param name Define the name of the uniform as defined in the shader
  74243. * @param value Define the value to give to the uniform
  74244. * @return the material itself allowing "fluent" like uniform updates
  74245. */
  74246. setFloat(name: string, value: number): ShaderMaterial;
  74247. /**
  74248. * Set a int in the shader.
  74249. * @param name Define the name of the uniform as defined in the shader
  74250. * @param value Define the value to give to the uniform
  74251. * @return the material itself allowing "fluent" like uniform updates
  74252. */
  74253. setInt(name: string, value: number): ShaderMaterial;
  74254. /**
  74255. * Set an array of floats in the shader.
  74256. * @param name Define the name of the uniform as defined in the shader
  74257. * @param value Define the value to give to the uniform
  74258. * @return the material itself allowing "fluent" like uniform updates
  74259. */
  74260. setFloats(name: string, value: number[]): ShaderMaterial;
  74261. /**
  74262. * Set a vec3 in the shader from a Color3.
  74263. * @param name Define the name of the uniform as defined in the shader
  74264. * @param value Define the value to give to the uniform
  74265. * @return the material itself allowing "fluent" like uniform updates
  74266. */
  74267. setColor3(name: string, value: Color3): ShaderMaterial;
  74268. /**
  74269. * Set a vec3 array in the shader from a Color3 array.
  74270. * @param name Define the name of the uniform as defined in the shader
  74271. * @param value Define the value to give to the uniform
  74272. * @return the material itself allowing "fluent" like uniform updates
  74273. */
  74274. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74275. /**
  74276. * Set a vec4 in the shader from a Color4.
  74277. * @param name Define the name of the uniform as defined in the shader
  74278. * @param value Define the value to give to the uniform
  74279. * @return the material itself allowing "fluent" like uniform updates
  74280. */
  74281. setColor4(name: string, value: Color4): ShaderMaterial;
  74282. /**
  74283. * Set a vec2 in the shader from a Vector2.
  74284. * @param name Define the name of the uniform as defined in the shader
  74285. * @param value Define the value to give to the uniform
  74286. * @return the material itself allowing "fluent" like uniform updates
  74287. */
  74288. setVector2(name: string, value: Vector2): ShaderMaterial;
  74289. /**
  74290. * Set a vec3 in the shader from a Vector3.
  74291. * @param name Define the name of the uniform as defined in the shader
  74292. * @param value Define the value to give to the uniform
  74293. * @return the material itself allowing "fluent" like uniform updates
  74294. */
  74295. setVector3(name: string, value: Vector3): ShaderMaterial;
  74296. /**
  74297. * Set a vec4 in the shader from a Vector4.
  74298. * @param name Define the name of the uniform as defined in the shader
  74299. * @param value Define the value to give to the uniform
  74300. * @return the material itself allowing "fluent" like uniform updates
  74301. */
  74302. setVector4(name: string, value: Vector4): ShaderMaterial;
  74303. /**
  74304. * Set a mat4 in the shader from a Matrix.
  74305. * @param name Define the name of the uniform as defined in the shader
  74306. * @param value Define the value to give to the uniform
  74307. * @return the material itself allowing "fluent" like uniform updates
  74308. */
  74309. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74310. /**
  74311. * Set a mat3 in the shader from a Float32Array.
  74312. * @param name Define the name of the uniform as defined in the shader
  74313. * @param value Define the value to give to the uniform
  74314. * @return the material itself allowing "fluent" like uniform updates
  74315. */
  74316. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74317. /**
  74318. * Set a mat2 in the shader from a Float32Array.
  74319. * @param name Define the name of the uniform as defined in the shader
  74320. * @param value Define the value to give to the uniform
  74321. * @return the material itself allowing "fluent" like uniform updates
  74322. */
  74323. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74324. /**
  74325. * Set a vec2 array in the shader from a number array.
  74326. * @param name Define the name of the uniform as defined in the shader
  74327. * @param value Define the value to give to the uniform
  74328. * @return the material itself allowing "fluent" like uniform updates
  74329. */
  74330. setArray2(name: string, value: number[]): ShaderMaterial;
  74331. /**
  74332. * Set a vec3 array in the shader from a number array.
  74333. * @param name Define the name of the uniform as defined in the shader
  74334. * @param value Define the value to give to the uniform
  74335. * @return the material itself allowing "fluent" like uniform updates
  74336. */
  74337. setArray3(name: string, value: number[]): ShaderMaterial;
  74338. private _checkCache;
  74339. /**
  74340. * Checks if the material is ready to render the requested mesh
  74341. * @param mesh Define the mesh to render
  74342. * @param useInstances Define whether or not the material is used with instances
  74343. * @returns true if ready, otherwise false
  74344. */
  74345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74346. /**
  74347. * Binds the world matrix to the material
  74348. * @param world defines the world transformation matrix
  74349. */
  74350. bindOnlyWorldMatrix(world: Matrix): void;
  74351. /**
  74352. * Binds the material to the mesh
  74353. * @param world defines the world transformation matrix
  74354. * @param mesh defines the mesh to bind the material to
  74355. */
  74356. bind(world: Matrix, mesh?: Mesh): void;
  74357. /**
  74358. * Gets the active textures from the material
  74359. * @returns an array of textures
  74360. */
  74361. getActiveTextures(): BaseTexture[];
  74362. /**
  74363. * Specifies if the material uses a texture
  74364. * @param texture defines the texture to check against the material
  74365. * @returns a boolean specifying if the material uses the texture
  74366. */
  74367. hasTexture(texture: BaseTexture): boolean;
  74368. /**
  74369. * Makes a duplicate of the material, and gives it a new name
  74370. * @param name defines the new name for the duplicated material
  74371. * @returns the cloned material
  74372. */
  74373. clone(name: string): ShaderMaterial;
  74374. /**
  74375. * Disposes the material
  74376. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74377. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74378. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74379. */
  74380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74381. /**
  74382. * Serializes this material in a JSON representation
  74383. * @returns the serialized material object
  74384. */
  74385. serialize(): any;
  74386. /**
  74387. * Creates a shader material from parsed shader material data
  74388. * @param source defines the JSON represnetation of the material
  74389. * @param scene defines the hosting scene
  74390. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74391. * @returns a new material
  74392. */
  74393. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74394. }
  74395. }
  74396. declare module BABYLON {
  74397. /** @hidden */
  74398. export var colorPixelShader: {
  74399. name: string;
  74400. shader: string;
  74401. };
  74402. }
  74403. declare module BABYLON {
  74404. /** @hidden */
  74405. export var colorVertexShader: {
  74406. name: string;
  74407. shader: string;
  74408. };
  74409. }
  74410. declare module BABYLON {
  74411. /**
  74412. * Line mesh
  74413. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74414. */
  74415. export class LinesMesh extends Mesh {
  74416. /**
  74417. * If vertex color should be applied to the mesh
  74418. */
  74419. useVertexColor?: boolean | undefined;
  74420. /**
  74421. * If vertex alpha should be applied to the mesh
  74422. */
  74423. useVertexAlpha?: boolean | undefined;
  74424. /**
  74425. * Color of the line (Default: White)
  74426. */
  74427. color: Color3;
  74428. /**
  74429. * Alpha of the line (Default: 1)
  74430. */
  74431. alpha: number;
  74432. /**
  74433. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74434. * This margin is expressed in world space coordinates, so its value may vary.
  74435. * Default value is 0.1
  74436. */
  74437. intersectionThreshold: number;
  74438. private _colorShader;
  74439. /**
  74440. * Creates a new LinesMesh
  74441. * @param name defines the name
  74442. * @param scene defines the hosting scene
  74443. * @param parent defines the parent mesh if any
  74444. * @param source defines the optional source LinesMesh used to clone data from
  74445. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74446. * When false, achieved by calling a clone(), also passing False.
  74447. * This will make creation of children, recursive.
  74448. * @param useVertexColor defines if this LinesMesh supports vertex color
  74449. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74450. */
  74451. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74452. /**
  74453. * If vertex color should be applied to the mesh
  74454. */
  74455. useVertexColor?: boolean | undefined,
  74456. /**
  74457. * If vertex alpha should be applied to the mesh
  74458. */
  74459. useVertexAlpha?: boolean | undefined);
  74460. /**
  74461. * Returns the string "LineMesh"
  74462. */
  74463. getClassName(): string;
  74464. /**
  74465. * @hidden
  74466. */
  74467. /**
  74468. * @hidden
  74469. */
  74470. material: Material;
  74471. /**
  74472. * @hidden
  74473. */
  74474. readonly checkCollisions: boolean;
  74475. /** @hidden */
  74476. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74477. /** @hidden */
  74478. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74479. /**
  74480. * Disposes of the line mesh
  74481. * @param doNotRecurse If children should be disposed
  74482. */
  74483. dispose(doNotRecurse?: boolean): void;
  74484. /**
  74485. * Returns a new LineMesh object cloned from the current one.
  74486. */
  74487. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74488. /**
  74489. * Creates a new InstancedLinesMesh object from the mesh model.
  74490. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74491. * @param name defines the name of the new instance
  74492. * @returns a new InstancedLinesMesh
  74493. */
  74494. createInstance(name: string): InstancedLinesMesh;
  74495. }
  74496. /**
  74497. * Creates an instance based on a source LinesMesh
  74498. */
  74499. export class InstancedLinesMesh extends InstancedMesh {
  74500. /**
  74501. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74502. * This margin is expressed in world space coordinates, so its value may vary.
  74503. * Initilized with the intersectionThreshold value of the source LinesMesh
  74504. */
  74505. intersectionThreshold: number;
  74506. constructor(name: string, source: LinesMesh);
  74507. /**
  74508. * Returns the string "InstancedLinesMesh".
  74509. */
  74510. getClassName(): string;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /**
  74515. * Mesh representing the gorund
  74516. */
  74517. export class GroundMesh extends Mesh {
  74518. /** If octree should be generated */
  74519. generateOctree: boolean;
  74520. private _heightQuads;
  74521. /** @hidden */
  74522. _subdivisionsX: number;
  74523. /** @hidden */
  74524. _subdivisionsY: number;
  74525. /** @hidden */
  74526. _width: number;
  74527. /** @hidden */
  74528. _height: number;
  74529. /** @hidden */
  74530. _minX: number;
  74531. /** @hidden */
  74532. _maxX: number;
  74533. /** @hidden */
  74534. _minZ: number;
  74535. /** @hidden */
  74536. _maxZ: number;
  74537. constructor(name: string, scene: Scene);
  74538. /**
  74539. * "GroundMesh"
  74540. * @returns "GroundMesh"
  74541. */
  74542. getClassName(): string;
  74543. /**
  74544. * The minimum of x and y subdivisions
  74545. */
  74546. readonly subdivisions: number;
  74547. /**
  74548. * X subdivisions
  74549. */
  74550. readonly subdivisionsX: number;
  74551. /**
  74552. * Y subdivisions
  74553. */
  74554. readonly subdivisionsY: number;
  74555. /**
  74556. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74557. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74558. * @param chunksCount the number of subdivisions for x and y
  74559. * @param octreeBlocksSize (Default: 32)
  74560. */
  74561. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74562. /**
  74563. * Returns a height (y) value in the Worl system :
  74564. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74565. * @param x x coordinate
  74566. * @param z z coordinate
  74567. * @returns the ground y position if (x, z) are outside the ground surface.
  74568. */
  74569. getHeightAtCoordinates(x: number, z: number): number;
  74570. /**
  74571. * Returns a normalized vector (Vector3) orthogonal to the ground
  74572. * at the ground coordinates (x, z) expressed in the World system.
  74573. * @param x x coordinate
  74574. * @param z z coordinate
  74575. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74576. */
  74577. getNormalAtCoordinates(x: number, z: number): Vector3;
  74578. /**
  74579. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74580. * at the ground coordinates (x, z) expressed in the World system.
  74581. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74582. * @param x x coordinate
  74583. * @param z z coordinate
  74584. * @param ref vector to store the result
  74585. * @returns the GroundMesh.
  74586. */
  74587. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74588. /**
  74589. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74590. * if the ground has been updated.
  74591. * This can be used in the render loop.
  74592. * @returns the GroundMesh.
  74593. */
  74594. updateCoordinateHeights(): GroundMesh;
  74595. private _getFacetAt;
  74596. private _initHeightQuads;
  74597. private _computeHeightQuads;
  74598. /**
  74599. * Serializes this ground mesh
  74600. * @param serializationObject object to write serialization to
  74601. */
  74602. serialize(serializationObject: any): void;
  74603. /**
  74604. * Parses a serialized ground mesh
  74605. * @param parsedMesh the serialized mesh
  74606. * @param scene the scene to create the ground mesh in
  74607. * @returns the created ground mesh
  74608. */
  74609. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74610. }
  74611. }
  74612. declare module BABYLON {
  74613. /**
  74614. * Interface for Physics-Joint data
  74615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74616. */
  74617. export interface PhysicsJointData {
  74618. /**
  74619. * The main pivot of the joint
  74620. */
  74621. mainPivot?: Vector3;
  74622. /**
  74623. * The connected pivot of the joint
  74624. */
  74625. connectedPivot?: Vector3;
  74626. /**
  74627. * The main axis of the joint
  74628. */
  74629. mainAxis?: Vector3;
  74630. /**
  74631. * The connected axis of the joint
  74632. */
  74633. connectedAxis?: Vector3;
  74634. /**
  74635. * The collision of the joint
  74636. */
  74637. collision?: boolean;
  74638. /**
  74639. * Native Oimo/Cannon/Energy data
  74640. */
  74641. nativeParams?: any;
  74642. }
  74643. /**
  74644. * This is a holder class for the physics joint created by the physics plugin
  74645. * It holds a set of functions to control the underlying joint
  74646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74647. */
  74648. export class PhysicsJoint {
  74649. /**
  74650. * The type of the physics joint
  74651. */
  74652. type: number;
  74653. /**
  74654. * The data for the physics joint
  74655. */
  74656. jointData: PhysicsJointData;
  74657. private _physicsJoint;
  74658. protected _physicsPlugin: IPhysicsEnginePlugin;
  74659. /**
  74660. * Initializes the physics joint
  74661. * @param type The type of the physics joint
  74662. * @param jointData The data for the physics joint
  74663. */
  74664. constructor(
  74665. /**
  74666. * The type of the physics joint
  74667. */
  74668. type: number,
  74669. /**
  74670. * The data for the physics joint
  74671. */
  74672. jointData: PhysicsJointData);
  74673. /**
  74674. * Gets the physics joint
  74675. */
  74676. /**
  74677. * Sets the physics joint
  74678. */
  74679. physicsJoint: any;
  74680. /**
  74681. * Sets the physics plugin
  74682. */
  74683. physicsPlugin: IPhysicsEnginePlugin;
  74684. /**
  74685. * Execute a function that is physics-plugin specific.
  74686. * @param {Function} func the function that will be executed.
  74687. * It accepts two parameters: the physics world and the physics joint
  74688. */
  74689. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  74690. /**
  74691. * Distance-Joint type
  74692. */
  74693. static DistanceJoint: number;
  74694. /**
  74695. * Hinge-Joint type
  74696. */
  74697. static HingeJoint: number;
  74698. /**
  74699. * Ball-and-Socket joint type
  74700. */
  74701. static BallAndSocketJoint: number;
  74702. /**
  74703. * Wheel-Joint type
  74704. */
  74705. static WheelJoint: number;
  74706. /**
  74707. * Slider-Joint type
  74708. */
  74709. static SliderJoint: number;
  74710. /**
  74711. * Prismatic-Joint type
  74712. */
  74713. static PrismaticJoint: number;
  74714. /**
  74715. * Universal-Joint type
  74716. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  74717. */
  74718. static UniversalJoint: number;
  74719. /**
  74720. * Hinge-Joint 2 type
  74721. */
  74722. static Hinge2Joint: number;
  74723. /**
  74724. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  74725. */
  74726. static PointToPointJoint: number;
  74727. /**
  74728. * Spring-Joint type
  74729. */
  74730. static SpringJoint: number;
  74731. /**
  74732. * Lock-Joint type
  74733. */
  74734. static LockJoint: number;
  74735. }
  74736. /**
  74737. * A class representing a physics distance joint
  74738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74739. */
  74740. export class DistanceJoint extends PhysicsJoint {
  74741. /**
  74742. *
  74743. * @param jointData The data for the Distance-Joint
  74744. */
  74745. constructor(jointData: DistanceJointData);
  74746. /**
  74747. * Update the predefined distance.
  74748. * @param maxDistance The maximum preferred distance
  74749. * @param minDistance The minimum preferred distance
  74750. */
  74751. updateDistance(maxDistance: number, minDistance?: number): void;
  74752. }
  74753. /**
  74754. * Represents a Motor-Enabled Joint
  74755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74756. */
  74757. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74758. /**
  74759. * Initializes the Motor-Enabled Joint
  74760. * @param type The type of the joint
  74761. * @param jointData The physica joint data for the joint
  74762. */
  74763. constructor(type: number, jointData: PhysicsJointData);
  74764. /**
  74765. * Set the motor values.
  74766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74767. * @param force the force to apply
  74768. * @param maxForce max force for this motor.
  74769. */
  74770. setMotor(force?: number, maxForce?: number): void;
  74771. /**
  74772. * Set the motor's limits.
  74773. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74774. * @param upperLimit The upper limit of the motor
  74775. * @param lowerLimit The lower limit of the motor
  74776. */
  74777. setLimit(upperLimit: number, lowerLimit?: number): void;
  74778. }
  74779. /**
  74780. * This class represents a single physics Hinge-Joint
  74781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74782. */
  74783. export class HingeJoint extends MotorEnabledJoint {
  74784. /**
  74785. * Initializes the Hinge-Joint
  74786. * @param jointData The joint data for the Hinge-Joint
  74787. */
  74788. constructor(jointData: PhysicsJointData);
  74789. /**
  74790. * Set the motor values.
  74791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74792. * @param {number} force the force to apply
  74793. * @param {number} maxForce max force for this motor.
  74794. */
  74795. setMotor(force?: number, maxForce?: number): void;
  74796. /**
  74797. * Set the motor's limits.
  74798. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74799. * @param upperLimit The upper limit of the motor
  74800. * @param lowerLimit The lower limit of the motor
  74801. */
  74802. setLimit(upperLimit: number, lowerLimit?: number): void;
  74803. }
  74804. /**
  74805. * This class represents a dual hinge physics joint (same as wheel joint)
  74806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74807. */
  74808. export class Hinge2Joint extends MotorEnabledJoint {
  74809. /**
  74810. * Initializes the Hinge2-Joint
  74811. * @param jointData The joint data for the Hinge2-Joint
  74812. */
  74813. constructor(jointData: PhysicsJointData);
  74814. /**
  74815. * Set the motor values.
  74816. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74817. * @param {number} force the force to apply
  74818. * @param {number} maxForce max force for this motor.
  74819. * @param {motorIndex} the motor's index, 0 or 1.
  74820. */
  74821. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74822. /**
  74823. * Set the motor limits.
  74824. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74825. * @param {number} upperLimit the upper limit
  74826. * @param {number} lowerLimit lower limit
  74827. * @param {motorIndex} the motor's index, 0 or 1.
  74828. */
  74829. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74830. }
  74831. /**
  74832. * Interface for a motor enabled joint
  74833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74834. */
  74835. export interface IMotorEnabledJoint {
  74836. /**
  74837. * Physics joint
  74838. */
  74839. physicsJoint: any;
  74840. /**
  74841. * Sets the motor of the motor-enabled joint
  74842. * @param force The force of the motor
  74843. * @param maxForce The maximum force of the motor
  74844. * @param motorIndex The index of the motor
  74845. */
  74846. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74847. /**
  74848. * Sets the limit of the motor
  74849. * @param upperLimit The upper limit of the motor
  74850. * @param lowerLimit The lower limit of the motor
  74851. * @param motorIndex The index of the motor
  74852. */
  74853. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74854. }
  74855. /**
  74856. * Joint data for a Distance-Joint
  74857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74858. */
  74859. export interface DistanceJointData extends PhysicsJointData {
  74860. /**
  74861. * Max distance the 2 joint objects can be apart
  74862. */
  74863. maxDistance: number;
  74864. }
  74865. /**
  74866. * Joint data from a spring joint
  74867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74868. */
  74869. export interface SpringJointData extends PhysicsJointData {
  74870. /**
  74871. * Length of the spring
  74872. */
  74873. length: number;
  74874. /**
  74875. * Stiffness of the spring
  74876. */
  74877. stiffness: number;
  74878. /**
  74879. * Damping of the spring
  74880. */
  74881. damping: number;
  74882. /** this callback will be called when applying the force to the impostors. */
  74883. forceApplicationCallback: () => void;
  74884. }
  74885. }
  74886. declare module BABYLON {
  74887. /**
  74888. * Interface used to describe a physics joint
  74889. */
  74890. export interface PhysicsImpostorJoint {
  74891. /** Defines the main impostor to which the joint is linked */
  74892. mainImpostor: PhysicsImpostor;
  74893. /** Defines the impostor that is connected to the main impostor using this joint */
  74894. connectedImpostor: PhysicsImpostor;
  74895. /** Defines the joint itself */
  74896. joint: PhysicsJoint;
  74897. }
  74898. /** @hidden */
  74899. export interface IPhysicsEnginePlugin {
  74900. world: any;
  74901. name: string;
  74902. setGravity(gravity: Vector3): void;
  74903. setTimeStep(timeStep: number): void;
  74904. getTimeStep(): number;
  74905. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74906. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74907. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74908. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74909. removePhysicsBody(impostor: PhysicsImpostor): void;
  74910. generateJoint(joint: PhysicsImpostorJoint): void;
  74911. removeJoint(joint: PhysicsImpostorJoint): void;
  74912. isSupported(): boolean;
  74913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74915. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74916. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74917. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74918. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74919. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74920. getBodyMass(impostor: PhysicsImpostor): number;
  74921. getBodyFriction(impostor: PhysicsImpostor): number;
  74922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74923. getBodyRestitution(impostor: PhysicsImpostor): number;
  74924. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74925. sleepBody(impostor: PhysicsImpostor): void;
  74926. wakeUpBody(impostor: PhysicsImpostor): void;
  74927. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74928. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74929. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74930. getRadius(impostor: PhysicsImpostor): number;
  74931. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74932. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74933. dispose(): void;
  74934. }
  74935. /**
  74936. * Interface used to define a physics engine
  74937. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74938. */
  74939. export interface IPhysicsEngine {
  74940. /**
  74941. * Gets the gravity vector used by the simulation
  74942. */
  74943. gravity: Vector3;
  74944. /**
  74945. * Sets the gravity vector used by the simulation
  74946. * @param gravity defines the gravity vector to use
  74947. */
  74948. setGravity(gravity: Vector3): void;
  74949. /**
  74950. * Set the time step of the physics engine.
  74951. * Default is 1/60.
  74952. * To slow it down, enter 1/600 for example.
  74953. * To speed it up, 1/30
  74954. * @param newTimeStep the new timestep to apply to this world.
  74955. */
  74956. setTimeStep(newTimeStep: number): void;
  74957. /**
  74958. * Get the time step of the physics engine.
  74959. * @returns the current time step
  74960. */
  74961. getTimeStep(): number;
  74962. /**
  74963. * Release all resources
  74964. */
  74965. dispose(): void;
  74966. /**
  74967. * Gets the name of the current physics plugin
  74968. * @returns the name of the plugin
  74969. */
  74970. getPhysicsPluginName(): string;
  74971. /**
  74972. * Adding a new impostor for the impostor tracking.
  74973. * This will be done by the impostor itself.
  74974. * @param impostor the impostor to add
  74975. */
  74976. addImpostor(impostor: PhysicsImpostor): void;
  74977. /**
  74978. * Remove an impostor from the engine.
  74979. * This impostor and its mesh will not longer be updated by the physics engine.
  74980. * @param impostor the impostor to remove
  74981. */
  74982. removeImpostor(impostor: PhysicsImpostor): void;
  74983. /**
  74984. * Add a joint to the physics engine
  74985. * @param mainImpostor defines the main impostor to which the joint is added.
  74986. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  74987. * @param joint defines the joint that will connect both impostors.
  74988. */
  74989. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74990. /**
  74991. * Removes a joint from the simulation
  74992. * @param mainImpostor defines the impostor used with the joint
  74993. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  74994. * @param joint defines the joint to remove
  74995. */
  74996. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74997. /**
  74998. * Gets the current plugin used to run the simulation
  74999. * @returns current plugin
  75000. */
  75001. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75002. /**
  75003. * Gets the list of physic impostors
  75004. * @returns an array of PhysicsImpostor
  75005. */
  75006. getImpostors(): Array<PhysicsImpostor>;
  75007. /**
  75008. * Gets the impostor for a physics enabled object
  75009. * @param object defines the object impersonated by the impostor
  75010. * @returns the PhysicsImpostor or null if not found
  75011. */
  75012. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75013. /**
  75014. * Gets the impostor for a physics body object
  75015. * @param body defines physics body used by the impostor
  75016. * @returns the PhysicsImpostor or null if not found
  75017. */
  75018. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75019. /**
  75020. * Called by the scene. No need to call it.
  75021. * @param delta defines the timespam between frames
  75022. */
  75023. _step(delta: number): void;
  75024. }
  75025. }
  75026. declare module BABYLON {
  75027. /**
  75028. * The interface for the physics imposter parameters
  75029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75030. */
  75031. export interface PhysicsImpostorParameters {
  75032. /**
  75033. * The mass of the physics imposter
  75034. */
  75035. mass: number;
  75036. /**
  75037. * The friction of the physics imposter
  75038. */
  75039. friction?: number;
  75040. /**
  75041. * The coefficient of restitution of the physics imposter
  75042. */
  75043. restitution?: number;
  75044. /**
  75045. * The native options of the physics imposter
  75046. */
  75047. nativeOptions?: any;
  75048. /**
  75049. * Specifies if the parent should be ignored
  75050. */
  75051. ignoreParent?: boolean;
  75052. /**
  75053. * Specifies if bi-directional transformations should be disabled
  75054. */
  75055. disableBidirectionalTransformation?: boolean;
  75056. }
  75057. /**
  75058. * Interface for a physics-enabled object
  75059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75060. */
  75061. export interface IPhysicsEnabledObject {
  75062. /**
  75063. * The position of the physics-enabled object
  75064. */
  75065. position: Vector3;
  75066. /**
  75067. * The rotation of the physics-enabled object
  75068. */
  75069. rotationQuaternion: Nullable<Quaternion>;
  75070. /**
  75071. * The scale of the physics-enabled object
  75072. */
  75073. scaling: Vector3;
  75074. /**
  75075. * The rotation of the physics-enabled object
  75076. */
  75077. rotation?: Vector3;
  75078. /**
  75079. * The parent of the physics-enabled object
  75080. */
  75081. parent?: any;
  75082. /**
  75083. * The bounding info of the physics-enabled object
  75084. * @returns The bounding info of the physics-enabled object
  75085. */
  75086. getBoundingInfo(): BoundingInfo;
  75087. /**
  75088. * Computes the world matrix
  75089. * @param force Specifies if the world matrix should be computed by force
  75090. * @returns A world matrix
  75091. */
  75092. computeWorldMatrix(force: boolean): Matrix;
  75093. /**
  75094. * Gets the world matrix
  75095. * @returns A world matrix
  75096. */
  75097. getWorldMatrix?(): Matrix;
  75098. /**
  75099. * Gets the child meshes
  75100. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75101. * @returns An array of abstract meshes
  75102. */
  75103. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75104. /**
  75105. * Gets the vertex data
  75106. * @param kind The type of vertex data
  75107. * @returns A nullable array of numbers, or a float32 array
  75108. */
  75109. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75110. /**
  75111. * Gets the indices from the mesh
  75112. * @returns A nullable array of index arrays
  75113. */
  75114. getIndices?(): Nullable<IndicesArray>;
  75115. /**
  75116. * Gets the scene from the mesh
  75117. * @returns the indices array or null
  75118. */
  75119. getScene?(): Scene;
  75120. /**
  75121. * Gets the absolute position from the mesh
  75122. * @returns the absolute position
  75123. */
  75124. getAbsolutePosition(): Vector3;
  75125. /**
  75126. * Gets the absolute pivot point from the mesh
  75127. * @returns the absolute pivot point
  75128. */
  75129. getAbsolutePivotPoint(): Vector3;
  75130. /**
  75131. * Rotates the mesh
  75132. * @param axis The axis of rotation
  75133. * @param amount The amount of rotation
  75134. * @param space The space of the rotation
  75135. * @returns The rotation transform node
  75136. */
  75137. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75138. /**
  75139. * Translates the mesh
  75140. * @param axis The axis of translation
  75141. * @param distance The distance of translation
  75142. * @param space The space of the translation
  75143. * @returns The transform node
  75144. */
  75145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75146. /**
  75147. * Sets the absolute position of the mesh
  75148. * @param absolutePosition The absolute position of the mesh
  75149. * @returns The transform node
  75150. */
  75151. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75152. /**
  75153. * Gets the class name of the mesh
  75154. * @returns The class name
  75155. */
  75156. getClassName(): string;
  75157. }
  75158. /**
  75159. * Represents a physics imposter
  75160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75161. */
  75162. export class PhysicsImpostor {
  75163. /**
  75164. * The physics-enabled object used as the physics imposter
  75165. */
  75166. object: IPhysicsEnabledObject;
  75167. /**
  75168. * The type of the physics imposter
  75169. */
  75170. type: number;
  75171. private _options;
  75172. private _scene?;
  75173. /**
  75174. * The default object size of the imposter
  75175. */
  75176. static DEFAULT_OBJECT_SIZE: Vector3;
  75177. /**
  75178. * The identity quaternion of the imposter
  75179. */
  75180. static IDENTITY_QUATERNION: Quaternion;
  75181. /** @hidden */
  75182. _pluginData: any;
  75183. private _physicsEngine;
  75184. private _physicsBody;
  75185. private _bodyUpdateRequired;
  75186. private _onBeforePhysicsStepCallbacks;
  75187. private _onAfterPhysicsStepCallbacks;
  75188. /** @hidden */
  75189. _onPhysicsCollideCallbacks: Array<{
  75190. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75191. otherImpostors: Array<PhysicsImpostor>;
  75192. }>;
  75193. private _deltaPosition;
  75194. private _deltaRotation;
  75195. private _deltaRotationConjugated;
  75196. private _parent;
  75197. private _isDisposed;
  75198. private static _tmpVecs;
  75199. private static _tmpQuat;
  75200. /**
  75201. * Specifies if the physics imposter is disposed
  75202. */
  75203. readonly isDisposed: boolean;
  75204. /**
  75205. * Gets the mass of the physics imposter
  75206. */
  75207. mass: number;
  75208. /**
  75209. * Gets the coefficient of friction
  75210. */
  75211. /**
  75212. * Sets the coefficient of friction
  75213. */
  75214. friction: number;
  75215. /**
  75216. * Gets the coefficient of restitution
  75217. */
  75218. /**
  75219. * Sets the coefficient of restitution
  75220. */
  75221. restitution: number;
  75222. /**
  75223. * The unique id of the physics imposter
  75224. * set by the physics engine when adding this impostor to the array
  75225. */
  75226. uniqueId: number;
  75227. private _joints;
  75228. /**
  75229. * Initializes the physics imposter
  75230. * @param object The physics-enabled object used as the physics imposter
  75231. * @param type The type of the physics imposter
  75232. * @param _options The options for the physics imposter
  75233. * @param _scene The Babylon scene
  75234. */
  75235. constructor(
  75236. /**
  75237. * The physics-enabled object used as the physics imposter
  75238. */
  75239. object: IPhysicsEnabledObject,
  75240. /**
  75241. * The type of the physics imposter
  75242. */
  75243. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  75244. /**
  75245. * This function will completly initialize this impostor.
  75246. * It will create a new body - but only if this mesh has no parent.
  75247. * If it has, this impostor will not be used other than to define the impostor
  75248. * of the child mesh.
  75249. * @hidden
  75250. */
  75251. _init(): void;
  75252. private _getPhysicsParent;
  75253. /**
  75254. * Should a new body be generated.
  75255. * @returns boolean specifying if body initialization is required
  75256. */
  75257. isBodyInitRequired(): boolean;
  75258. /**
  75259. * Sets the updated scaling
  75260. * @param updated Specifies if the scaling is updated
  75261. */
  75262. setScalingUpdated(): void;
  75263. /**
  75264. * Force a regeneration of this or the parent's impostor's body.
  75265. * Use under cautious - This will remove all joints already implemented.
  75266. */
  75267. forceUpdate(): void;
  75268. /**
  75269. * Gets the body that holds this impostor. Either its own, or its parent.
  75270. */
  75271. /**
  75272. * Set the physics body. Used mainly by the physics engine/plugin
  75273. */
  75274. physicsBody: any;
  75275. /**
  75276. * Get the parent of the physics imposter
  75277. * @returns Physics imposter or null
  75278. */
  75279. /**
  75280. * Sets the parent of the physics imposter
  75281. */
  75282. parent: Nullable<PhysicsImpostor>;
  75283. /**
  75284. * Resets the update flags
  75285. */
  75286. resetUpdateFlags(): void;
  75287. /**
  75288. * Gets the object extend size
  75289. * @returns the object extend size
  75290. */
  75291. getObjectExtendSize(): Vector3;
  75292. /**
  75293. * Gets the object center
  75294. * @returns The object center
  75295. */
  75296. getObjectCenter(): Vector3;
  75297. /**
  75298. * Get a specific parametes from the options parameter
  75299. * @param paramName The object parameter name
  75300. * @returns The object parameter
  75301. */
  75302. getParam(paramName: string): any;
  75303. /**
  75304. * Sets a specific parameter in the options given to the physics plugin
  75305. * @param paramName The parameter name
  75306. * @param value The value of the parameter
  75307. */
  75308. setParam(paramName: string, value: number): void;
  75309. /**
  75310. * Specifically change the body's mass option. Won't recreate the physics body object
  75311. * @param mass The mass of the physics imposter
  75312. */
  75313. setMass(mass: number): void;
  75314. /**
  75315. * Gets the linear velocity
  75316. * @returns linear velocity or null
  75317. */
  75318. getLinearVelocity(): Nullable<Vector3>;
  75319. /**
  75320. * Sets the linear velocity
  75321. * @param velocity linear velocity or null
  75322. */
  75323. setLinearVelocity(velocity: Nullable<Vector3>): void;
  75324. /**
  75325. * Gets the angular velocity
  75326. * @returns angular velocity or null
  75327. */
  75328. getAngularVelocity(): Nullable<Vector3>;
  75329. /**
  75330. * Sets the angular velocity
  75331. * @param velocity The velocity or null
  75332. */
  75333. setAngularVelocity(velocity: Nullable<Vector3>): void;
  75334. /**
  75335. * Execute a function with the physics plugin native code
  75336. * Provide a function the will have two variables - the world object and the physics body object
  75337. * @param func The function to execute with the physics plugin native code
  75338. */
  75339. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  75340. /**
  75341. * Register a function that will be executed before the physics world is stepping forward
  75342. * @param func The function to execute before the physics world is stepped forward
  75343. */
  75344. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75345. /**
  75346. * Unregister a function that will be executed before the physics world is stepping forward
  75347. * @param func The function to execute before the physics world is stepped forward
  75348. */
  75349. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75350. /**
  75351. * Register a function that will be executed after the physics step
  75352. * @param func The function to execute after physics step
  75353. */
  75354. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75355. /**
  75356. * Unregisters a function that will be executed after the physics step
  75357. * @param func The function to execute after physics step
  75358. */
  75359. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75360. /**
  75361. * register a function that will be executed when this impostor collides against a different body
  75362. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  75363. * @param func Callback that is executed on collision
  75364. */
  75365. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  75366. /**
  75367. * Unregisters the physics imposter on contact
  75368. * @param collideAgainst The physics object to collide against
  75369. * @param func Callback to execute on collision
  75370. */
  75371. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  75372. private _tmpQuat;
  75373. private _tmpQuat2;
  75374. /**
  75375. * Get the parent rotation
  75376. * @returns The parent rotation
  75377. */
  75378. getParentsRotation(): Quaternion;
  75379. /**
  75380. * this function is executed by the physics engine.
  75381. */
  75382. beforeStep: () => void;
  75383. /**
  75384. * this function is executed by the physics engine
  75385. */
  75386. afterStep: () => void;
  75387. /**
  75388. * Legacy collision detection event support
  75389. */
  75390. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  75391. /**
  75392. * event and body object due to cannon's event-based architecture.
  75393. */
  75394. onCollide: (e: {
  75395. body: any;
  75396. }) => void;
  75397. /**
  75398. * Apply a force
  75399. * @param force The force to apply
  75400. * @param contactPoint The contact point for the force
  75401. * @returns The physics imposter
  75402. */
  75403. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75404. /**
  75405. * Apply an impulse
  75406. * @param force The impulse force
  75407. * @param contactPoint The contact point for the impulse force
  75408. * @returns The physics imposter
  75409. */
  75410. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75411. /**
  75412. * A help function to create a joint
  75413. * @param otherImpostor A physics imposter used to create a joint
  75414. * @param jointType The type of joint
  75415. * @param jointData The data for the joint
  75416. * @returns The physics imposter
  75417. */
  75418. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  75419. /**
  75420. * Add a joint to this impostor with a different impostor
  75421. * @param otherImpostor A physics imposter used to add a joint
  75422. * @param joint The joint to add
  75423. * @returns The physics imposter
  75424. */
  75425. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  75426. /**
  75427. * Will keep this body still, in a sleep mode.
  75428. * @returns the physics imposter
  75429. */
  75430. sleep(): PhysicsImpostor;
  75431. /**
  75432. * Wake the body up.
  75433. * @returns The physics imposter
  75434. */
  75435. wakeUp(): PhysicsImpostor;
  75436. /**
  75437. * Clones the physics imposter
  75438. * @param newObject The physics imposter clones to this physics-enabled object
  75439. * @returns A nullable physics imposter
  75440. */
  75441. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75442. /**
  75443. * Disposes the physics imposter
  75444. */
  75445. dispose(): void;
  75446. /**
  75447. * Sets the delta position
  75448. * @param position The delta position amount
  75449. */
  75450. setDeltaPosition(position: Vector3): void;
  75451. /**
  75452. * Sets the delta rotation
  75453. * @param rotation The delta rotation amount
  75454. */
  75455. setDeltaRotation(rotation: Quaternion): void;
  75456. /**
  75457. * Gets the box size of the physics imposter and stores the result in the input parameter
  75458. * @param result Stores the box size
  75459. * @returns The physics imposter
  75460. */
  75461. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  75462. /**
  75463. * Gets the radius of the physics imposter
  75464. * @returns Radius of the physics imposter
  75465. */
  75466. getRadius(): number;
  75467. /**
  75468. * Sync a bone with this impostor
  75469. * @param bone The bone to sync to the impostor.
  75470. * @param boneMesh The mesh that the bone is influencing.
  75471. * @param jointPivot The pivot of the joint / bone in local space.
  75472. * @param distToJoint Optional distance from the impostor to the joint.
  75473. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75474. */
  75475. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  75476. /**
  75477. * Sync impostor to a bone
  75478. * @param bone The bone that the impostor will be synced to.
  75479. * @param boneMesh The mesh that the bone is influencing.
  75480. * @param jointPivot The pivot of the joint / bone in local space.
  75481. * @param distToJoint Optional distance from the impostor to the joint.
  75482. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75483. * @param boneAxis Optional vector3 axis the bone is aligned with
  75484. */
  75485. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  75486. /**
  75487. * No-Imposter type
  75488. */
  75489. static NoImpostor: number;
  75490. /**
  75491. * Sphere-Imposter type
  75492. */
  75493. static SphereImpostor: number;
  75494. /**
  75495. * Box-Imposter type
  75496. */
  75497. static BoxImpostor: number;
  75498. /**
  75499. * Plane-Imposter type
  75500. */
  75501. static PlaneImpostor: number;
  75502. /**
  75503. * Mesh-imposter type
  75504. */
  75505. static MeshImpostor: number;
  75506. /**
  75507. * Cylinder-Imposter type
  75508. */
  75509. static CylinderImpostor: number;
  75510. /**
  75511. * Particle-Imposter type
  75512. */
  75513. static ParticleImpostor: number;
  75514. /**
  75515. * Heightmap-Imposter type
  75516. */
  75517. static HeightmapImpostor: number;
  75518. }
  75519. }
  75520. declare module BABYLON {
  75521. /**
  75522. * Class used to represent a specific level of detail of a mesh
  75523. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75524. */
  75525. export class MeshLODLevel {
  75526. /** Defines the distance where this level should star being displayed */
  75527. distance: number;
  75528. /** Defines the mesh to use to render this level */
  75529. mesh: Nullable<Mesh>;
  75530. /**
  75531. * Creates a new LOD level
  75532. * @param distance defines the distance where this level should star being displayed
  75533. * @param mesh defines the mesh to use to render this level
  75534. */
  75535. constructor(
  75536. /** Defines the distance where this level should star being displayed */
  75537. distance: number,
  75538. /** Defines the mesh to use to render this level */
  75539. mesh: Nullable<Mesh>);
  75540. }
  75541. /**
  75542. * @hidden
  75543. **/
  75544. export class _CreationDataStorage {
  75545. closePath?: boolean;
  75546. closeArray?: boolean;
  75547. idx: number[];
  75548. dashSize: number;
  75549. gapSize: number;
  75550. path3D: Path3D;
  75551. pathArray: Vector3[][];
  75552. arc: number;
  75553. radius: number;
  75554. cap: number;
  75555. tessellation: number;
  75556. }
  75557. /**
  75558. * @hidden
  75559. **/
  75560. class _InstanceDataStorage {
  75561. visibleInstances: any;
  75562. renderIdForInstances: number[];
  75563. batchCache: _InstancesBatch;
  75564. instancesBufferSize: number;
  75565. instancesBuffer: Nullable<Buffer>;
  75566. instancesData: Float32Array;
  75567. overridenInstanceCount: number;
  75568. }
  75569. /**
  75570. * @hidden
  75571. **/
  75572. export class _InstancesBatch {
  75573. mustReturn: boolean;
  75574. visibleInstances: Nullable<InstancedMesh[]>[];
  75575. renderSelf: boolean[];
  75576. }
  75577. /**
  75578. * Class used to represent renderable models
  75579. */
  75580. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  75581. /**
  75582. * Mesh side orientation : usually the external or front surface
  75583. */
  75584. static readonly FRONTSIDE: number;
  75585. /**
  75586. * Mesh side orientation : usually the internal or back surface
  75587. */
  75588. static readonly BACKSIDE: number;
  75589. /**
  75590. * Mesh side orientation : both internal and external or front and back surfaces
  75591. */
  75592. static readonly DOUBLESIDE: number;
  75593. /**
  75594. * Mesh side orientation : by default, `FRONTSIDE`
  75595. */
  75596. static readonly DEFAULTSIDE: number;
  75597. /**
  75598. * Mesh cap setting : no cap
  75599. */
  75600. static readonly NO_CAP: number;
  75601. /**
  75602. * Mesh cap setting : one cap at the beginning of the mesh
  75603. */
  75604. static readonly CAP_START: number;
  75605. /**
  75606. * Mesh cap setting : one cap at the end of the mesh
  75607. */
  75608. static readonly CAP_END: number;
  75609. /**
  75610. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  75611. */
  75612. static readonly CAP_ALL: number;
  75613. /**
  75614. * Gets the default side orientation.
  75615. * @param orientation the orientation to value to attempt to get
  75616. * @returns the default orientation
  75617. * @hidden
  75618. */
  75619. static _GetDefaultSideOrientation(orientation?: number): number;
  75620. private _onBeforeRenderObservable;
  75621. private _onBeforeBindObservable;
  75622. private _onAfterRenderObservable;
  75623. private _onBeforeDrawObservable;
  75624. /**
  75625. * An event triggered before rendering the mesh
  75626. */
  75627. readonly onBeforeRenderObservable: Observable<Mesh>;
  75628. /**
  75629. * An event triggered before binding the mesh
  75630. */
  75631. readonly onBeforeBindObservable: Observable<Mesh>;
  75632. /**
  75633. * An event triggered after rendering the mesh
  75634. */
  75635. readonly onAfterRenderObservable: Observable<Mesh>;
  75636. /**
  75637. * An event triggered before drawing the mesh
  75638. */
  75639. readonly onBeforeDrawObservable: Observable<Mesh>;
  75640. private _onBeforeDrawObserver;
  75641. /**
  75642. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  75643. */
  75644. onBeforeDraw: () => void;
  75645. /**
  75646. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75647. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75648. */
  75649. delayLoadState: number;
  75650. /**
  75651. * Gets the list of instances created from this mesh
  75652. * it is not supposed to be modified manually.
  75653. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75655. */
  75656. instances: InstancedMesh[];
  75657. /**
  75658. * Gets the file containing delay loading data for this mesh
  75659. */
  75660. delayLoadingFile: string;
  75661. /** @hidden */
  75662. _binaryInfo: any;
  75663. private _LODLevels;
  75664. /**
  75665. * User defined function used to change how LOD level selection is done
  75666. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75667. */
  75668. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75669. private _morphTargetManager;
  75670. /**
  75671. * Gets or sets the morph target manager
  75672. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75673. */
  75674. morphTargetManager: Nullable<MorphTargetManager>;
  75675. /** @hidden */
  75676. _creationDataStorage: Nullable<_CreationDataStorage>;
  75677. /** @hidden */
  75678. _geometry: Nullable<Geometry>;
  75679. /** @hidden */
  75680. _delayInfo: Array<string>;
  75681. /** @hidden */
  75682. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75683. /** @hidden */
  75684. _instanceDataStorage: _InstanceDataStorage;
  75685. private _effectiveMaterial;
  75686. /** @hidden */
  75687. _shouldGenerateFlatShading: boolean;
  75688. private _preActivateId;
  75689. /** @hidden */
  75690. _originalBuilderSideOrientation: number;
  75691. /**
  75692. * Use this property to change the original side orientation defined at construction time
  75693. */
  75694. overrideMaterialSideOrientation: Nullable<number>;
  75695. private _areNormalsFrozen;
  75696. private _sourcePositions;
  75697. private _sourceNormals;
  75698. private _source;
  75699. private meshMap;
  75700. /**
  75701. * Gets the source mesh (the one used to clone this one from)
  75702. */
  75703. readonly source: Nullable<Mesh>;
  75704. /**
  75705. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75706. */
  75707. isUnIndexed: boolean;
  75708. /**
  75709. * @constructor
  75710. * @param name The value used by scene.getMeshByName() to do a lookup.
  75711. * @param scene The scene to add this mesh to.
  75712. * @param parent The parent of this mesh, if it has one
  75713. * @param source An optional Mesh from which geometry is shared, cloned.
  75714. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75715. * When false, achieved by calling a clone(), also passing False.
  75716. * This will make creation of children, recursive.
  75717. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75718. */
  75719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75720. /**
  75721. * Gets the class name
  75722. * @returns the string "Mesh".
  75723. */
  75724. getClassName(): string;
  75725. /** @hidden */
  75726. readonly _isMesh: boolean;
  75727. /**
  75728. * Returns a description of this mesh
  75729. * @param fullDetails define if full details about this mesh must be used
  75730. * @returns a descriptive string representing this mesh
  75731. */
  75732. toString(fullDetails?: boolean): string;
  75733. /** @hidden */
  75734. _unBindEffect(): void;
  75735. /**
  75736. * Gets a boolean indicating if this mesh has LOD
  75737. */
  75738. readonly hasLODLevels: boolean;
  75739. /**
  75740. * Gets the list of MeshLODLevel associated with the current mesh
  75741. * @returns an array of MeshLODLevel
  75742. */
  75743. getLODLevels(): MeshLODLevel[];
  75744. private _sortLODLevels;
  75745. /**
  75746. * Add a mesh as LOD level triggered at the given distance.
  75747. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75748. * @param distance The distance from the center of the object to show this level
  75749. * @param mesh The mesh to be added as LOD level (can be null)
  75750. * @return This mesh (for chaining)
  75751. */
  75752. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75753. /**
  75754. * Returns the LOD level mesh at the passed distance or null if not found.
  75755. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75756. * @param distance The distance from the center of the object to show this level
  75757. * @returns a Mesh or `null`
  75758. */
  75759. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75760. /**
  75761. * Remove a mesh from the LOD array
  75762. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75763. * @param mesh defines the mesh to be removed
  75764. * @return This mesh (for chaining)
  75765. */
  75766. removeLODLevel(mesh: Mesh): Mesh;
  75767. /**
  75768. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75769. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75770. * @param camera defines the camera to use to compute distance
  75771. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75772. * @return This mesh (for chaining)
  75773. */
  75774. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75775. /**
  75776. * Gets the mesh internal Geometry object
  75777. */
  75778. readonly geometry: Nullable<Geometry>;
  75779. /**
  75780. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75781. * @returns the total number of vertices
  75782. */
  75783. getTotalVertices(): number;
  75784. /**
  75785. * Returns the content of an associated vertex buffer
  75786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75787. * - VertexBuffer.PositionKind
  75788. * - VertexBuffer.UVKind
  75789. * - VertexBuffer.UV2Kind
  75790. * - VertexBuffer.UV3Kind
  75791. * - VertexBuffer.UV4Kind
  75792. * - VertexBuffer.UV5Kind
  75793. * - VertexBuffer.UV6Kind
  75794. * - VertexBuffer.ColorKind
  75795. * - VertexBuffer.MatricesIndicesKind
  75796. * - VertexBuffer.MatricesIndicesExtraKind
  75797. * - VertexBuffer.MatricesWeightsKind
  75798. * - VertexBuffer.MatricesWeightsExtraKind
  75799. * @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
  75800. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75801. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75802. */
  75803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75804. /**
  75805. * Returns the mesh VertexBuffer object from the requested `kind`
  75806. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75807. * - VertexBuffer.PositionKind
  75808. * - VertexBuffer.UVKind
  75809. * - VertexBuffer.UV2Kind
  75810. * - VertexBuffer.UV3Kind
  75811. * - VertexBuffer.UV4Kind
  75812. * - VertexBuffer.UV5Kind
  75813. * - VertexBuffer.UV6Kind
  75814. * - VertexBuffer.ColorKind
  75815. * - VertexBuffer.MatricesIndicesKind
  75816. * - VertexBuffer.MatricesIndicesExtraKind
  75817. * - VertexBuffer.MatricesWeightsKind
  75818. * - VertexBuffer.MatricesWeightsExtraKind
  75819. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75820. */
  75821. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75822. /**
  75823. * Tests if a specific vertex buffer is associated with this mesh
  75824. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75825. * - VertexBuffer.PositionKind
  75826. * - VertexBuffer.UVKind
  75827. * - VertexBuffer.UV2Kind
  75828. * - VertexBuffer.UV3Kind
  75829. * - VertexBuffer.UV4Kind
  75830. * - VertexBuffer.UV5Kind
  75831. * - VertexBuffer.UV6Kind
  75832. * - VertexBuffer.ColorKind
  75833. * - VertexBuffer.MatricesIndicesKind
  75834. * - VertexBuffer.MatricesIndicesExtraKind
  75835. * - VertexBuffer.MatricesWeightsKind
  75836. * - VertexBuffer.MatricesWeightsExtraKind
  75837. * @returns a boolean
  75838. */
  75839. isVerticesDataPresent(kind: string): boolean;
  75840. /**
  75841. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75842. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75843. * - VertexBuffer.PositionKind
  75844. * - VertexBuffer.UVKind
  75845. * - VertexBuffer.UV2Kind
  75846. * - VertexBuffer.UV3Kind
  75847. * - VertexBuffer.UV4Kind
  75848. * - VertexBuffer.UV5Kind
  75849. * - VertexBuffer.UV6Kind
  75850. * - VertexBuffer.ColorKind
  75851. * - VertexBuffer.MatricesIndicesKind
  75852. * - VertexBuffer.MatricesIndicesExtraKind
  75853. * - VertexBuffer.MatricesWeightsKind
  75854. * - VertexBuffer.MatricesWeightsExtraKind
  75855. * @returns a boolean
  75856. */
  75857. isVertexBufferUpdatable(kind: string): boolean;
  75858. /**
  75859. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75860. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75861. * - VertexBuffer.PositionKind
  75862. * - VertexBuffer.UVKind
  75863. * - VertexBuffer.UV2Kind
  75864. * - VertexBuffer.UV3Kind
  75865. * - VertexBuffer.UV4Kind
  75866. * - VertexBuffer.UV5Kind
  75867. * - VertexBuffer.UV6Kind
  75868. * - VertexBuffer.ColorKind
  75869. * - VertexBuffer.MatricesIndicesKind
  75870. * - VertexBuffer.MatricesIndicesExtraKind
  75871. * - VertexBuffer.MatricesWeightsKind
  75872. * - VertexBuffer.MatricesWeightsExtraKind
  75873. * @returns an array of strings
  75874. */
  75875. getVerticesDataKinds(): string[];
  75876. /**
  75877. * Returns a positive integer : the total number of indices in this mesh geometry.
  75878. * @returns the numner of indices or zero if the mesh has no geometry.
  75879. */
  75880. getTotalIndices(): number;
  75881. /**
  75882. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75883. * @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.
  75884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75885. * @returns the indices array or an empty array if the mesh has no geometry
  75886. */
  75887. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75888. readonly isBlocked: boolean;
  75889. /**
  75890. * Determine if the current mesh is ready to be rendered
  75891. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75892. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75893. * @returns true if all associated assets are ready (material, textures, shaders)
  75894. */
  75895. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75896. /**
  75897. * 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.
  75898. */
  75899. readonly areNormalsFrozen: boolean;
  75900. /**
  75901. * 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.
  75902. * @returns the current mesh
  75903. */
  75904. freezeNormals(): Mesh;
  75905. /**
  75906. * 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
  75907. * @returns the current mesh
  75908. */
  75909. unfreezeNormals(): Mesh;
  75910. /**
  75911. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75912. */
  75913. overridenInstanceCount: number;
  75914. /** @hidden */
  75915. _preActivate(): Mesh;
  75916. /** @hidden */
  75917. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75918. /** @hidden */
  75919. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75920. /**
  75921. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75922. * This means the mesh underlying bounding box and sphere are recomputed.
  75923. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75924. * @returns the current mesh
  75925. */
  75926. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75927. /** @hidden */
  75928. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75929. /**
  75930. * This function will subdivide the mesh into multiple submeshes
  75931. * @param count defines the expected number of submeshes
  75932. */
  75933. subdivide(count: number): void;
  75934. /**
  75935. * Copy a FloatArray into a specific associated vertex buffer
  75936. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75937. * - VertexBuffer.PositionKind
  75938. * - VertexBuffer.UVKind
  75939. * - VertexBuffer.UV2Kind
  75940. * - VertexBuffer.UV3Kind
  75941. * - VertexBuffer.UV4Kind
  75942. * - VertexBuffer.UV5Kind
  75943. * - VertexBuffer.UV6Kind
  75944. * - VertexBuffer.ColorKind
  75945. * - VertexBuffer.MatricesIndicesKind
  75946. * - VertexBuffer.MatricesIndicesExtraKind
  75947. * - VertexBuffer.MatricesWeightsKind
  75948. * - VertexBuffer.MatricesWeightsExtraKind
  75949. * @param data defines the data source
  75950. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75951. * @param stride defines the data stride size (can be null)
  75952. * @returns the current mesh
  75953. */
  75954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75955. /**
  75956. * Flags an associated vertex buffer as updatable
  75957. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75958. * - VertexBuffer.PositionKind
  75959. * - VertexBuffer.UVKind
  75960. * - VertexBuffer.UV2Kind
  75961. * - VertexBuffer.UV3Kind
  75962. * - VertexBuffer.UV4Kind
  75963. * - VertexBuffer.UV5Kind
  75964. * - VertexBuffer.UV6Kind
  75965. * - VertexBuffer.ColorKind
  75966. * - VertexBuffer.MatricesIndicesKind
  75967. * - VertexBuffer.MatricesIndicesExtraKind
  75968. * - VertexBuffer.MatricesWeightsKind
  75969. * - VertexBuffer.MatricesWeightsExtraKind
  75970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75971. */
  75972. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  75973. /**
  75974. * Sets the mesh global Vertex Buffer
  75975. * @param buffer defines the buffer to use
  75976. * @returns the current mesh
  75977. */
  75978. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  75979. /**
  75980. * Update a specific associated vertex buffer
  75981. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75982. * - VertexBuffer.PositionKind
  75983. * - VertexBuffer.UVKind
  75984. * - VertexBuffer.UV2Kind
  75985. * - VertexBuffer.UV3Kind
  75986. * - VertexBuffer.UV4Kind
  75987. * - VertexBuffer.UV5Kind
  75988. * - VertexBuffer.UV6Kind
  75989. * - VertexBuffer.ColorKind
  75990. * - VertexBuffer.MatricesIndicesKind
  75991. * - VertexBuffer.MatricesIndicesExtraKind
  75992. * - VertexBuffer.MatricesWeightsKind
  75993. * - VertexBuffer.MatricesWeightsExtraKind
  75994. * @param data defines the data source
  75995. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  75996. * @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)
  75997. * @returns the current mesh
  75998. */
  75999. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76000. /**
  76001. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76002. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76003. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76004. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76005. * @returns the current mesh
  76006. */
  76007. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76008. /**
  76009. * Creates a un-shared specific occurence of the geometry for the mesh.
  76010. * @returns the current mesh
  76011. */
  76012. makeGeometryUnique(): Mesh;
  76013. /**
  76014. * Set the index buffer of this mesh
  76015. * @param indices defines the source data
  76016. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76017. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76018. * @returns the current mesh
  76019. */
  76020. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76021. /**
  76022. * Update the current index buffer
  76023. * @param indices defines the source data
  76024. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76025. * @returns the current mesh
  76026. */
  76027. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  76028. /**
  76029. * Invert the geometry to move from a right handed system to a left handed one.
  76030. * @returns the current mesh
  76031. */
  76032. toLeftHanded(): Mesh;
  76033. /** @hidden */
  76034. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76035. /** @hidden */
  76036. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  76037. /**
  76038. * Registers for this mesh a javascript function called just before the rendering process
  76039. * @param func defines the function to call before rendering this mesh
  76040. * @returns the current mesh
  76041. */
  76042. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76043. /**
  76044. * Disposes a previously registered javascript function called before the rendering
  76045. * @param func defines the function to remove
  76046. * @returns the current mesh
  76047. */
  76048. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76049. /**
  76050. * Registers for this mesh a javascript function called just after the rendering is complete
  76051. * @param func defines the function to call after rendering this mesh
  76052. * @returns the current mesh
  76053. */
  76054. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76055. /**
  76056. * Disposes a previously registered javascript function called after the rendering.
  76057. * @param func defines the function to remove
  76058. * @returns the current mesh
  76059. */
  76060. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76061. /** @hidden */
  76062. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76063. /** @hidden */
  76064. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76065. /** @hidden */
  76066. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76067. /**
  76068. * 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
  76069. * @param subMesh defines the subMesh to render
  76070. * @param enableAlphaMode defines if alpha mode can be changed
  76071. * @returns the current mesh
  76072. */
  76073. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  76074. private _onBeforeDraw;
  76075. /**
  76076. * Renormalize the mesh and patch it up if there are no weights
  76077. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  76078. * However in the case of zero weights then we set just a single influence to 1.
  76079. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  76080. */
  76081. cleanMatrixWeights(): void;
  76082. private normalizeSkinFourWeights;
  76083. private normalizeSkinWeightsAndExtra;
  76084. /**
  76085. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  76086. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  76087. * the user know there was an issue with importing the mesh
  76088. * @returns a validation object with skinned, valid and report string
  76089. */
  76090. validateSkinning(): {
  76091. skinned: boolean;
  76092. valid: boolean;
  76093. report: string;
  76094. };
  76095. /** @hidden */
  76096. _checkDelayState(): Mesh;
  76097. private _queueLoad;
  76098. /**
  76099. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76100. * A mesh is in the frustum if its bounding box intersects the frustum
  76101. * @param frustumPlanes defines the frustum to test
  76102. * @returns true if the mesh is in the frustum planes
  76103. */
  76104. isInFrustum(frustumPlanes: Plane[]): boolean;
  76105. /**
  76106. * Sets the mesh material by the material or multiMaterial `id` property
  76107. * @param id is a string identifying the material or the multiMaterial
  76108. * @returns the current mesh
  76109. */
  76110. setMaterialByID(id: string): Mesh;
  76111. /**
  76112. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  76113. * @returns an array of IAnimatable
  76114. */
  76115. getAnimatables(): IAnimatable[];
  76116. /**
  76117. * Modifies the mesh geometry according to the passed transformation matrix.
  76118. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  76119. * The mesh normals are modified using the same transformation.
  76120. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76121. * @param transform defines the transform matrix to use
  76122. * @see http://doc.babylonjs.com/resources/baking_transformations
  76123. * @returns the current mesh
  76124. */
  76125. bakeTransformIntoVertices(transform: Matrix): Mesh;
  76126. /**
  76127. * Modifies the mesh geometry according to its own current World Matrix.
  76128. * The mesh World Matrix is then reset.
  76129. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  76130. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76131. * @see http://doc.babylonjs.com/resources/baking_transformations
  76132. * @returns the current mesh
  76133. */
  76134. bakeCurrentTransformIntoVertices(): Mesh;
  76135. /** @hidden */
  76136. readonly _positions: Nullable<Vector3[]>;
  76137. /** @hidden */
  76138. _resetPointsArrayCache(): Mesh;
  76139. /** @hidden */
  76140. _generatePointsArray(): boolean;
  76141. /**
  76142. * Returns a new Mesh object generated from the current mesh properties.
  76143. * This method must not get confused with createInstance()
  76144. * @param name is a string, the name given to the new mesh
  76145. * @param newParent can be any Node object (default `null`)
  76146. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  76147. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  76148. * @returns a new mesh
  76149. */
  76150. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  76151. /**
  76152. * Releases resources associated with this mesh.
  76153. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76154. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76155. */
  76156. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76157. /**
  76158. * Modifies the mesh geometry according to a displacement map.
  76159. * 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.
  76160. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76161. * @param url is a string, the URL from the image file is to be downloaded.
  76162. * @param minHeight is the lower limit of the displacement.
  76163. * @param maxHeight is the upper limit of the displacement.
  76164. * @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.
  76165. * @param uvOffset is an optional vector2 used to offset UV.
  76166. * @param uvScale is an optional vector2 used to scale UV.
  76167. * @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.
  76168. * @returns the Mesh.
  76169. */
  76170. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76171. /**
  76172. * Modifies the mesh geometry according to a displacementMap buffer.
  76173. * 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.
  76174. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76175. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  76176. * @param heightMapWidth is the width of the buffer image.
  76177. * @param heightMapHeight is the height of the buffer image.
  76178. * @param minHeight is the lower limit of the displacement.
  76179. * @param maxHeight is the upper limit of the displacement.
  76180. * @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.
  76181. * @param uvOffset is an optional vector2 used to offset UV.
  76182. * @param uvScale is an optional vector2 used to scale UV.
  76183. * @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.
  76184. * @returns the Mesh.
  76185. */
  76186. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76187. /**
  76188. * Modify the mesh to get a flat shading rendering.
  76189. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  76190. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  76191. * @returns current mesh
  76192. */
  76193. convertToFlatShadedMesh(): Mesh;
  76194. /**
  76195. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  76196. * In other words, more vertices, no more indices and a single bigger VBO.
  76197. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  76198. * @returns current mesh
  76199. */
  76200. convertToUnIndexedMesh(): Mesh;
  76201. /**
  76202. * Inverses facet orientations.
  76203. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  76204. * @param flipNormals will also inverts the normals
  76205. * @returns current mesh
  76206. */
  76207. flipFaces(flipNormals?: boolean): Mesh;
  76208. /** @hidden */
  76209. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  76210. /** @hidden */
  76211. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  76212. /**
  76213. * Creates a new InstancedMesh object from the mesh model.
  76214. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76215. * @param name defines the name of the new instance
  76216. * @returns a new InstancedMesh
  76217. */
  76218. createInstance(name: string): InstancedMesh;
  76219. /**
  76220. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  76221. * After this call, all the mesh instances have the same submeshes than the current mesh.
  76222. * @returns the current mesh
  76223. */
  76224. synchronizeInstances(): Mesh;
  76225. /**
  76226. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  76227. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  76228. * This should be used together with the simplification to avoid disappearing triangles.
  76229. * @param successCallback an optional success callback to be called after the optimization finished.
  76230. * @returns the current mesh
  76231. */
  76232. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  76233. /**
  76234. * Serialize current mesh
  76235. * @param serializationObject defines the object which will receive the serialization data
  76236. */
  76237. serialize(serializationObject: any): void;
  76238. /** @hidden */
  76239. _syncGeometryWithMorphTargetManager(): void;
  76240. /** @hidden */
  76241. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  76242. /**
  76243. * Returns a new Mesh object parsed from the source provided.
  76244. * @param parsedMesh is the source
  76245. * @param scene defines the hosting scene
  76246. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  76247. * @returns a new Mesh
  76248. */
  76249. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  76250. /**
  76251. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  76252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76253. * @param name defines the name of the mesh to create
  76254. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  76255. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  76256. * @param closePath creates a seam between the first and the last points of each path of the path array
  76257. * @param offset is taken in account only if the `pathArray` is containing a single path
  76258. * @param scene defines the hosting scene
  76259. * @param updatable defines if the mesh must be flagged as updatable
  76260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76261. * @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)
  76262. * @returns a new Mesh
  76263. */
  76264. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76265. /**
  76266. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  76267. * @param name defines the name of the mesh to create
  76268. * @param radius sets the radius size (float) of the polygon (default 0.5)
  76269. * @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
  76270. * @param scene defines the hosting scene
  76271. * @param updatable defines if the mesh must be flagged as updatable
  76272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76273. * @returns a new Mesh
  76274. */
  76275. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76276. /**
  76277. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  76278. * @param name defines the name of the mesh to create
  76279. * @param size sets the size (float) of each box side (default 1)
  76280. * @param scene defines the hosting scene
  76281. * @param updatable defines if the mesh must be flagged as updatable
  76282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76283. * @returns a new Mesh
  76284. */
  76285. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76286. /**
  76287. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  76288. * @param name defines the name of the mesh to create
  76289. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  76290. * @param diameter sets the diameter size (float) of the sphere (default 1)
  76291. * @param scene defines the hosting scene
  76292. * @param updatable defines if the mesh must be flagged as updatable
  76293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76294. * @returns a new Mesh
  76295. */
  76296. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76297. /**
  76298. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  76299. * @param name defines the name of the mesh to create
  76300. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  76301. * @param diameterTop set the top cap diameter (floats, default 1)
  76302. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  76303. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  76304. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  76305. * @param scene defines the hosting scene
  76306. * @param updatable defines if the mesh must be flagged as updatable
  76307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76308. * @returns a new Mesh
  76309. */
  76310. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  76311. /**
  76312. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  76313. * @param name defines the name of the mesh to create
  76314. * @param diameter sets the diameter size (float) of the torus (default 1)
  76315. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  76316. * @param tessellation sets the number of torus sides (postive integer, default 16)
  76317. * @param scene defines the hosting scene
  76318. * @param updatable defines if the mesh must be flagged as updatable
  76319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76320. * @returns a new Mesh
  76321. */
  76322. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76323. /**
  76324. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  76325. * @param name defines the name of the mesh to create
  76326. * @param radius sets the global radius size (float) of the torus knot (default 2)
  76327. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  76328. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  76329. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  76330. * @param p the number of windings on X axis (positive integers, default 2)
  76331. * @param q the number of windings on Y axis (positive integers, default 3)
  76332. * @param scene defines the hosting scene
  76333. * @param updatable defines if the mesh must be flagged as updatable
  76334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76335. * @returns a new Mesh
  76336. */
  76337. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76338. /**
  76339. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  76340. * @param name defines the name of the mesh to create
  76341. * @param points is an array successive Vector3
  76342. * @param scene defines the hosting scene
  76343. * @param updatable defines if the mesh must be flagged as updatable
  76344. * @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).
  76345. * @returns a new Mesh
  76346. */
  76347. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  76348. /**
  76349. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  76350. * @param name defines the name of the mesh to create
  76351. * @param points is an array successive Vector3
  76352. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  76353. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76354. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  76355. * @param scene defines the hosting scene
  76356. * @param updatable defines if the mesh must be flagged as updatable
  76357. * @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)
  76358. * @returns a new Mesh
  76359. */
  76360. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  76361. /**
  76362. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  76363. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  76364. * 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.
  76365. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76366. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76367. * Remember you can only change the shape positions, not their number when updating a polygon.
  76368. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  76369. * @param name defines the name of the mesh to create
  76370. * @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
  76371. * @param scene defines the hosting scene
  76372. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76373. * @param updatable defines if the mesh must be flagged as updatable
  76374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76375. * @param earcutInjection can be used to inject your own earcut reference
  76376. * @returns a new Mesh
  76377. */
  76378. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76379. /**
  76380. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  76381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  76382. * @param name defines the name of the mesh to create
  76383. * @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
  76384. * @param depth defines the height of extrusion
  76385. * @param scene defines the hosting scene
  76386. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76387. * @param updatable defines if the mesh must be flagged as updatable
  76388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76389. * @param earcutInjection can be used to inject your own earcut reference
  76390. * @returns a new Mesh
  76391. */
  76392. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76393. /**
  76394. * Creates an extruded shape mesh.
  76395. * 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
  76396. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76398. * @param name defines the name of the mesh to create
  76399. * @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
  76400. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76401. * @param scale is the value to scale the shape
  76402. * @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
  76403. * @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
  76404. * @param scene defines the hosting scene
  76405. * @param updatable defines if the mesh must be flagged as updatable
  76406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76407. * @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)
  76408. * @returns a new Mesh
  76409. */
  76410. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76411. /**
  76412. * Creates an custom extruded shape mesh.
  76413. * The custom extrusion is a parametric shape.
  76414. * It has no predefined shape. Its final shape will depend on the input parameters.
  76415. * Please consider using the same method from the MeshBuilder class instead
  76416. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76417. * @param name defines the name of the mesh to create
  76418. * @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
  76419. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76420. * @param scaleFunction is a custom Javascript function called on each path point
  76421. * @param rotationFunction is a custom Javascript function called on each path point
  76422. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  76423. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  76424. * @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
  76425. * @param scene defines the hosting scene
  76426. * @param updatable defines if the mesh must be flagged as updatable
  76427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76428. * @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)
  76429. * @returns a new Mesh
  76430. */
  76431. 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;
  76432. /**
  76433. * Creates lathe mesh.
  76434. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  76435. * Please consider using the same method from the MeshBuilder class instead
  76436. * @param name defines the name of the mesh to create
  76437. * @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
  76438. * @param radius is the radius value of the lathe
  76439. * @param tessellation is the side number of the lathe.
  76440. * @param scene defines the hosting scene
  76441. * @param updatable defines if the mesh must be flagged as updatable
  76442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76443. * @returns a new Mesh
  76444. */
  76445. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76446. /**
  76447. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  76448. * @param name defines the name of the mesh to create
  76449. * @param size sets the size (float) of both sides of the plane at once (default 1)
  76450. * @param scene defines the hosting scene
  76451. * @param updatable defines if the mesh must be flagged as updatable
  76452. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76453. * @returns a new Mesh
  76454. */
  76455. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76456. /**
  76457. * Creates a ground mesh.
  76458. * Please consider using the same method from the MeshBuilder class instead
  76459. * @param name defines the name of the mesh to create
  76460. * @param width set the width of the ground
  76461. * @param height set the height of the ground
  76462. * @param subdivisions sets the number of subdivisions per side
  76463. * @param scene defines the hosting scene
  76464. * @param updatable defines if the mesh must be flagged as updatable
  76465. * @returns a new Mesh
  76466. */
  76467. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  76468. /**
  76469. * Creates a tiled ground mesh.
  76470. * Please consider using the same method from the MeshBuilder class instead
  76471. * @param name defines the name of the mesh to create
  76472. * @param xmin set the ground minimum X coordinate
  76473. * @param zmin set the ground minimum Y coordinate
  76474. * @param xmax set the ground maximum X coordinate
  76475. * @param zmax set the ground maximum Z coordinate
  76476. * @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
  76477. * @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
  76478. * @param scene defines the hosting scene
  76479. * @param updatable defines if the mesh must be flagged as updatable
  76480. * @returns a new Mesh
  76481. */
  76482. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  76483. w: number;
  76484. h: number;
  76485. }, precision: {
  76486. w: number;
  76487. h: number;
  76488. }, scene: Scene, updatable?: boolean): Mesh;
  76489. /**
  76490. * Creates a ground mesh from a height map.
  76491. * Please consider using the same method from the MeshBuilder class instead
  76492. * @see http://doc.babylonjs.com/babylon101/height_map
  76493. * @param name defines the name of the mesh to create
  76494. * @param url sets the URL of the height map image resource
  76495. * @param width set the ground width size
  76496. * @param height set the ground height size
  76497. * @param subdivisions sets the number of subdivision per side
  76498. * @param minHeight is the minimum altitude on the ground
  76499. * @param maxHeight is the maximum altitude on the ground
  76500. * @param scene defines the hosting scene
  76501. * @param updatable defines if the mesh must be flagged as updatable
  76502. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  76503. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76504. * @returns a new Mesh
  76505. */
  76506. 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;
  76507. /**
  76508. * Creates a tube mesh.
  76509. * The tube is a parametric shape.
  76510. * It has no predefined shape. Its final shape will depend on the input parameters.
  76511. * Please consider using the same method from the MeshBuilder class instead
  76512. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76513. * @param name defines the name of the mesh to create
  76514. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  76515. * @param radius sets the tube radius size
  76516. * @param tessellation is the number of sides on the tubular surface
  76517. * @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
  76518. * @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
  76519. * @param scene defines the hosting scene
  76520. * @param updatable defines if the mesh must be flagged as updatable
  76521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76522. * @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)
  76523. * @returns a new Mesh
  76524. */
  76525. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  76526. (i: number, distance: number): number;
  76527. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76528. /**
  76529. * Creates a polyhedron mesh.
  76530. * Please consider using the same method from the MeshBuilder class instead.
  76531. * * 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
  76532. * * The parameter `size` (positive float, default 1) sets the polygon size
  76533. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76534. * * 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`
  76535. * * 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
  76536. * * 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)`)
  76537. * * 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
  76538. * * 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
  76539. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76540. * * If you create a double-sided mesh, you can choose what parts of 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
  76541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76542. * @param name defines the name of the mesh to create
  76543. * @param options defines the options used to create the mesh
  76544. * @param scene defines the hosting scene
  76545. * @returns a new Mesh
  76546. */
  76547. static CreatePolyhedron(name: string, options: {
  76548. type?: number;
  76549. size?: number;
  76550. sizeX?: number;
  76551. sizeY?: number;
  76552. sizeZ?: number;
  76553. custom?: any;
  76554. faceUV?: Vector4[];
  76555. faceColors?: Color4[];
  76556. updatable?: boolean;
  76557. sideOrientation?: number;
  76558. }, scene: Scene): Mesh;
  76559. /**
  76560. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76561. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76562. * * 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`)
  76563. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76564. * * 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
  76565. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76566. * * If you create a double-sided mesh, you can choose what parts of 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
  76567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76568. * @param name defines the name of the mesh
  76569. * @param options defines the options used to create the mesh
  76570. * @param scene defines the hosting scene
  76571. * @returns a new Mesh
  76572. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76573. */
  76574. static CreateIcoSphere(name: string, options: {
  76575. radius?: number;
  76576. flat?: boolean;
  76577. subdivisions?: number;
  76578. sideOrientation?: number;
  76579. updatable?: boolean;
  76580. }, scene: Scene): Mesh;
  76581. /**
  76582. * Creates a decal mesh.
  76583. * Please consider using the same method from the MeshBuilder class instead.
  76584. * A decal is a mesh usually applied as a model onto the surface of another mesh
  76585. * @param name defines the name of the mesh
  76586. * @param sourceMesh defines the mesh receiving the decal
  76587. * @param position sets the position of the decal in world coordinates
  76588. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  76589. * @param size sets the decal scaling
  76590. * @param angle sets the angle to rotate the decal
  76591. * @returns a new Mesh
  76592. */
  76593. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  76594. /**
  76595. * Prepare internal position array for software CPU skinning
  76596. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  76597. */
  76598. setPositionsForCPUSkinning(): Float32Array;
  76599. /**
  76600. * Prepare internal normal array for software CPU skinning
  76601. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  76602. */
  76603. setNormalsForCPUSkinning(): Float32Array;
  76604. /**
  76605. * Updates the vertex buffer by applying transformation from the bones
  76606. * @param skeleton defines the skeleton to apply to current mesh
  76607. * @returns the current mesh
  76608. */
  76609. applySkeleton(skeleton: Skeleton): Mesh;
  76610. /**
  76611. * 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
  76612. * @param meshes defines the list of meshes to scan
  76613. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  76614. */
  76615. static MinMax(meshes: AbstractMesh[]): {
  76616. min: Vector3;
  76617. max: Vector3;
  76618. };
  76619. /**
  76620. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  76621. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  76622. * @returns a vector3
  76623. */
  76624. static Center(meshesOrMinMaxVector: {
  76625. min: Vector3;
  76626. max: Vector3;
  76627. } | AbstractMesh[]): Vector3;
  76628. /**
  76629. * Merge the array of meshes into a single mesh for performance reasons.
  76630. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  76631. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  76632. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  76633. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  76634. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  76635. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  76636. * @returns a new mesh
  76637. */
  76638. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  76639. /** @hidden */
  76640. addInstance(instance: InstancedMesh): void;
  76641. /** @hidden */
  76642. removeInstance(instance: InstancedMesh): void;
  76643. }
  76644. }
  76645. declare module BABYLON {
  76646. /**
  76647. * Base class for the main features of a material in Babylon.js
  76648. */
  76649. export class Material implements IAnimatable {
  76650. /**
  76651. * Returns the triangle fill mode
  76652. */
  76653. static readonly TriangleFillMode: number;
  76654. /**
  76655. * Returns the wireframe mode
  76656. */
  76657. static readonly WireFrameFillMode: number;
  76658. /**
  76659. * Returns the point fill mode
  76660. */
  76661. static readonly PointFillMode: number;
  76662. /**
  76663. * Returns the point list draw mode
  76664. */
  76665. static readonly PointListDrawMode: number;
  76666. /**
  76667. * Returns the line list draw mode
  76668. */
  76669. static readonly LineListDrawMode: number;
  76670. /**
  76671. * Returns the line loop draw mode
  76672. */
  76673. static readonly LineLoopDrawMode: number;
  76674. /**
  76675. * Returns the line strip draw mode
  76676. */
  76677. static readonly LineStripDrawMode: number;
  76678. /**
  76679. * Returns the triangle strip draw mode
  76680. */
  76681. static readonly TriangleStripDrawMode: number;
  76682. /**
  76683. * Returns the triangle fan draw mode
  76684. */
  76685. static readonly TriangleFanDrawMode: number;
  76686. /**
  76687. * Stores the clock-wise side orientation
  76688. */
  76689. static readonly ClockWiseSideOrientation: number;
  76690. /**
  76691. * Stores the counter clock-wise side orientation
  76692. */
  76693. static readonly CounterClockWiseSideOrientation: number;
  76694. /**
  76695. * The dirty texture flag value
  76696. */
  76697. static readonly TextureDirtyFlag: number;
  76698. /**
  76699. * The dirty light flag value
  76700. */
  76701. static readonly LightDirtyFlag: number;
  76702. /**
  76703. * The dirty fresnel flag value
  76704. */
  76705. static readonly FresnelDirtyFlag: number;
  76706. /**
  76707. * The dirty attribute flag value
  76708. */
  76709. static readonly AttributesDirtyFlag: number;
  76710. /**
  76711. * The dirty misc flag value
  76712. */
  76713. static readonly MiscDirtyFlag: number;
  76714. /**
  76715. * The all dirty flag value
  76716. */
  76717. static readonly AllDirtyFlag: number;
  76718. /**
  76719. * The ID of the material
  76720. */
  76721. id: string;
  76722. /**
  76723. * Gets or sets the unique id of the material
  76724. */
  76725. uniqueId: number;
  76726. /**
  76727. * The name of the material
  76728. */
  76729. name: string;
  76730. /**
  76731. * Gets or sets user defined metadata
  76732. */
  76733. metadata: any;
  76734. /**
  76735. * For internal use only. Please do not use.
  76736. */
  76737. reservedDataStore: any;
  76738. /**
  76739. * Specifies if the ready state should be checked on each call
  76740. */
  76741. checkReadyOnEveryCall: boolean;
  76742. /**
  76743. * Specifies if the ready state should be checked once
  76744. */
  76745. checkReadyOnlyOnce: boolean;
  76746. /**
  76747. * The state of the material
  76748. */
  76749. state: string;
  76750. /**
  76751. * The alpha value of the material
  76752. */
  76753. protected _alpha: number;
  76754. /**
  76755. * Sets the alpha value of the material
  76756. */
  76757. /**
  76758. * Gets the alpha value of the material
  76759. */
  76760. alpha: number;
  76761. /**
  76762. * Specifies if back face culling is enabled
  76763. */
  76764. protected _backFaceCulling: boolean;
  76765. /**
  76766. * Sets the back-face culling state
  76767. */
  76768. /**
  76769. * Gets the back-face culling state
  76770. */
  76771. backFaceCulling: boolean;
  76772. /**
  76773. * Stores the value for side orientation
  76774. */
  76775. sideOrientation: number;
  76776. /**
  76777. * Callback triggered when the material is compiled
  76778. */
  76779. onCompiled: (effect: Effect) => void;
  76780. /**
  76781. * Callback triggered when an error occurs
  76782. */
  76783. onError: (effect: Effect, errors: string) => void;
  76784. /**
  76785. * Callback triggered to get the render target textures
  76786. */
  76787. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  76788. /**
  76789. * Gets a boolean indicating that current material needs to register RTT
  76790. */
  76791. readonly hasRenderTargetTextures: boolean;
  76792. /**
  76793. * Specifies if the material should be serialized
  76794. */
  76795. doNotSerialize: boolean;
  76796. /**
  76797. * @hidden
  76798. */
  76799. _storeEffectOnSubMeshes: boolean;
  76800. /**
  76801. * Stores the animations for the material
  76802. */
  76803. animations: Array<Animation>;
  76804. /**
  76805. * An event triggered when the material is disposed
  76806. */
  76807. onDisposeObservable: Observable<Material>;
  76808. /**
  76809. * An observer which watches for dispose events
  76810. */
  76811. private _onDisposeObserver;
  76812. private _onUnBindObservable;
  76813. /**
  76814. * Called during a dispose event
  76815. */
  76816. onDispose: () => void;
  76817. private _onBindObservable;
  76818. /**
  76819. * An event triggered when the material is bound
  76820. */
  76821. readonly onBindObservable: Observable<AbstractMesh>;
  76822. /**
  76823. * An observer which watches for bind events
  76824. */
  76825. private _onBindObserver;
  76826. /**
  76827. * Called during a bind event
  76828. */
  76829. onBind: (Mesh: AbstractMesh) => void;
  76830. /**
  76831. * An event triggered when the material is unbound
  76832. */
  76833. readonly onUnBindObservable: Observable<Material>;
  76834. /**
  76835. * Stores the value of the alpha mode
  76836. */
  76837. private _alphaMode;
  76838. /**
  76839. * Sets the value of the alpha mode.
  76840. *
  76841. * | Value | Type | Description |
  76842. * | --- | --- | --- |
  76843. * | 0 | ALPHA_DISABLE | |
  76844. * | 1 | ALPHA_ADD | |
  76845. * | 2 | ALPHA_COMBINE | |
  76846. * | 3 | ALPHA_SUBTRACT | |
  76847. * | 4 | ALPHA_MULTIPLY | |
  76848. * | 5 | ALPHA_MAXIMIZED | |
  76849. * | 6 | ALPHA_ONEONE | |
  76850. * | 7 | ALPHA_PREMULTIPLIED | |
  76851. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  76852. * | 9 | ALPHA_INTERPOLATE | |
  76853. * | 10 | ALPHA_SCREENMODE | |
  76854. *
  76855. */
  76856. /**
  76857. * Gets the value of the alpha mode
  76858. */
  76859. alphaMode: number;
  76860. /**
  76861. * Stores the state of the need depth pre-pass value
  76862. */
  76863. private _needDepthPrePass;
  76864. /**
  76865. * Sets the need depth pre-pass value
  76866. */
  76867. /**
  76868. * Gets the depth pre-pass value
  76869. */
  76870. needDepthPrePass: boolean;
  76871. /**
  76872. * Specifies if depth writing should be disabled
  76873. */
  76874. disableDepthWrite: boolean;
  76875. /**
  76876. * Specifies if depth writing should be forced
  76877. */
  76878. forceDepthWrite: boolean;
  76879. /**
  76880. * Specifies if there should be a separate pass for culling
  76881. */
  76882. separateCullingPass: boolean;
  76883. /**
  76884. * Stores the state specifing if fog should be enabled
  76885. */
  76886. private _fogEnabled;
  76887. /**
  76888. * Sets the state for enabling fog
  76889. */
  76890. /**
  76891. * Gets the value of the fog enabled state
  76892. */
  76893. fogEnabled: boolean;
  76894. /**
  76895. * Stores the size of points
  76896. */
  76897. pointSize: number;
  76898. /**
  76899. * Stores the z offset value
  76900. */
  76901. zOffset: number;
  76902. /**
  76903. * Gets a value specifying if wireframe mode is enabled
  76904. */
  76905. /**
  76906. * Sets the state of wireframe mode
  76907. */
  76908. wireframe: boolean;
  76909. /**
  76910. * Gets the value specifying if point clouds are enabled
  76911. */
  76912. /**
  76913. * Sets the state of point cloud mode
  76914. */
  76915. pointsCloud: boolean;
  76916. /**
  76917. * Gets the material fill mode
  76918. */
  76919. /**
  76920. * Sets the material fill mode
  76921. */
  76922. fillMode: number;
  76923. /**
  76924. * @hidden
  76925. * Stores the effects for the material
  76926. */
  76927. _effect: Nullable<Effect>;
  76928. /**
  76929. * @hidden
  76930. * Specifies if the material was previously ready
  76931. */
  76932. _wasPreviouslyReady: boolean;
  76933. /**
  76934. * Specifies if uniform buffers should be used
  76935. */
  76936. private _useUBO;
  76937. /**
  76938. * Stores a reference to the scene
  76939. */
  76940. private _scene;
  76941. /**
  76942. * Stores the fill mode state
  76943. */
  76944. private _fillMode;
  76945. /**
  76946. * Specifies if the depth write state should be cached
  76947. */
  76948. private _cachedDepthWriteState;
  76949. /**
  76950. * Stores the uniform buffer
  76951. */
  76952. protected _uniformBuffer: UniformBuffer;
  76953. /** @hidden */
  76954. _indexInSceneMaterialArray: number;
  76955. /** @hidden */
  76956. meshMap: Nullable<{
  76957. [id: string]: AbstractMesh | undefined;
  76958. }>;
  76959. /**
  76960. * Creates a material instance
  76961. * @param name defines the name of the material
  76962. * @param scene defines the scene to reference
  76963. * @param doNotAdd specifies if the material should be added to the scene
  76964. */
  76965. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  76966. /**
  76967. * Returns a string representation of the current material
  76968. * @param fullDetails defines a boolean indicating which levels of logging is desired
  76969. * @returns a string with material information
  76970. */
  76971. toString(fullDetails?: boolean): string;
  76972. /**
  76973. * Gets the class name of the material
  76974. * @returns a string with the class name of the material
  76975. */
  76976. getClassName(): string;
  76977. /**
  76978. * Specifies if updates for the material been locked
  76979. */
  76980. readonly isFrozen: boolean;
  76981. /**
  76982. * Locks updates for the material
  76983. */
  76984. freeze(): void;
  76985. /**
  76986. * Unlocks updates for the material
  76987. */
  76988. unfreeze(): void;
  76989. /**
  76990. * Specifies if the material is ready to be used
  76991. * @param mesh defines the mesh to check
  76992. * @param useInstances specifies if instances should be used
  76993. * @returns a boolean indicating if the material is ready to be used
  76994. */
  76995. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76996. /**
  76997. * Specifies that the submesh is ready to be used
  76998. * @param mesh defines the mesh to check
  76999. * @param subMesh defines which submesh to check
  77000. * @param useInstances specifies that instances should be used
  77001. * @returns a boolean indicating that the submesh is ready or not
  77002. */
  77003. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77004. /**
  77005. * Returns the material effect
  77006. * @returns the effect associated with the material
  77007. */
  77008. getEffect(): Nullable<Effect>;
  77009. /**
  77010. * Returns the current scene
  77011. * @returns a Scene
  77012. */
  77013. getScene(): Scene;
  77014. /**
  77015. * Specifies if the material will require alpha blending
  77016. * @returns a boolean specifying if alpha blending is needed
  77017. */
  77018. needAlphaBlending(): boolean;
  77019. /**
  77020. * Specifies if the mesh will require alpha blending
  77021. * @param mesh defines the mesh to check
  77022. * @returns a boolean specifying if alpha blending is needed for the mesh
  77023. */
  77024. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  77025. /**
  77026. * Specifies if this material should be rendered in alpha test mode
  77027. * @returns a boolean specifying if an alpha test is needed.
  77028. */
  77029. needAlphaTesting(): boolean;
  77030. /**
  77031. * Gets the texture used for the alpha test
  77032. * @returns the texture to use for alpha testing
  77033. */
  77034. getAlphaTestTexture(): Nullable<BaseTexture>;
  77035. /**
  77036. * Marks the material to indicate that it needs to be re-calculated
  77037. */
  77038. markDirty(): void;
  77039. /** @hidden */
  77040. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  77041. /**
  77042. * Binds the material to the mesh
  77043. * @param world defines the world transformation matrix
  77044. * @param mesh defines the mesh to bind the material to
  77045. */
  77046. bind(world: Matrix, mesh?: Mesh): void;
  77047. /**
  77048. * Binds the submesh to the material
  77049. * @param world defines the world transformation matrix
  77050. * @param mesh defines the mesh containing the submesh
  77051. * @param subMesh defines the submesh to bind the material to
  77052. */
  77053. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  77054. /**
  77055. * Binds the world matrix to the material
  77056. * @param world defines the world transformation matrix
  77057. */
  77058. bindOnlyWorldMatrix(world: Matrix): void;
  77059. /**
  77060. * Binds the scene's uniform buffer to the effect.
  77061. * @param effect defines the effect to bind to the scene uniform buffer
  77062. * @param sceneUbo defines the uniform buffer storing scene data
  77063. */
  77064. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  77065. /**
  77066. * Binds the view matrix to the effect
  77067. * @param effect defines the effect to bind the view matrix to
  77068. */
  77069. bindView(effect: Effect): void;
  77070. /**
  77071. * Binds the view projection matrix to the effect
  77072. * @param effect defines the effect to bind the view projection matrix to
  77073. */
  77074. bindViewProjection(effect: Effect): void;
  77075. /**
  77076. * Specifies if material alpha testing should be turned on for the mesh
  77077. * @param mesh defines the mesh to check
  77078. */
  77079. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  77080. /**
  77081. * Processes to execute after binding the material to a mesh
  77082. * @param mesh defines the rendered mesh
  77083. */
  77084. protected _afterBind(mesh?: Mesh): void;
  77085. /**
  77086. * Unbinds the material from the mesh
  77087. */
  77088. unbind(): void;
  77089. /**
  77090. * Gets the active textures from the material
  77091. * @returns an array of textures
  77092. */
  77093. getActiveTextures(): BaseTexture[];
  77094. /**
  77095. * Specifies if the material uses a texture
  77096. * @param texture defines the texture to check against the material
  77097. * @returns a boolean specifying if the material uses the texture
  77098. */
  77099. hasTexture(texture: BaseTexture): boolean;
  77100. /**
  77101. * Makes a duplicate of the material, and gives it a new name
  77102. * @param name defines the new name for the duplicated material
  77103. * @returns the cloned material
  77104. */
  77105. clone(name: string): Nullable<Material>;
  77106. /**
  77107. * Gets the meshes bound to the material
  77108. * @returns an array of meshes bound to the material
  77109. */
  77110. getBindedMeshes(): AbstractMesh[];
  77111. /**
  77112. * Force shader compilation
  77113. * @param mesh defines the mesh associated with this material
  77114. * @param onCompiled defines a function to execute once the material is compiled
  77115. * @param options defines the options to configure the compilation
  77116. */
  77117. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  77118. clipPlane: boolean;
  77119. }>): void;
  77120. /**
  77121. * Force shader compilation
  77122. * @param mesh defines the mesh that will use this material
  77123. * @param options defines additional options for compiling the shaders
  77124. * @returns a promise that resolves when the compilation completes
  77125. */
  77126. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  77127. clipPlane: boolean;
  77128. }>): Promise<void>;
  77129. private static readonly _ImageProcessingDirtyCallBack;
  77130. private static readonly _TextureDirtyCallBack;
  77131. private static readonly _FresnelDirtyCallBack;
  77132. private static readonly _MiscDirtyCallBack;
  77133. private static readonly _LightsDirtyCallBack;
  77134. private static readonly _AttributeDirtyCallBack;
  77135. private static _FresnelAndMiscDirtyCallBack;
  77136. private static _TextureAndMiscDirtyCallBack;
  77137. private static readonly _DirtyCallbackArray;
  77138. private static readonly _RunDirtyCallBacks;
  77139. /**
  77140. * Marks a define in the material to indicate that it needs to be re-computed
  77141. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  77142. */
  77143. markAsDirty(flag: number): void;
  77144. /**
  77145. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  77146. * @param func defines a function which checks material defines against the submeshes
  77147. */
  77148. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  77149. /**
  77150. * Indicates that image processing needs to be re-calculated for all submeshes
  77151. */
  77152. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  77153. /**
  77154. * Indicates that textures need to be re-calculated for all submeshes
  77155. */
  77156. protected _markAllSubMeshesAsTexturesDirty(): void;
  77157. /**
  77158. * Indicates that fresnel needs to be re-calculated for all submeshes
  77159. */
  77160. protected _markAllSubMeshesAsFresnelDirty(): void;
  77161. /**
  77162. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  77163. */
  77164. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  77165. /**
  77166. * Indicates that lights need to be re-calculated for all submeshes
  77167. */
  77168. protected _markAllSubMeshesAsLightsDirty(): void;
  77169. /**
  77170. * Indicates that attributes need to be re-calculated for all submeshes
  77171. */
  77172. protected _markAllSubMeshesAsAttributesDirty(): void;
  77173. /**
  77174. * Indicates that misc needs to be re-calculated for all submeshes
  77175. */
  77176. protected _markAllSubMeshesAsMiscDirty(): void;
  77177. /**
  77178. * Indicates that textures and misc need to be re-calculated for all submeshes
  77179. */
  77180. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  77181. /**
  77182. * Disposes the material
  77183. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77184. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77185. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77186. */
  77187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77188. /** @hidden */
  77189. private releaseVertexArrayObject;
  77190. /**
  77191. * Serializes this material
  77192. * @returns the serialized material object
  77193. */
  77194. serialize(): any;
  77195. /**
  77196. * Creates a material from parsed material data
  77197. * @param parsedMaterial defines parsed material data
  77198. * @param scene defines the hosting scene
  77199. * @param rootUrl defines the root URL to use to load textures
  77200. * @returns a new material
  77201. */
  77202. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  77203. }
  77204. }
  77205. declare module BABYLON {
  77206. /**
  77207. * Base class for submeshes
  77208. */
  77209. export class BaseSubMesh {
  77210. /** @hidden */
  77211. _materialDefines: Nullable<MaterialDefines>;
  77212. /** @hidden */
  77213. _materialEffect: Nullable<Effect>;
  77214. /**
  77215. * Gets associated effect
  77216. */
  77217. readonly effect: Nullable<Effect>;
  77218. /**
  77219. * Sets associated effect (effect used to render this submesh)
  77220. * @param effect defines the effect to associate with
  77221. * @param defines defines the set of defines used to compile this effect
  77222. */
  77223. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77224. }
  77225. /**
  77226. * Defines a subdivision inside a mesh
  77227. */
  77228. export class SubMesh extends BaseSubMesh implements ICullable {
  77229. /** the material index to use */
  77230. materialIndex: number;
  77231. /** vertex index start */
  77232. verticesStart: number;
  77233. /** vertices count */
  77234. verticesCount: number;
  77235. /** index start */
  77236. indexStart: number;
  77237. /** indices count */
  77238. indexCount: number;
  77239. /** @hidden */
  77240. _linesIndexCount: number;
  77241. private _mesh;
  77242. private _renderingMesh;
  77243. private _boundingInfo;
  77244. private _linesIndexBuffer;
  77245. /** @hidden */
  77246. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77247. /** @hidden */
  77248. _trianglePlanes: Plane[];
  77249. /** @hidden */
  77250. _lastColliderTransformMatrix: Matrix;
  77251. /** @hidden */
  77252. _renderId: number;
  77253. /** @hidden */
  77254. _alphaIndex: number;
  77255. /** @hidden */
  77256. _distanceToCamera: number;
  77257. /** @hidden */
  77258. _id: number;
  77259. private _currentMaterial;
  77260. /**
  77261. * Add a new submesh to a mesh
  77262. * @param materialIndex defines the material index to use
  77263. * @param verticesStart defines vertex index start
  77264. * @param verticesCount defines vertices count
  77265. * @param indexStart defines index start
  77266. * @param indexCount defines indices count
  77267. * @param mesh defines the parent mesh
  77268. * @param renderingMesh defines an optional rendering mesh
  77269. * @param createBoundingBox defines if bounding box should be created for this submesh
  77270. * @returns the new submesh
  77271. */
  77272. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77273. /**
  77274. * Creates a new submesh
  77275. * @param materialIndex defines the material index to use
  77276. * @param verticesStart defines vertex index start
  77277. * @param verticesCount defines vertices count
  77278. * @param indexStart defines index start
  77279. * @param indexCount defines indices count
  77280. * @param mesh defines the parent mesh
  77281. * @param renderingMesh defines an optional rendering mesh
  77282. * @param createBoundingBox defines if bounding box should be created for this submesh
  77283. */
  77284. constructor(
  77285. /** the material index to use */
  77286. materialIndex: number,
  77287. /** vertex index start */
  77288. verticesStart: number,
  77289. /** vertices count */
  77290. verticesCount: number,
  77291. /** index start */
  77292. indexStart: number,
  77293. /** indices count */
  77294. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77295. /**
  77296. * Returns true if this submesh covers the entire parent mesh
  77297. * @ignorenaming
  77298. */
  77299. readonly IsGlobal: boolean;
  77300. /**
  77301. * Returns the submesh BoudingInfo object
  77302. * @returns current bounding info (or mesh's one if the submesh is global)
  77303. */
  77304. getBoundingInfo(): BoundingInfo;
  77305. /**
  77306. * Sets the submesh BoundingInfo
  77307. * @param boundingInfo defines the new bounding info to use
  77308. * @returns the SubMesh
  77309. */
  77310. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77311. /**
  77312. * Returns the mesh of the current submesh
  77313. * @return the parent mesh
  77314. */
  77315. getMesh(): AbstractMesh;
  77316. /**
  77317. * Returns the rendering mesh of the submesh
  77318. * @returns the rendering mesh (could be different from parent mesh)
  77319. */
  77320. getRenderingMesh(): Mesh;
  77321. /**
  77322. * Returns the submesh material
  77323. * @returns null or the current material
  77324. */
  77325. getMaterial(): Nullable<Material>;
  77326. /**
  77327. * Sets a new updated BoundingInfo object to the submesh
  77328. * @returns the SubMesh
  77329. */
  77330. refreshBoundingInfo(): SubMesh;
  77331. /** @hidden */
  77332. _checkCollision(collider: Collider): boolean;
  77333. /**
  77334. * Updates the submesh BoundingInfo
  77335. * @param world defines the world matrix to use to update the bounding info
  77336. * @returns the submesh
  77337. */
  77338. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77339. /**
  77340. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77341. * @param frustumPlanes defines the frustum planes
  77342. * @returns true if the submesh is intersecting with the frustum
  77343. */
  77344. isInFrustum(frustumPlanes: Plane[]): boolean;
  77345. /**
  77346. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77347. * @param frustumPlanes defines the frustum planes
  77348. * @returns true if the submesh is inside the frustum
  77349. */
  77350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77351. /**
  77352. * Renders the submesh
  77353. * @param enableAlphaMode defines if alpha needs to be used
  77354. * @returns the submesh
  77355. */
  77356. render(enableAlphaMode: boolean): SubMesh;
  77357. /**
  77358. * @hidden
  77359. */
  77360. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77361. /**
  77362. * Checks if the submesh intersects with a ray
  77363. * @param ray defines the ray to test
  77364. * @returns true is the passed ray intersects the submesh bounding box
  77365. */
  77366. canIntersects(ray: Ray): boolean;
  77367. /**
  77368. * Intersects current submesh with a ray
  77369. * @param ray defines the ray to test
  77370. * @param positions defines mesh's positions array
  77371. * @param indices defines mesh's indices array
  77372. * @param fastCheck defines if only bounding info should be used
  77373. * @returns intersection info or null if no intersection
  77374. */
  77375. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77376. /** @hidden */
  77377. private _intersectLines;
  77378. /** @hidden */
  77379. private _intersectTriangles;
  77380. /** @hidden */
  77381. _rebuild(): void;
  77382. /**
  77383. * Creates a new submesh from the passed mesh
  77384. * @param newMesh defines the new hosting mesh
  77385. * @param newRenderingMesh defines an optional rendering mesh
  77386. * @returns the new submesh
  77387. */
  77388. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77389. /**
  77390. * Release associated resources
  77391. */
  77392. dispose(): void;
  77393. /**
  77394. * Gets the class name
  77395. * @returns the string "SubMesh".
  77396. */
  77397. getClassName(): string;
  77398. /**
  77399. * Creates a new submesh from indices data
  77400. * @param materialIndex the index of the main mesh material
  77401. * @param startIndex the index where to start the copy in the mesh indices array
  77402. * @param indexCount the number of indices to copy then from the startIndex
  77403. * @param mesh the main mesh to create the submesh from
  77404. * @param renderingMesh the optional rendering mesh
  77405. * @returns a new submesh
  77406. */
  77407. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77408. }
  77409. }
  77410. declare module BABYLON {
  77411. /**
  77412. * Class used to store geometry data (vertex buffers + index buffer)
  77413. */
  77414. export class Geometry implements IGetSetVerticesData {
  77415. /**
  77416. * Gets or sets the ID of the geometry
  77417. */
  77418. id: string;
  77419. /**
  77420. * Gets or sets the unique ID of the geometry
  77421. */
  77422. uniqueId: number;
  77423. /**
  77424. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77425. */
  77426. delayLoadState: number;
  77427. /**
  77428. * Gets the file containing the data to load when running in delay load state
  77429. */
  77430. delayLoadingFile: Nullable<string>;
  77431. /**
  77432. * Callback called when the geometry is updated
  77433. */
  77434. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77435. private _scene;
  77436. private _engine;
  77437. private _meshes;
  77438. private _totalVertices;
  77439. /** @hidden */
  77440. _indices: IndicesArray;
  77441. /** @hidden */
  77442. _vertexBuffers: {
  77443. [key: string]: VertexBuffer;
  77444. };
  77445. private _isDisposed;
  77446. private _extend;
  77447. private _boundingBias;
  77448. /** @hidden */
  77449. _delayInfo: Array<string>;
  77450. private _indexBuffer;
  77451. private _indexBufferIsUpdatable;
  77452. /** @hidden */
  77453. _boundingInfo: Nullable<BoundingInfo>;
  77454. /** @hidden */
  77455. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77456. /** @hidden */
  77457. _softwareSkinningFrameId: number;
  77458. private _vertexArrayObjects;
  77459. private _updatable;
  77460. /** @hidden */
  77461. _positions: Nullable<Vector3[]>;
  77462. /**
  77463. * 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
  77464. */
  77465. /**
  77466. * 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
  77467. */
  77468. boundingBias: Vector2;
  77469. /**
  77470. * Static function used to attach a new empty geometry to a mesh
  77471. * @param mesh defines the mesh to attach the geometry to
  77472. * @returns the new Geometry
  77473. */
  77474. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77475. /**
  77476. * Creates a new geometry
  77477. * @param id defines the unique ID
  77478. * @param scene defines the hosting scene
  77479. * @param vertexData defines the VertexData used to get geometry data
  77480. * @param updatable defines if geometry must be updatable (false by default)
  77481. * @param mesh defines the mesh that will be associated with the geometry
  77482. */
  77483. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77484. /**
  77485. * Gets the current extend of the geometry
  77486. */
  77487. readonly extend: {
  77488. minimum: Vector3;
  77489. maximum: Vector3;
  77490. };
  77491. /**
  77492. * Gets the hosting scene
  77493. * @returns the hosting Scene
  77494. */
  77495. getScene(): Scene;
  77496. /**
  77497. * Gets the hosting engine
  77498. * @returns the hosting Engine
  77499. */
  77500. getEngine(): Engine;
  77501. /**
  77502. * Defines if the geometry is ready to use
  77503. * @returns true if the geometry is ready to be used
  77504. */
  77505. isReady(): boolean;
  77506. /**
  77507. * Gets a value indicating that the geometry should not be serialized
  77508. */
  77509. readonly doNotSerialize: boolean;
  77510. /** @hidden */
  77511. _rebuild(): void;
  77512. /**
  77513. * Affects all geometry data in one call
  77514. * @param vertexData defines the geometry data
  77515. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77516. */
  77517. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77518. /**
  77519. * Set specific vertex data
  77520. * @param kind defines the data kind (Position, normal, etc...)
  77521. * @param data defines the vertex data to use
  77522. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77523. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77524. */
  77525. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77526. /**
  77527. * Removes a specific vertex data
  77528. * @param kind defines the data kind (Position, normal, etc...)
  77529. */
  77530. removeVerticesData(kind: string): void;
  77531. /**
  77532. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77533. * @param buffer defines the vertex buffer to use
  77534. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77535. */
  77536. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77537. /**
  77538. * Update a specific vertex buffer
  77539. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77540. * It will do nothing if the buffer is not updatable
  77541. * @param kind defines the data kind (Position, normal, etc...)
  77542. * @param data defines the data to use
  77543. * @param offset defines the offset in the target buffer where to store the data
  77544. * @param useBytes set to true if the offset is in bytes
  77545. */
  77546. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77547. /**
  77548. * Update a specific vertex buffer
  77549. * This function will create a new buffer if the current one is not updatable
  77550. * @param kind defines the data kind (Position, normal, etc...)
  77551. * @param data defines the data to use
  77552. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77553. */
  77554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77555. private _updateBoundingInfo;
  77556. /** @hidden */
  77557. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77558. /**
  77559. * Gets total number of vertices
  77560. * @returns the total number of vertices
  77561. */
  77562. getTotalVertices(): number;
  77563. /**
  77564. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77565. * @param kind defines the data kind (Position, normal, etc...)
  77566. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77567. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77568. * @returns a float array containing vertex data
  77569. */
  77570. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77571. /**
  77572. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77573. * @param kind defines the data kind (Position, normal, etc...)
  77574. * @returns true if the vertex buffer with the specified kind is updatable
  77575. */
  77576. isVertexBufferUpdatable(kind: string): boolean;
  77577. /**
  77578. * Gets a specific vertex buffer
  77579. * @param kind defines the data kind (Position, normal, etc...)
  77580. * @returns a VertexBuffer
  77581. */
  77582. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77583. /**
  77584. * Returns all vertex buffers
  77585. * @return an object holding all vertex buffers indexed by kind
  77586. */
  77587. getVertexBuffers(): Nullable<{
  77588. [key: string]: VertexBuffer;
  77589. }>;
  77590. /**
  77591. * Gets a boolean indicating if specific vertex buffer is present
  77592. * @param kind defines the data kind (Position, normal, etc...)
  77593. * @returns true if data is present
  77594. */
  77595. isVerticesDataPresent(kind: string): boolean;
  77596. /**
  77597. * Gets a list of all attached data kinds (Position, normal, etc...)
  77598. * @returns a list of string containing all kinds
  77599. */
  77600. getVerticesDataKinds(): string[];
  77601. /**
  77602. * Update index buffer
  77603. * @param indices defines the indices to store in the index buffer
  77604. * @param offset defines the offset in the target buffer where to store the data
  77605. */
  77606. updateIndices(indices: IndicesArray, offset?: number): void;
  77607. /**
  77608. * Creates a new index buffer
  77609. * @param indices defines the indices to store in the index buffer
  77610. * @param totalVertices defines the total number of vertices (could be null)
  77611. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77612. */
  77613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77614. /**
  77615. * Return the total number of indices
  77616. * @returns the total number of indices
  77617. */
  77618. getTotalIndices(): number;
  77619. /**
  77620. * Gets the index buffer array
  77621. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77622. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77623. * @returns the index buffer array
  77624. */
  77625. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77626. /**
  77627. * Gets the index buffer
  77628. * @return the index buffer
  77629. */
  77630. getIndexBuffer(): Nullable<WebGLBuffer>;
  77631. /** @hidden */
  77632. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77633. /**
  77634. * Release the associated resources for a specific mesh
  77635. * @param mesh defines the source mesh
  77636. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77637. */
  77638. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77639. /**
  77640. * Apply current geometry to a given mesh
  77641. * @param mesh defines the mesh to apply geometry to
  77642. */
  77643. applyToMesh(mesh: Mesh): void;
  77644. private _updateExtend;
  77645. private _applyToMesh;
  77646. private notifyUpdate;
  77647. /**
  77648. * Load the geometry if it was flagged as delay loaded
  77649. * @param scene defines the hosting scene
  77650. * @param onLoaded defines a callback called when the geometry is loaded
  77651. */
  77652. load(scene: Scene, onLoaded?: () => void): void;
  77653. private _queueLoad;
  77654. /**
  77655. * Invert the geometry to move from a right handed system to a left handed one.
  77656. */
  77657. toLeftHanded(): void;
  77658. /** @hidden */
  77659. _resetPointsArrayCache(): void;
  77660. /** @hidden */
  77661. _generatePointsArray(): boolean;
  77662. /**
  77663. * Gets a value indicating if the geometry is disposed
  77664. * @returns true if the geometry was disposed
  77665. */
  77666. isDisposed(): boolean;
  77667. private _disposeVertexArrayObjects;
  77668. /**
  77669. * Free all associated resources
  77670. */
  77671. dispose(): void;
  77672. /**
  77673. * Clone the current geometry into a new geometry
  77674. * @param id defines the unique ID of the new geometry
  77675. * @returns a new geometry object
  77676. */
  77677. copy(id: string): Geometry;
  77678. /**
  77679. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77680. * @return a JSON representation of the current geometry data (without the vertices data)
  77681. */
  77682. serialize(): any;
  77683. private toNumberArray;
  77684. /**
  77685. * Serialize all vertices data into a JSON oject
  77686. * @returns a JSON representation of the current geometry data
  77687. */
  77688. serializeVerticeData(): any;
  77689. /**
  77690. * Extracts a clone of a mesh geometry
  77691. * @param mesh defines the source mesh
  77692. * @param id defines the unique ID of the new geometry object
  77693. * @returns the new geometry object
  77694. */
  77695. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77696. /**
  77697. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77698. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77699. * Be aware Math.random() could cause collisions, but:
  77700. * "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"
  77701. * @returns a string containing a new GUID
  77702. */
  77703. static RandomId(): string;
  77704. /** @hidden */
  77705. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77706. private static _CleanMatricesWeights;
  77707. /**
  77708. * Create a new geometry from persisted data (Using .babylon file format)
  77709. * @param parsedVertexData defines the persisted data
  77710. * @param scene defines the hosting scene
  77711. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77712. * @returns the new geometry object
  77713. */
  77714. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77715. }
  77716. }
  77717. declare module BABYLON {
  77718. /**
  77719. * Define an interface for all classes that will get and set the data on vertices
  77720. */
  77721. export interface IGetSetVerticesData {
  77722. /**
  77723. * Gets a boolean indicating if specific vertex data is present
  77724. * @param kind defines the vertex data kind to use
  77725. * @returns true is data kind is present
  77726. */
  77727. isVerticesDataPresent(kind: string): boolean;
  77728. /**
  77729. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77730. * @param kind defines the data kind (Position, normal, etc...)
  77731. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77732. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77733. * @returns a float array containing vertex data
  77734. */
  77735. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77736. /**
  77737. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77738. * @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.
  77739. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77740. * @returns the indices array or an empty array if the mesh has no geometry
  77741. */
  77742. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77743. /**
  77744. * Set specific vertex data
  77745. * @param kind defines the data kind (Position, normal, etc...)
  77746. * @param data defines the vertex data to use
  77747. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77748. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77749. */
  77750. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  77751. /**
  77752. * Update a specific associated vertex buffer
  77753. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77754. * - VertexBuffer.PositionKind
  77755. * - VertexBuffer.UVKind
  77756. * - VertexBuffer.UV2Kind
  77757. * - VertexBuffer.UV3Kind
  77758. * - VertexBuffer.UV4Kind
  77759. * - VertexBuffer.UV5Kind
  77760. * - VertexBuffer.UV6Kind
  77761. * - VertexBuffer.ColorKind
  77762. * - VertexBuffer.MatricesIndicesKind
  77763. * - VertexBuffer.MatricesIndicesExtraKind
  77764. * - VertexBuffer.MatricesWeightsKind
  77765. * - VertexBuffer.MatricesWeightsExtraKind
  77766. * @param data defines the data source
  77767. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77768. * @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)
  77769. */
  77770. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  77771. /**
  77772. * Creates a new index buffer
  77773. * @param indices defines the indices to store in the index buffer
  77774. * @param totalVertices defines the total number of vertices (could be null)
  77775. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77776. */
  77777. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  77778. }
  77779. /**
  77780. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  77781. */
  77782. export class VertexData {
  77783. /**
  77784. * Mesh side orientation : usually the external or front surface
  77785. */
  77786. static readonly FRONTSIDE: number;
  77787. /**
  77788. * Mesh side orientation : usually the internal or back surface
  77789. */
  77790. static readonly BACKSIDE: number;
  77791. /**
  77792. * Mesh side orientation : both internal and external or front and back surfaces
  77793. */
  77794. static readonly DOUBLESIDE: number;
  77795. /**
  77796. * Mesh side orientation : by default, `FRONTSIDE`
  77797. */
  77798. static readonly DEFAULTSIDE: number;
  77799. /**
  77800. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  77801. */
  77802. positions: Nullable<FloatArray>;
  77803. /**
  77804. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  77805. */
  77806. normals: Nullable<FloatArray>;
  77807. /**
  77808. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  77809. */
  77810. tangents: Nullable<FloatArray>;
  77811. /**
  77812. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77813. */
  77814. uvs: Nullable<FloatArray>;
  77815. /**
  77816. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77817. */
  77818. uvs2: Nullable<FloatArray>;
  77819. /**
  77820. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77821. */
  77822. uvs3: Nullable<FloatArray>;
  77823. /**
  77824. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77825. */
  77826. uvs4: Nullable<FloatArray>;
  77827. /**
  77828. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77829. */
  77830. uvs5: Nullable<FloatArray>;
  77831. /**
  77832. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77833. */
  77834. uvs6: Nullable<FloatArray>;
  77835. /**
  77836. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  77837. */
  77838. colors: Nullable<FloatArray>;
  77839. /**
  77840. * 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).
  77841. */
  77842. matricesIndices: Nullable<FloatArray>;
  77843. /**
  77844. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  77845. */
  77846. matricesWeights: Nullable<FloatArray>;
  77847. /**
  77848. * An array extending the number of possible indices
  77849. */
  77850. matricesIndicesExtra: Nullable<FloatArray>;
  77851. /**
  77852. * An array extending the number of possible weights when the number of indices is extended
  77853. */
  77854. matricesWeightsExtra: Nullable<FloatArray>;
  77855. /**
  77856. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  77857. */
  77858. indices: Nullable<IndicesArray>;
  77859. /**
  77860. * Uses the passed data array to set the set the values for the specified kind of data
  77861. * @param data a linear array of floating numbers
  77862. * @param kind the type of data that is being set, eg positions, colors etc
  77863. */
  77864. set(data: FloatArray, kind: string): void;
  77865. /**
  77866. * Associates the vertexData to the passed Mesh.
  77867. * Sets it as updatable or not (default `false`)
  77868. * @param mesh the mesh the vertexData is applied to
  77869. * @param updatable when used and having the value true allows new data to update the vertexData
  77870. * @returns the VertexData
  77871. */
  77872. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  77873. /**
  77874. * Associates the vertexData to the passed Geometry.
  77875. * Sets it as updatable or not (default `false`)
  77876. * @param geometry the geometry the vertexData is applied to
  77877. * @param updatable when used and having the value true allows new data to update the vertexData
  77878. * @returns VertexData
  77879. */
  77880. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  77881. /**
  77882. * Updates the associated mesh
  77883. * @param mesh the mesh to be updated
  77884. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77885. * @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
  77886. * @returns VertexData
  77887. */
  77888. updateMesh(mesh: Mesh): VertexData;
  77889. /**
  77890. * Updates the associated geometry
  77891. * @param geometry the geometry to be updated
  77892. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77893. * @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
  77894. * @returns VertexData.
  77895. */
  77896. updateGeometry(geometry: Geometry): VertexData;
  77897. private _applyTo;
  77898. private _update;
  77899. /**
  77900. * Transforms each position and each normal of the vertexData according to the passed Matrix
  77901. * @param matrix the transforming matrix
  77902. * @returns the VertexData
  77903. */
  77904. transform(matrix: Matrix): VertexData;
  77905. /**
  77906. * Merges the passed VertexData into the current one
  77907. * @param other the VertexData to be merged into the current one
  77908. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  77909. * @returns the modified VertexData
  77910. */
  77911. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  77912. private _mergeElement;
  77913. private _validate;
  77914. /**
  77915. * Serializes the VertexData
  77916. * @returns a serialized object
  77917. */
  77918. serialize(): any;
  77919. /**
  77920. * Extracts the vertexData from a mesh
  77921. * @param mesh the mesh from which to extract the VertexData
  77922. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  77923. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77924. * @returns the object VertexData associated to the passed mesh
  77925. */
  77926. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77927. /**
  77928. * Extracts the vertexData from the geometry
  77929. * @param geometry the geometry from which to extract the VertexData
  77930. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  77931. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77932. * @returns the object VertexData associated to the passed mesh
  77933. */
  77934. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77935. private static _ExtractFrom;
  77936. /**
  77937. * Creates the VertexData for a Ribbon
  77938. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  77939. * * pathArray array of paths, each of which an array of successive Vector3
  77940. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  77941. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  77942. * * 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
  77943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77944. * * 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)
  77945. * * 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)
  77946. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  77947. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  77948. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  77949. * @returns the VertexData of the ribbon
  77950. */
  77951. static CreateRibbon(options: {
  77952. pathArray: Vector3[][];
  77953. closeArray?: boolean;
  77954. closePath?: boolean;
  77955. offset?: number;
  77956. sideOrientation?: number;
  77957. frontUVs?: Vector4;
  77958. backUVs?: Vector4;
  77959. invertUV?: boolean;
  77960. uvs?: Vector2[];
  77961. colors?: Color4[];
  77962. }): VertexData;
  77963. /**
  77964. * Creates the VertexData for a box
  77965. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77966. * * size sets the width, height and depth of the box to the value of size, optional default 1
  77967. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  77968. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  77969. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  77970. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  77971. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  77972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77973. * * 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)
  77974. * * 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)
  77975. * @returns the VertexData of the box
  77976. */
  77977. static CreateBox(options: {
  77978. size?: number;
  77979. width?: number;
  77980. height?: number;
  77981. depth?: number;
  77982. faceUV?: Vector4[];
  77983. faceColors?: Color4[];
  77984. sideOrientation?: number;
  77985. frontUVs?: Vector4;
  77986. backUVs?: Vector4;
  77987. }): VertexData;
  77988. /**
  77989. * Creates the VertexData for an ellipsoid, defaults to a sphere
  77990. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77991. * * segments sets the number of horizontal strips optional, default 32
  77992. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  77993. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  77994. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  77995. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  77996. * * 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
  77997. * * 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
  77998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77999. * * 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)
  78000. * * 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)
  78001. * @returns the VertexData of the ellipsoid
  78002. */
  78003. static CreateSphere(options: {
  78004. segments?: number;
  78005. diameter?: number;
  78006. diameterX?: number;
  78007. diameterY?: number;
  78008. diameterZ?: number;
  78009. arc?: number;
  78010. slice?: number;
  78011. sideOrientation?: number;
  78012. frontUVs?: Vector4;
  78013. backUVs?: Vector4;
  78014. }): VertexData;
  78015. /**
  78016. * Creates the VertexData for a cylinder, cone or prism
  78017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78018. * * height sets the height (y direction) of the cylinder, optional, default 2
  78019. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78020. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78021. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78022. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78023. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78024. * * 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
  78025. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78026. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78027. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78028. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78030. * * 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)
  78031. * * 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)
  78032. * @returns the VertexData of the cylinder, cone or prism
  78033. */
  78034. static CreateCylinder(options: {
  78035. height?: number;
  78036. diameterTop?: number;
  78037. diameterBottom?: number;
  78038. diameter?: number;
  78039. tessellation?: number;
  78040. subdivisions?: number;
  78041. arc?: number;
  78042. faceColors?: Color4[];
  78043. faceUV?: Vector4[];
  78044. hasRings?: boolean;
  78045. enclose?: boolean;
  78046. sideOrientation?: number;
  78047. frontUVs?: Vector4;
  78048. backUVs?: Vector4;
  78049. }): VertexData;
  78050. /**
  78051. * Creates the VertexData for a torus
  78052. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78053. * * diameter the diameter of the torus, optional default 1
  78054. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78055. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78057. * * 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)
  78058. * * 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)
  78059. * @returns the VertexData of the torus
  78060. */
  78061. static CreateTorus(options: {
  78062. diameter?: number;
  78063. thickness?: number;
  78064. tessellation?: number;
  78065. sideOrientation?: number;
  78066. frontUVs?: Vector4;
  78067. backUVs?: Vector4;
  78068. }): VertexData;
  78069. /**
  78070. * Creates the VertexData of the LineSystem
  78071. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78072. * - lines an array of lines, each line being an array of successive Vector3
  78073. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78074. * @returns the VertexData of the LineSystem
  78075. */
  78076. static CreateLineSystem(options: {
  78077. lines: Vector3[][];
  78078. colors?: Nullable<Color4[][]>;
  78079. }): VertexData;
  78080. /**
  78081. * Create the VertexData for a DashedLines
  78082. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78083. * - points an array successive Vector3
  78084. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78085. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78086. * - dashNb the intended total number of dashes, optional, default 200
  78087. * @returns the VertexData for the DashedLines
  78088. */
  78089. static CreateDashedLines(options: {
  78090. points: Vector3[];
  78091. dashSize?: number;
  78092. gapSize?: number;
  78093. dashNb?: number;
  78094. }): VertexData;
  78095. /**
  78096. * Creates the VertexData for a Ground
  78097. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78098. * - width the width (x direction) of the ground, optional, default 1
  78099. * - height the height (z direction) of the ground, optional, default 1
  78100. * - subdivisions the number of subdivisions per side, optional, default 1
  78101. * @returns the VertexData of the Ground
  78102. */
  78103. static CreateGround(options: {
  78104. width?: number;
  78105. height?: number;
  78106. subdivisions?: number;
  78107. subdivisionsX?: number;
  78108. subdivisionsY?: number;
  78109. }): VertexData;
  78110. /**
  78111. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78112. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78113. * * xmin the ground minimum X coordinate, optional, default -1
  78114. * * zmin the ground minimum Z coordinate, optional, default -1
  78115. * * xmax the ground maximum X coordinate, optional, default 1
  78116. * * zmax the ground maximum Z coordinate, optional, default 1
  78117. * * 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}
  78118. * * 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}
  78119. * @returns the VertexData of the TiledGround
  78120. */
  78121. static CreateTiledGround(options: {
  78122. xmin: number;
  78123. zmin: number;
  78124. xmax: number;
  78125. zmax: number;
  78126. subdivisions?: {
  78127. w: number;
  78128. h: number;
  78129. };
  78130. precision?: {
  78131. w: number;
  78132. h: number;
  78133. };
  78134. }): VertexData;
  78135. /**
  78136. * Creates the VertexData of the Ground designed from a heightmap
  78137. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78138. * * width the width (x direction) of the ground
  78139. * * height the height (z direction) of the ground
  78140. * * subdivisions the number of subdivisions per side
  78141. * * minHeight the minimum altitude on the ground, optional, default 0
  78142. * * maxHeight the maximum altitude on the ground, optional default 1
  78143. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78144. * * buffer the array holding the image color data
  78145. * * bufferWidth the width of image
  78146. * * bufferHeight the height of image
  78147. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78148. * @returns the VertexData of the Ground designed from a heightmap
  78149. */
  78150. static CreateGroundFromHeightMap(options: {
  78151. width: number;
  78152. height: number;
  78153. subdivisions: number;
  78154. minHeight: number;
  78155. maxHeight: number;
  78156. colorFilter: Color3;
  78157. buffer: Uint8Array;
  78158. bufferWidth: number;
  78159. bufferHeight: number;
  78160. alphaFilter: number;
  78161. }): VertexData;
  78162. /**
  78163. * Creates the VertexData for a Plane
  78164. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78165. * * size sets the width and height of the plane to the value of size, optional default 1
  78166. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78167. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78169. * * 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)
  78170. * * 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)
  78171. * @returns the VertexData of the box
  78172. */
  78173. static CreatePlane(options: {
  78174. size?: number;
  78175. width?: number;
  78176. height?: number;
  78177. sideOrientation?: number;
  78178. frontUVs?: Vector4;
  78179. backUVs?: Vector4;
  78180. }): VertexData;
  78181. /**
  78182. * Creates the VertexData of the Disc or regular Polygon
  78183. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78184. * * radius the radius of the disc, optional default 0.5
  78185. * * tessellation the number of polygon sides, optional, default 64
  78186. * * 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
  78187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78188. * * 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)
  78189. * * 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)
  78190. * @returns the VertexData of the box
  78191. */
  78192. static CreateDisc(options: {
  78193. radius?: number;
  78194. tessellation?: number;
  78195. arc?: number;
  78196. sideOrientation?: number;
  78197. frontUVs?: Vector4;
  78198. backUVs?: Vector4;
  78199. }): VertexData;
  78200. /**
  78201. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78202. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78203. * @param polygon a mesh built from polygonTriangulation.build()
  78204. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78205. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78206. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78207. * @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)
  78208. * @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)
  78209. * @returns the VertexData of the Polygon
  78210. */
  78211. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78212. /**
  78213. * Creates the VertexData of the IcoSphere
  78214. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78215. * * radius the radius of the IcoSphere, optional default 1
  78216. * * radiusX allows stretching in the x direction, optional, default radius
  78217. * * radiusY allows stretching in the y direction, optional, default radius
  78218. * * radiusZ allows stretching in the z direction, optional, default radius
  78219. * * flat when true creates a flat shaded mesh, optional, default true
  78220. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78221. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78222. * * 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)
  78223. * * 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)
  78224. * @returns the VertexData of the IcoSphere
  78225. */
  78226. static CreateIcoSphere(options: {
  78227. radius?: number;
  78228. radiusX?: number;
  78229. radiusY?: number;
  78230. radiusZ?: number;
  78231. flat?: boolean;
  78232. subdivisions?: number;
  78233. sideOrientation?: number;
  78234. frontUVs?: Vector4;
  78235. backUVs?: Vector4;
  78236. }): VertexData;
  78237. /**
  78238. * Creates the VertexData for a Polyhedron
  78239. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78240. * * type provided types are:
  78241. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78242. * * 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)
  78243. * * size the size of the IcoSphere, optional default 1
  78244. * * sizeX allows stretching in the x direction, optional, default size
  78245. * * sizeY allows stretching in the y direction, optional, default size
  78246. * * sizeZ allows stretching in the z direction, optional, default size
  78247. * * 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
  78248. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78249. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78250. * * flat when true creates a flat shaded mesh, optional, default true
  78251. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78252. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78253. * * 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)
  78254. * * 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)
  78255. * @returns the VertexData of the Polyhedron
  78256. */
  78257. static CreatePolyhedron(options: {
  78258. type?: number;
  78259. size?: number;
  78260. sizeX?: number;
  78261. sizeY?: number;
  78262. sizeZ?: number;
  78263. custom?: any;
  78264. faceUV?: Vector4[];
  78265. faceColors?: Color4[];
  78266. flat?: boolean;
  78267. sideOrientation?: number;
  78268. frontUVs?: Vector4;
  78269. backUVs?: Vector4;
  78270. }): VertexData;
  78271. /**
  78272. * Creates the VertexData for a TorusKnot
  78273. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78274. * * radius the radius of the torus knot, optional, default 2
  78275. * * tube the thickness of the tube, optional, default 0.5
  78276. * * radialSegments the number of sides on each tube segments, optional, default 32
  78277. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78278. * * p the number of windings around the z axis, optional, default 2
  78279. * * q the number of windings around the x axis, optional, default 3
  78280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78281. * * 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)
  78282. * * 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)
  78283. * @returns the VertexData of the Torus Knot
  78284. */
  78285. static CreateTorusKnot(options: {
  78286. radius?: number;
  78287. tube?: number;
  78288. radialSegments?: number;
  78289. tubularSegments?: number;
  78290. p?: number;
  78291. q?: number;
  78292. sideOrientation?: number;
  78293. frontUVs?: Vector4;
  78294. backUVs?: Vector4;
  78295. }): VertexData;
  78296. /**
  78297. * Compute normals for given positions and indices
  78298. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78299. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78300. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78301. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78302. * * facetNormals : optional array of facet normals (vector3)
  78303. * * facetPositions : optional array of facet positions (vector3)
  78304. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78305. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78306. * * bInfo : optional bounding info, required for facetPartitioning computation
  78307. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78308. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78309. * * useRightHandedSystem: optional boolean to for right handed system computation
  78310. * * depthSort : optional boolean to enable the facet depth sort computation
  78311. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78312. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78313. */
  78314. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78315. facetNormals?: any;
  78316. facetPositions?: any;
  78317. facetPartitioning?: any;
  78318. ratio?: number;
  78319. bInfo?: any;
  78320. bbSize?: Vector3;
  78321. subDiv?: any;
  78322. useRightHandedSystem?: boolean;
  78323. depthSort?: boolean;
  78324. distanceTo?: Vector3;
  78325. depthSortedFacets?: any;
  78326. }): void;
  78327. /** @hidden */
  78328. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78329. /**
  78330. * Applies VertexData created from the imported parameters to the geometry
  78331. * @param parsedVertexData the parsed data from an imported file
  78332. * @param geometry the geometry to apply the VertexData to
  78333. */
  78334. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78335. }
  78336. }
  78337. declare module BABYLON {
  78338. /**
  78339. * Class containing static functions to help procedurally build meshes
  78340. */
  78341. export class DiscBuilder {
  78342. /**
  78343. * Creates a plane polygonal mesh. By default, this is a disc
  78344. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78345. * * 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
  78346. * * 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
  78347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78350. * @param name defines the name of the mesh
  78351. * @param options defines the options used to create the mesh
  78352. * @param scene defines the hosting scene
  78353. * @returns the plane polygonal mesh
  78354. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78355. */
  78356. static CreateDisc(name: string, options: {
  78357. radius?: number;
  78358. tessellation?: number;
  78359. arc?: number;
  78360. updatable?: boolean;
  78361. sideOrientation?: number;
  78362. frontUVs?: Vector4;
  78363. backUVs?: Vector4;
  78364. }, scene?: Nullable<Scene>): Mesh;
  78365. }
  78366. }
  78367. declare module BABYLON {
  78368. /**
  78369. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78370. *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.
  78371. * The SPS is also a particle system. It provides some methods to manage the particles.
  78372. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78373. *
  78374. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78375. */
  78376. export class SolidParticleSystem implements IDisposable {
  78377. /**
  78378. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78379. * Example : var p = SPS.particles[i];
  78380. */
  78381. particles: SolidParticle[];
  78382. /**
  78383. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78384. */
  78385. nbParticles: number;
  78386. /**
  78387. * If the particles must ever face the camera (default false). Useful for planar particles.
  78388. */
  78389. billboard: boolean;
  78390. /**
  78391. * Recompute normals when adding a shape
  78392. */
  78393. recomputeNormals: boolean;
  78394. /**
  78395. * This a counter ofr your own usage. It's not set by any SPS functions.
  78396. */
  78397. counter: number;
  78398. /**
  78399. * The SPS name. This name is also given to the underlying mesh.
  78400. */
  78401. name: string;
  78402. /**
  78403. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78404. */
  78405. mesh: Mesh;
  78406. /**
  78407. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78408. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78409. */
  78410. vars: any;
  78411. /**
  78412. * This array is populated when the SPS is set as 'pickable'.
  78413. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78414. * Each element of this array is an object `{idx: int, faceId: int}`.
  78415. * `idx` is the picked particle index in the `SPS.particles` array
  78416. * `faceId` is the picked face index counted within this particle.
  78417. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78418. */
  78419. pickedParticles: {
  78420. idx: number;
  78421. faceId: number;
  78422. }[];
  78423. /**
  78424. * This array is populated when `enableDepthSort` is set to true.
  78425. * Each element of this array is an instance of the class DepthSortedParticle.
  78426. */
  78427. depthSortedParticles: DepthSortedParticle[];
  78428. /**
  78429. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78430. * @hidden
  78431. */
  78432. _bSphereOnly: boolean;
  78433. /**
  78434. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78435. * @hidden
  78436. */
  78437. _bSphereRadiusFactor: number;
  78438. private _scene;
  78439. private _positions;
  78440. private _indices;
  78441. private _normals;
  78442. private _colors;
  78443. private _uvs;
  78444. private _indices32;
  78445. private _positions32;
  78446. private _normals32;
  78447. private _fixedNormal32;
  78448. private _colors32;
  78449. private _uvs32;
  78450. private _index;
  78451. private _updatable;
  78452. private _pickable;
  78453. private _isVisibilityBoxLocked;
  78454. private _alwaysVisible;
  78455. private _depthSort;
  78456. private _shapeCounter;
  78457. private _copy;
  78458. private _color;
  78459. private _computeParticleColor;
  78460. private _computeParticleTexture;
  78461. private _computeParticleRotation;
  78462. private _computeParticleVertex;
  78463. private _computeBoundingBox;
  78464. private _depthSortParticles;
  78465. private _camera;
  78466. private _mustUnrotateFixedNormals;
  78467. private _particlesIntersect;
  78468. private _needs32Bits;
  78469. /**
  78470. * Creates a SPS (Solid Particle System) object.
  78471. * @param name (String) is the SPS name, this will be the underlying mesh name.
  78472. * @param scene (Scene) is the scene in which the SPS is added.
  78473. * @param options defines the options of the sps e.g.
  78474. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  78475. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  78476. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  78477. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  78478. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  78479. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  78480. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  78481. */
  78482. constructor(name: string, scene: Scene, options?: {
  78483. updatable?: boolean;
  78484. isPickable?: boolean;
  78485. enableDepthSort?: boolean;
  78486. particleIntersection?: boolean;
  78487. boundingSphereOnly?: boolean;
  78488. bSphereRadiusFactor?: number;
  78489. });
  78490. /**
  78491. * Builds the SPS underlying mesh. Returns a standard Mesh.
  78492. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  78493. * @returns the created mesh
  78494. */
  78495. buildMesh(): Mesh;
  78496. /**
  78497. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  78498. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  78499. * Thus the particles generated from `digest()` have their property `position` set yet.
  78500. * @param mesh ( Mesh ) is the mesh to be digested
  78501. * @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
  78502. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  78503. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  78504. * @returns the current SPS
  78505. */
  78506. digest(mesh: Mesh, options?: {
  78507. facetNb?: number;
  78508. number?: number;
  78509. delta?: number;
  78510. }): SolidParticleSystem;
  78511. private _unrotateFixedNormals;
  78512. private _resetCopy;
  78513. private _meshBuilder;
  78514. private _posToShape;
  78515. private _uvsToShapeUV;
  78516. private _addParticle;
  78517. /**
  78518. * Adds some particles to the SPS from the model shape. Returns the shape id.
  78519. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  78520. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  78521. * @param nb (positive integer) the number of particles to be created from this model
  78522. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  78523. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  78524. * @returns the number of shapes in the system
  78525. */
  78526. addShape(mesh: Mesh, nb: number, options?: {
  78527. positionFunction?: any;
  78528. vertexFunction?: any;
  78529. }): number;
  78530. private _rebuildParticle;
  78531. /**
  78532. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  78533. * @returns the SPS.
  78534. */
  78535. rebuildMesh(): SolidParticleSystem;
  78536. /**
  78537. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  78538. * This method calls `updateParticle()` for each particle of the SPS.
  78539. * For an animated SPS, it is usually called within the render loop.
  78540. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  78541. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  78542. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  78543. * @returns the SPS.
  78544. */
  78545. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  78546. /**
  78547. * Disposes the SPS.
  78548. */
  78549. dispose(): void;
  78550. /**
  78551. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  78552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78553. * @returns the SPS.
  78554. */
  78555. refreshVisibleSize(): SolidParticleSystem;
  78556. /**
  78557. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  78558. * @param size the size (float) of the visibility box
  78559. * note : this doesn't lock the SPS mesh bounding box.
  78560. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78561. */
  78562. setVisibilityBox(size: number): void;
  78563. /**
  78564. * Gets whether the SPS as always visible or not
  78565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78566. */
  78567. /**
  78568. * Sets the SPS as always visible or not
  78569. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78570. */
  78571. isAlwaysVisible: boolean;
  78572. /**
  78573. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78574. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78575. */
  78576. /**
  78577. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78578. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78579. */
  78580. isVisibilityBoxLocked: boolean;
  78581. /**
  78582. * Tells to `setParticles()` to compute the particle rotations or not.
  78583. * Default value : true. The SPS is faster when it's set to false.
  78584. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78585. */
  78586. /**
  78587. * Gets if `setParticles()` computes the particle rotations or not.
  78588. * Default value : true. The SPS is faster when it's set to false.
  78589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78590. */
  78591. computeParticleRotation: boolean;
  78592. /**
  78593. * Tells to `setParticles()` to compute the particle colors or not.
  78594. * Default value : true. The SPS is faster when it's set to false.
  78595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78596. */
  78597. /**
  78598. * Gets if `setParticles()` computes the particle colors or not.
  78599. * Default value : true. The SPS is faster when it's set to false.
  78600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78601. */
  78602. computeParticleColor: boolean;
  78603. /**
  78604. * Gets if `setParticles()` computes the particle textures or not.
  78605. * Default value : true. The SPS is faster when it's set to false.
  78606. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  78607. */
  78608. computeParticleTexture: boolean;
  78609. /**
  78610. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  78611. * Default value : false. The SPS is faster when it's set to false.
  78612. * Note : the particle custom vertex positions aren't stored values.
  78613. */
  78614. /**
  78615. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  78616. * Default value : false. The SPS is faster when it's set to false.
  78617. * Note : the particle custom vertex positions aren't stored values.
  78618. */
  78619. computeParticleVertex: boolean;
  78620. /**
  78621. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  78622. */
  78623. /**
  78624. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  78625. */
  78626. computeBoundingBox: boolean;
  78627. /**
  78628. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  78629. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78630. * Default : `true`
  78631. */
  78632. /**
  78633. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  78634. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78635. * Default : `true`
  78636. */
  78637. depthSortParticles: boolean;
  78638. /**
  78639. * This function does nothing. It may be overwritten to set all the particle first values.
  78640. * The SPS doesn't call this function, you may have to call it by your own.
  78641. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78642. */
  78643. initParticles(): void;
  78644. /**
  78645. * This function does nothing. It may be overwritten to recycle a particle.
  78646. * The SPS doesn't call this function, you may have to call it by your own.
  78647. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78648. * @param particle The particle to recycle
  78649. * @returns the recycled particle
  78650. */
  78651. recycleParticle(particle: SolidParticle): SolidParticle;
  78652. /**
  78653. * Updates a particle : this function should be overwritten by the user.
  78654. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  78655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78656. * @example : just set a particle position or velocity and recycle conditions
  78657. * @param particle The particle to update
  78658. * @returns the updated particle
  78659. */
  78660. updateParticle(particle: SolidParticle): SolidParticle;
  78661. /**
  78662. * Updates a vertex of a particle : it can be overwritten by the user.
  78663. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  78664. * @param particle the current particle
  78665. * @param vertex the current index of the current particle
  78666. * @param pt the index of the current vertex in the particle shape
  78667. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  78668. * @example : just set a vertex particle position
  78669. * @returns the updated vertex
  78670. */
  78671. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  78672. /**
  78673. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  78674. * This does nothing and may be overwritten by the user.
  78675. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78676. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78677. * @param update the boolean update value actually passed to setParticles()
  78678. */
  78679. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78680. /**
  78681. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  78682. * This will be passed three parameters.
  78683. * This does nothing and may be overwritten by the user.
  78684. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78685. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78686. * @param update the boolean update value actually passed to setParticles()
  78687. */
  78688. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78689. }
  78690. }
  78691. declare module BABYLON {
  78692. /**
  78693. * Represents one particle of a solid particle system.
  78694. */
  78695. export class SolidParticle {
  78696. /**
  78697. * particle global index
  78698. */
  78699. idx: number;
  78700. /**
  78701. * The color of the particle
  78702. */
  78703. color: Nullable<Color4>;
  78704. /**
  78705. * The world space position of the particle.
  78706. */
  78707. position: Vector3;
  78708. /**
  78709. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  78710. */
  78711. rotation: Vector3;
  78712. /**
  78713. * The world space rotation quaternion of the particle.
  78714. */
  78715. rotationQuaternion: Nullable<Quaternion>;
  78716. /**
  78717. * The scaling of the particle.
  78718. */
  78719. scaling: Vector3;
  78720. /**
  78721. * The uvs of the particle.
  78722. */
  78723. uvs: Vector4;
  78724. /**
  78725. * The current speed of the particle.
  78726. */
  78727. velocity: Vector3;
  78728. /**
  78729. * The pivot point in the particle local space.
  78730. */
  78731. pivot: Vector3;
  78732. /**
  78733. * Must the particle be translated from its pivot point in its local space ?
  78734. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  78735. * Default : false
  78736. */
  78737. translateFromPivot: boolean;
  78738. /**
  78739. * Is the particle active or not ?
  78740. */
  78741. alive: boolean;
  78742. /**
  78743. * Is the particle visible or not ?
  78744. */
  78745. isVisible: boolean;
  78746. /**
  78747. * Index of this particle in the global "positions" array (Internal use)
  78748. * @hidden
  78749. */
  78750. _pos: number;
  78751. /**
  78752. * @hidden Index of this particle in the global "indices" array (Internal use)
  78753. */
  78754. _ind: number;
  78755. /**
  78756. * @hidden ModelShape of this particle (Internal use)
  78757. */
  78758. _model: ModelShape;
  78759. /**
  78760. * ModelShape id of this particle
  78761. */
  78762. shapeId: number;
  78763. /**
  78764. * Index of the particle in its shape id (Internal use)
  78765. */
  78766. idxInShape: number;
  78767. /**
  78768. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  78769. */
  78770. _modelBoundingInfo: BoundingInfo;
  78771. /**
  78772. * @hidden Particle BoundingInfo object (Internal use)
  78773. */
  78774. _boundingInfo: BoundingInfo;
  78775. /**
  78776. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  78777. */
  78778. _sps: SolidParticleSystem;
  78779. /**
  78780. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  78781. */
  78782. _stillInvisible: boolean;
  78783. /**
  78784. * @hidden Last computed particle rotation matrix
  78785. */
  78786. _rotationMatrix: number[];
  78787. /**
  78788. * Parent particle Id, if any.
  78789. * Default null.
  78790. */
  78791. parentId: Nullable<number>;
  78792. /**
  78793. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  78794. * The possible values are :
  78795. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78796. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78797. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78798. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78799. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78800. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  78801. * */
  78802. cullingStrategy: number;
  78803. /**
  78804. * @hidden Internal global position in the SPS.
  78805. */
  78806. _globalPosition: Vector3;
  78807. /**
  78808. * Creates a Solid Particle object.
  78809. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  78810. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  78811. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  78812. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  78813. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  78814. * @param shapeId (integer) is the model shape identifier in the SPS.
  78815. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  78816. * @param sps defines the sps it is associated to
  78817. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  78818. */
  78819. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  78820. /**
  78821. * Legacy support, changed scale to scaling
  78822. */
  78823. /**
  78824. * Legacy support, changed scale to scaling
  78825. */
  78826. scale: Vector3;
  78827. /**
  78828. * Legacy support, changed quaternion to rotationQuaternion
  78829. */
  78830. /**
  78831. * Legacy support, changed quaternion to rotationQuaternion
  78832. */
  78833. quaternion: Nullable<Quaternion>;
  78834. /**
  78835. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  78836. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  78837. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  78838. * @returns true if it intersects
  78839. */
  78840. intersectsMesh(target: Mesh | SolidParticle): boolean;
  78841. /**
  78842. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  78843. * A particle is in the frustum if its bounding box intersects the frustum
  78844. * @param frustumPlanes defines the frustum to test
  78845. * @returns true if the particle is in the frustum planes
  78846. */
  78847. isInFrustum(frustumPlanes: Plane[]): boolean;
  78848. /**
  78849. * get the rotation matrix of the particle
  78850. * @hidden
  78851. */
  78852. getRotationMatrix(m: Matrix): void;
  78853. }
  78854. /**
  78855. * Represents the shape of the model used by one particle of a solid particle system.
  78856. * SPS internal tool, don't use it manually.
  78857. */
  78858. export class ModelShape {
  78859. /**
  78860. * The shape id
  78861. * @hidden
  78862. */
  78863. shapeID: number;
  78864. /**
  78865. * flat array of model positions (internal use)
  78866. * @hidden
  78867. */
  78868. _shape: Vector3[];
  78869. /**
  78870. * flat array of model UVs (internal use)
  78871. * @hidden
  78872. */
  78873. _shapeUV: number[];
  78874. /**
  78875. * length of the shape in the model indices array (internal use)
  78876. * @hidden
  78877. */
  78878. _indicesLength: number;
  78879. /**
  78880. * Custom position function (internal use)
  78881. * @hidden
  78882. */
  78883. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  78884. /**
  78885. * Custom vertex function (internal use)
  78886. * @hidden
  78887. */
  78888. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  78889. /**
  78890. * 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.
  78891. * SPS internal tool, don't use it manually.
  78892. * @hidden
  78893. */
  78894. 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>);
  78895. }
  78896. /**
  78897. * Represents a Depth Sorted Particle in the solid particle system.
  78898. */
  78899. export class DepthSortedParticle {
  78900. /**
  78901. * Index of the particle in the "indices" array
  78902. */
  78903. ind: number;
  78904. /**
  78905. * Length of the particle shape in the "indices" array
  78906. */
  78907. indicesLength: number;
  78908. /**
  78909. * Squared distance from the particle to the camera
  78910. */
  78911. sqDistance: number;
  78912. }
  78913. }
  78914. declare module BABYLON {
  78915. /**
  78916. * Class used to store all common mesh properties
  78917. */
  78918. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  78919. /** No occlusion */
  78920. static OCCLUSION_TYPE_NONE: number;
  78921. /** Occlusion set to optimisitic */
  78922. static OCCLUSION_TYPE_OPTIMISTIC: number;
  78923. /** Occlusion set to strict */
  78924. static OCCLUSION_TYPE_STRICT: number;
  78925. /** Use an accurante occlusion algorithm */
  78926. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  78927. /** Use a conservative occlusion algorithm */
  78928. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  78929. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78930. * Test order :
  78931. * Is the bounding sphere outside the frustum ?
  78932. * If not, are the bounding box vertices outside the frustum ?
  78933. * It not, then the cullable object is in the frustum.
  78934. */
  78935. static readonly CULLINGSTRATEGY_STANDARD: number;
  78936. /** Culling strategy : Bounding Sphere Only.
  78937. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78938. * It's also less accurate than the standard because some not visible objects can still be selected.
  78939. * Test : is the bounding sphere outside the frustum ?
  78940. * If not, then the cullable object is in the frustum.
  78941. */
  78942. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78943. /** Culling strategy : Optimistic Inclusion.
  78944. * This in an inclusion test first, then the standard exclusion test.
  78945. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78946. * 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.
  78947. * Anyway, it's as accurate as the standard strategy.
  78948. * Test :
  78949. * Is the cullable object bounding sphere center in the frustum ?
  78950. * If not, apply the default culling strategy.
  78951. */
  78952. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78953. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78954. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78955. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78956. * 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.
  78957. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78958. * Test :
  78959. * Is the cullable object bounding sphere center in the frustum ?
  78960. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78961. */
  78962. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78963. /**
  78964. * No billboard
  78965. */
  78966. static readonly BILLBOARDMODE_NONE: number;
  78967. /** Billboard on X axis */
  78968. static readonly BILLBOARDMODE_X: number;
  78969. /** Billboard on Y axis */
  78970. static readonly BILLBOARDMODE_Y: number;
  78971. /** Billboard on Z axis */
  78972. static readonly BILLBOARDMODE_Z: number;
  78973. /** Billboard on all axes */
  78974. static readonly BILLBOARDMODE_ALL: number;
  78975. private _facetData;
  78976. /**
  78977. * The culling strategy to use to check whether the mesh must be rendered or not.
  78978. * This value can be changed at any time and will be used on the next render mesh selection.
  78979. * The possible values are :
  78980. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78981. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78982. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78983. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78984. * Please read each static variable documentation to get details about the culling process.
  78985. * */
  78986. cullingStrategy: number;
  78987. /**
  78988. * Gets the number of facets in the mesh
  78989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78990. */
  78991. readonly facetNb: number;
  78992. /**
  78993. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78995. */
  78996. partitioningSubdivisions: number;
  78997. /**
  78998. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78999. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79001. */
  79002. partitioningBBoxRatio: number;
  79003. /**
  79004. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79005. * Works only for updatable meshes.
  79006. * Doesn't work with multi-materials
  79007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79008. */
  79009. mustDepthSortFacets: boolean;
  79010. /**
  79011. * The location (Vector3) where the facet depth sort must be computed from.
  79012. * By default, the active camera position.
  79013. * Used only when facet depth sort is enabled
  79014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79015. */
  79016. facetDepthSortFrom: Vector3;
  79017. /**
  79018. * gets a boolean indicating if facetData is enabled
  79019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79020. */
  79021. readonly isFacetDataEnabled: boolean;
  79022. /** @hidden */
  79023. _updateNonUniformScalingState(value: boolean): boolean;
  79024. /**
  79025. * An event triggered when this mesh collides with another one
  79026. */
  79027. onCollideObservable: Observable<AbstractMesh>;
  79028. private _onCollideObserver;
  79029. /** Set a function to call when this mesh collides with another one */
  79030. onCollide: () => void;
  79031. /**
  79032. * An event triggered when the collision's position changes
  79033. */
  79034. onCollisionPositionChangeObservable: Observable<Vector3>;
  79035. private _onCollisionPositionChangeObserver;
  79036. /** Set a function to call when the collision's position changes */
  79037. onCollisionPositionChange: () => void;
  79038. /**
  79039. * An event triggered when material is changed
  79040. */
  79041. onMaterialChangedObservable: Observable<AbstractMesh>;
  79042. /**
  79043. * Gets or sets the orientation for POV movement & rotation
  79044. */
  79045. definedFacingForward: boolean;
  79046. /** @hidden */
  79047. _occlusionQuery: Nullable<WebGLQuery>;
  79048. private _visibility;
  79049. /**
  79050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79051. */
  79052. /**
  79053. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79054. */
  79055. visibility: number;
  79056. /** Gets or sets the alpha index used to sort transparent meshes
  79057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79058. */
  79059. alphaIndex: number;
  79060. /**
  79061. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79062. */
  79063. isVisible: boolean;
  79064. /**
  79065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79066. */
  79067. isPickable: boolean;
  79068. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79069. showSubMeshesBoundingBox: boolean;
  79070. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79071. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79072. */
  79073. isBlocker: boolean;
  79074. /**
  79075. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79076. */
  79077. enablePointerMoveEvents: boolean;
  79078. /**
  79079. * Specifies the rendering group id for this mesh (0 by default)
  79080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79081. */
  79082. renderingGroupId: number;
  79083. private _material;
  79084. /** Gets or sets current material */
  79085. material: Nullable<Material>;
  79086. private _receiveShadows;
  79087. /**
  79088. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79089. * @see http://doc.babylonjs.com/babylon101/shadows
  79090. */
  79091. receiveShadows: boolean;
  79092. /** Defines color to use when rendering outline */
  79093. outlineColor: Color3;
  79094. /** Define width to use when rendering outline */
  79095. outlineWidth: number;
  79096. /** Defines color to use when rendering overlay */
  79097. overlayColor: Color3;
  79098. /** Defines alpha to use when rendering overlay */
  79099. overlayAlpha: number;
  79100. private _hasVertexAlpha;
  79101. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79102. hasVertexAlpha: boolean;
  79103. private _useVertexColors;
  79104. /** 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) */
  79105. useVertexColors: boolean;
  79106. private _computeBonesUsingShaders;
  79107. /**
  79108. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79109. */
  79110. computeBonesUsingShaders: boolean;
  79111. private _numBoneInfluencers;
  79112. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79113. numBoneInfluencers: number;
  79114. private _applyFog;
  79115. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79116. applyFog: boolean;
  79117. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79118. useOctreeForRenderingSelection: boolean;
  79119. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79120. useOctreeForPicking: boolean;
  79121. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79122. useOctreeForCollisions: boolean;
  79123. private _layerMask;
  79124. /**
  79125. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79126. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79127. */
  79128. layerMask: number;
  79129. /**
  79130. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79131. */
  79132. alwaysSelectAsActiveMesh: boolean;
  79133. /**
  79134. * Gets or sets the current action manager
  79135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79136. */
  79137. actionManager: Nullable<AbstractActionManager>;
  79138. private _checkCollisions;
  79139. private _collisionMask;
  79140. private _collisionGroup;
  79141. /**
  79142. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79144. */
  79145. ellipsoid: Vector3;
  79146. /**
  79147. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79149. */
  79150. ellipsoidOffset: Vector3;
  79151. private _collider;
  79152. private _oldPositionForCollisions;
  79153. private _diffPositionForCollisions;
  79154. /**
  79155. * Gets or sets a collision mask used to mask collisions (default is -1).
  79156. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79157. */
  79158. collisionMask: number;
  79159. /**
  79160. * Gets or sets the current collision group mask (-1 by default).
  79161. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79162. */
  79163. collisionGroup: number;
  79164. /**
  79165. * Defines edge width used when edgesRenderer is enabled
  79166. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79167. */
  79168. edgesWidth: number;
  79169. /**
  79170. * Defines edge color used when edgesRenderer is enabled
  79171. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79172. */
  79173. edgesColor: Color4;
  79174. /** @hidden */
  79175. _edgesRenderer: Nullable<IEdgesRenderer>;
  79176. /** @hidden */
  79177. _masterMesh: Nullable<AbstractMesh>;
  79178. /** @hidden */
  79179. _boundingInfo: Nullable<BoundingInfo>;
  79180. /** @hidden */
  79181. _renderId: number;
  79182. /**
  79183. * Gets or sets the list of subMeshes
  79184. * @see http://doc.babylonjs.com/how_to/multi_materials
  79185. */
  79186. subMeshes: SubMesh[];
  79187. /** @hidden */
  79188. _intersectionsInProgress: AbstractMesh[];
  79189. /** @hidden */
  79190. _unIndexed: boolean;
  79191. /** @hidden */
  79192. _lightSources: Light[];
  79193. /** @hidden */
  79194. readonly _positions: Nullable<Vector3[]>;
  79195. /** @hidden */
  79196. _waitingActions: any;
  79197. /** @hidden */
  79198. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79199. private _skeleton;
  79200. /** @hidden */
  79201. _bonesTransformMatrices: Nullable<Float32Array>;
  79202. /**
  79203. * Gets or sets a skeleton to apply skining transformations
  79204. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79205. */
  79206. skeleton: Nullable<Skeleton>;
  79207. /**
  79208. * An event triggered when the mesh is rebuilt.
  79209. */
  79210. onRebuildObservable: Observable<AbstractMesh>;
  79211. /**
  79212. * Creates a new AbstractMesh
  79213. * @param name defines the name of the mesh
  79214. * @param scene defines the hosting scene
  79215. */
  79216. constructor(name: string, scene?: Nullable<Scene>);
  79217. /**
  79218. * Returns the string "AbstractMesh"
  79219. * @returns "AbstractMesh"
  79220. */
  79221. getClassName(): string;
  79222. /**
  79223. * Gets a string representation of the current mesh
  79224. * @param fullDetails defines a boolean indicating if full details must be included
  79225. * @returns a string representation of the current mesh
  79226. */
  79227. toString(fullDetails?: boolean): string;
  79228. /** @hidden */
  79229. _rebuild(): void;
  79230. /** @hidden */
  79231. _resyncLightSources(): void;
  79232. /** @hidden */
  79233. _resyncLighSource(light: Light): void;
  79234. /** @hidden */
  79235. _unBindEffect(): void;
  79236. /** @hidden */
  79237. _removeLightSource(light: Light): void;
  79238. private _markSubMeshesAsDirty;
  79239. /** @hidden */
  79240. _markSubMeshesAsLightDirty(): void;
  79241. /** @hidden */
  79242. _markSubMeshesAsAttributesDirty(): void;
  79243. /** @hidden */
  79244. _markSubMeshesAsMiscDirty(): void;
  79245. /**
  79246. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79247. */
  79248. scaling: Vector3;
  79249. /**
  79250. * Returns true if the mesh is blocked. Implemented by child classes
  79251. */
  79252. readonly isBlocked: boolean;
  79253. /**
  79254. * Returns the mesh itself by default. Implemented by child classes
  79255. * @param camera defines the camera to use to pick the right LOD level
  79256. * @returns the currentAbstractMesh
  79257. */
  79258. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79259. /**
  79260. * Returns 0 by default. Implemented by child classes
  79261. * @returns an integer
  79262. */
  79263. getTotalVertices(): number;
  79264. /**
  79265. * Returns a positive integer : the total number of indices in this mesh geometry.
  79266. * @returns the numner of indices or zero if the mesh has no geometry.
  79267. */
  79268. getTotalIndices(): number;
  79269. /**
  79270. * Returns null by default. Implemented by child classes
  79271. * @returns null
  79272. */
  79273. getIndices(): Nullable<IndicesArray>;
  79274. /**
  79275. * Returns the array of the requested vertex data kind. Implemented by child classes
  79276. * @param kind defines the vertex data kind to use
  79277. * @returns null
  79278. */
  79279. getVerticesData(kind: string): Nullable<FloatArray>;
  79280. /**
  79281. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79282. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79283. * Note that a new underlying VertexBuffer object is created each call.
  79284. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79285. * @param kind defines vertex data kind:
  79286. * * VertexBuffer.PositionKind
  79287. * * VertexBuffer.UVKind
  79288. * * VertexBuffer.UV2Kind
  79289. * * VertexBuffer.UV3Kind
  79290. * * VertexBuffer.UV4Kind
  79291. * * VertexBuffer.UV5Kind
  79292. * * VertexBuffer.UV6Kind
  79293. * * VertexBuffer.ColorKind
  79294. * * VertexBuffer.MatricesIndicesKind
  79295. * * VertexBuffer.MatricesIndicesExtraKind
  79296. * * VertexBuffer.MatricesWeightsKind
  79297. * * VertexBuffer.MatricesWeightsExtraKind
  79298. * @param data defines the data source
  79299. * @param updatable defines if the data must be flagged as updatable (or static)
  79300. * @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
  79301. * @returns the current mesh
  79302. */
  79303. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79304. /**
  79305. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79306. * If the mesh has no geometry, it is simply returned as it is.
  79307. * @param kind defines vertex data kind:
  79308. * * VertexBuffer.PositionKind
  79309. * * VertexBuffer.UVKind
  79310. * * VertexBuffer.UV2Kind
  79311. * * VertexBuffer.UV3Kind
  79312. * * VertexBuffer.UV4Kind
  79313. * * VertexBuffer.UV5Kind
  79314. * * VertexBuffer.UV6Kind
  79315. * * VertexBuffer.ColorKind
  79316. * * VertexBuffer.MatricesIndicesKind
  79317. * * VertexBuffer.MatricesIndicesExtraKind
  79318. * * VertexBuffer.MatricesWeightsKind
  79319. * * VertexBuffer.MatricesWeightsExtraKind
  79320. * @param data defines the data source
  79321. * @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
  79322. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79323. * @returns the current mesh
  79324. */
  79325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79326. /**
  79327. * Sets the mesh indices,
  79328. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79329. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79330. * @param totalVertices Defines the total number of vertices
  79331. * @returns the current mesh
  79332. */
  79333. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79334. /**
  79335. * Gets a boolean indicating if specific vertex data is present
  79336. * @param kind defines the vertex data kind to use
  79337. * @returns true is data kind is present
  79338. */
  79339. isVerticesDataPresent(kind: string): boolean;
  79340. /**
  79341. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79342. * @returns a BoundingInfo
  79343. */
  79344. getBoundingInfo(): BoundingInfo;
  79345. /**
  79346. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79347. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79348. * @returns the current mesh
  79349. */
  79350. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79351. /**
  79352. * Overwrite the current bounding info
  79353. * @param boundingInfo defines the new bounding info
  79354. * @returns the current mesh
  79355. */
  79356. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79357. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79358. readonly useBones: boolean;
  79359. /** @hidden */
  79360. _preActivate(): void;
  79361. /** @hidden */
  79362. _preActivateForIntermediateRendering(renderId: number): void;
  79363. /** @hidden */
  79364. _activate(renderId: number): void;
  79365. /**
  79366. * Gets the current world matrix
  79367. * @returns a Matrix
  79368. */
  79369. getWorldMatrix(): Matrix;
  79370. /** @hidden */
  79371. _getWorldMatrixDeterminant(): number;
  79372. /**
  79373. * Perform relative position change from the point of view of behind the front of the mesh.
  79374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79375. * Supports definition of mesh facing forward or backward
  79376. * @param amountRight defines the distance on the right axis
  79377. * @param amountUp defines the distance on the up axis
  79378. * @param amountForward defines the distance on the forward axis
  79379. * @returns the current mesh
  79380. */
  79381. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79382. /**
  79383. * Calculate relative position change from the point of view of behind the front of the mesh.
  79384. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79385. * Supports definition of mesh facing forward or backward
  79386. * @param amountRight defines the distance on the right axis
  79387. * @param amountUp defines the distance on the up axis
  79388. * @param amountForward defines the distance on the forward axis
  79389. * @returns the new displacement vector
  79390. */
  79391. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79392. /**
  79393. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79394. * Supports definition of mesh facing forward or backward
  79395. * @param flipBack defines the flip
  79396. * @param twirlClockwise defines the twirl
  79397. * @param tiltRight defines the tilt
  79398. * @returns the current mesh
  79399. */
  79400. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79401. /**
  79402. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79403. * Supports definition of mesh facing forward or backward.
  79404. * @param flipBack defines the flip
  79405. * @param twirlClockwise defines the twirl
  79406. * @param tiltRight defines the tilt
  79407. * @returns the new rotation vector
  79408. */
  79409. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79410. /**
  79411. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79412. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79413. * @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
  79414. * @returns the new bounding vectors
  79415. */
  79416. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79417. min: Vector3;
  79418. max: Vector3;
  79419. };
  79420. /**
  79421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79422. * This means the mesh underlying bounding box and sphere are recomputed.
  79423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79424. * @returns the current mesh
  79425. */
  79426. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79427. /** @hidden */
  79428. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79429. /** @hidden */
  79430. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79431. /** @hidden */
  79432. _updateBoundingInfo(): AbstractMesh;
  79433. /** @hidden */
  79434. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79435. /** @hidden */
  79436. protected _afterComputeWorldMatrix(): void;
  79437. /**
  79438. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79439. * A mesh is in the frustum if its bounding box intersects the frustum
  79440. * @param frustumPlanes defines the frustum to test
  79441. * @returns true if the mesh is in the frustum planes
  79442. */
  79443. isInFrustum(frustumPlanes: Plane[]): boolean;
  79444. /**
  79445. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79446. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79447. * @param frustumPlanes defines the frustum to test
  79448. * @returns true if the mesh is completely in the frustum planes
  79449. */
  79450. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79451. /**
  79452. * True if the mesh intersects another mesh or a SolidParticle object
  79453. * @param mesh defines a target mesh or SolidParticle to test
  79454. * @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)
  79455. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79456. * @returns true if there is an intersection
  79457. */
  79458. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79459. /**
  79460. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79461. * @param point defines the point to test
  79462. * @returns true if there is an intersection
  79463. */
  79464. intersectsPoint(point: Vector3): boolean;
  79465. /**
  79466. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79468. */
  79469. checkCollisions: boolean;
  79470. /**
  79471. * Gets Collider object used to compute collisions (not physics)
  79472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79473. */
  79474. readonly collider: Collider;
  79475. /**
  79476. * Move the mesh using collision engine
  79477. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79478. * @param displacement defines the requested displacement vector
  79479. * @returns the current mesh
  79480. */
  79481. moveWithCollisions(displacement: Vector3): AbstractMesh;
  79482. private _onCollisionPositionChange;
  79483. /** @hidden */
  79484. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  79485. /** @hidden */
  79486. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  79487. /** @hidden */
  79488. _checkCollision(collider: Collider): AbstractMesh;
  79489. /** @hidden */
  79490. _generatePointsArray(): boolean;
  79491. /**
  79492. * Checks if the passed Ray intersects with the mesh
  79493. * @param ray defines the ray to use
  79494. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79495. * @returns the picking info
  79496. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79497. */
  79498. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  79499. /**
  79500. * Clones the current mesh
  79501. * @param name defines the mesh name
  79502. * @param newParent defines the new mesh parent
  79503. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79504. * @returns the new mesh
  79505. */
  79506. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  79507. /**
  79508. * Disposes all the submeshes of the current meshnp
  79509. * @returns the current mesh
  79510. */
  79511. releaseSubMeshes(): AbstractMesh;
  79512. /**
  79513. * Releases resources associated with this abstract mesh.
  79514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79516. */
  79517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79518. /**
  79519. * Adds the passed mesh as a child to the current mesh
  79520. * @param mesh defines the child mesh
  79521. * @returns the current mesh
  79522. */
  79523. addChild(mesh: AbstractMesh): AbstractMesh;
  79524. /**
  79525. * Removes the passed mesh from the current mesh children list
  79526. * @param mesh defines the child mesh
  79527. * @returns the current mesh
  79528. */
  79529. removeChild(mesh: AbstractMesh): AbstractMesh;
  79530. /** @hidden */
  79531. private _initFacetData;
  79532. /**
  79533. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79534. * This method can be called within the render loop.
  79535. * 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
  79536. * @returns the current mesh
  79537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79538. */
  79539. updateFacetData(): AbstractMesh;
  79540. /**
  79541. * Returns the facetLocalNormals array.
  79542. * The normals are expressed in the mesh local spac
  79543. * @returns an array of Vector3
  79544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79545. */
  79546. getFacetLocalNormals(): Vector3[];
  79547. /**
  79548. * Returns the facetLocalPositions array.
  79549. * The facet positions are expressed in the mesh local space
  79550. * @returns an array of Vector3
  79551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79552. */
  79553. getFacetLocalPositions(): Vector3[];
  79554. /**
  79555. * Returns the facetLocalPartioning array
  79556. * @returns an array of array of numbers
  79557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79558. */
  79559. getFacetLocalPartitioning(): number[][];
  79560. /**
  79561. * Returns the i-th facet position in the world system.
  79562. * This method allocates a new Vector3 per call
  79563. * @param i defines the facet index
  79564. * @returns a new Vector3
  79565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79566. */
  79567. getFacetPosition(i: number): Vector3;
  79568. /**
  79569. * Sets the reference Vector3 with the i-th facet position in the world system
  79570. * @param i defines the facet index
  79571. * @param ref defines the target vector
  79572. * @returns the current mesh
  79573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79574. */
  79575. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  79576. /**
  79577. * Returns the i-th facet normal in the world system.
  79578. * This method allocates a new Vector3 per call
  79579. * @param i defines the facet index
  79580. * @returns a new Vector3
  79581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79582. */
  79583. getFacetNormal(i: number): Vector3;
  79584. /**
  79585. * Sets the reference Vector3 with the i-th facet normal in the world system
  79586. * @param i defines the facet index
  79587. * @param ref defines the target vector
  79588. * @returns the current mesh
  79589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79590. */
  79591. getFacetNormalToRef(i: number, ref: Vector3): this;
  79592. /**
  79593. * 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)
  79594. * @param x defines x coordinate
  79595. * @param y defines y coordinate
  79596. * @param z defines z coordinate
  79597. * @returns the array of facet indexes
  79598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79599. */
  79600. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  79601. /**
  79602. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79603. * @param projected sets as the (x,y,z) world projection on the facet
  79604. * @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
  79605. * @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
  79606. * @param x defines x coordinate
  79607. * @param y defines y coordinate
  79608. * @param z defines z coordinate
  79609. * @returns the face index if found (or null instead)
  79610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79611. */
  79612. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79613. /**
  79614. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79615. * @param projected sets as the (x,y,z) local projection on the facet
  79616. * @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
  79617. * @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
  79618. * @param x defines x coordinate
  79619. * @param y defines y coordinate
  79620. * @param z defines z coordinate
  79621. * @returns the face index if found (or null instead)
  79622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79623. */
  79624. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79625. /**
  79626. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79627. * @returns the parameters
  79628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79629. */
  79630. getFacetDataParameters(): any;
  79631. /**
  79632. * Disables the feature FacetData and frees the related memory
  79633. * @returns the current mesh
  79634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79635. */
  79636. disableFacetData(): AbstractMesh;
  79637. /**
  79638. * Updates the AbstractMesh indices array
  79639. * @param indices defines the data source
  79640. * @returns the current mesh
  79641. */
  79642. updateIndices(indices: IndicesArray): AbstractMesh;
  79643. /**
  79644. * Creates new normals data for the mesh
  79645. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79646. * @returns the current mesh
  79647. */
  79648. createNormals(updatable: boolean): AbstractMesh;
  79649. /**
  79650. * Align the mesh with a normal
  79651. * @param normal defines the normal to use
  79652. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79653. * @returns the current mesh
  79654. */
  79655. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  79656. /** @hidden */
  79657. _checkOcclusionQuery(): boolean;
  79658. }
  79659. }
  79660. declare module BABYLON {
  79661. /**
  79662. * Class used to handle skinning animations
  79663. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79664. */
  79665. export class Skeleton implements IAnimatable {
  79666. /** defines the skeleton name */
  79667. name: string;
  79668. /** defines the skeleton Id */
  79669. id: string;
  79670. /**
  79671. * Defines the list of child bones
  79672. */
  79673. bones: Bone[];
  79674. /**
  79675. * Defines an estimate of the dimension of the skeleton at rest
  79676. */
  79677. dimensionsAtRest: Vector3;
  79678. /**
  79679. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79680. */
  79681. needInitialSkinMatrix: boolean;
  79682. /**
  79683. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79684. */
  79685. overrideMesh: Nullable<AbstractMesh>;
  79686. /**
  79687. * Gets the list of animations attached to this skeleton
  79688. */
  79689. animations: Array<Animation>;
  79690. private _scene;
  79691. private _isDirty;
  79692. private _transformMatrices;
  79693. private _transformMatrixTexture;
  79694. private _meshesWithPoseMatrix;
  79695. private _animatables;
  79696. private _identity;
  79697. private _synchronizedWithMesh;
  79698. private _ranges;
  79699. private _lastAbsoluteTransformsUpdateId;
  79700. private _canUseTextureForBones;
  79701. /** @hidden */
  79702. _numBonesWithLinkedTransformNode: number;
  79703. /**
  79704. * Specifies if the skeleton should be serialized
  79705. */
  79706. doNotSerialize: boolean;
  79707. /**
  79708. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79709. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79710. */
  79711. useTextureToStoreBoneMatrices: boolean;
  79712. private _animationPropertiesOverride;
  79713. /**
  79714. * Gets or sets the animation properties override
  79715. */
  79716. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79717. /**
  79718. * An observable triggered before computing the skeleton's matrices
  79719. */
  79720. onBeforeComputeObservable: Observable<Skeleton>;
  79721. /**
  79722. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79723. */
  79724. readonly isUsingTextureForMatrices: boolean;
  79725. /**
  79726. * Creates a new skeleton
  79727. * @param name defines the skeleton name
  79728. * @param id defines the skeleton Id
  79729. * @param scene defines the hosting scene
  79730. */
  79731. constructor(
  79732. /** defines the skeleton name */
  79733. name: string,
  79734. /** defines the skeleton Id */
  79735. id: string, scene: Scene);
  79736. /**
  79737. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79738. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79739. * @returns a Float32Array containing matrices data
  79740. */
  79741. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79742. /**
  79743. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79744. * @returns a raw texture containing the data
  79745. */
  79746. getTransformMatrixTexture(): Nullable<RawTexture>;
  79747. /**
  79748. * Gets the current hosting scene
  79749. * @returns a scene object
  79750. */
  79751. getScene(): Scene;
  79752. /**
  79753. * Gets a string representing the current skeleton data
  79754. * @param fullDetails defines a boolean indicating if we want a verbose version
  79755. * @returns a string representing the current skeleton data
  79756. */
  79757. toString(fullDetails?: boolean): string;
  79758. /**
  79759. * Get bone's index searching by name
  79760. * @param name defines bone's name to search for
  79761. * @return the indice of the bone. Returns -1 if not found
  79762. */
  79763. getBoneIndexByName(name: string): number;
  79764. /**
  79765. * Creater a new animation range
  79766. * @param name defines the name of the range
  79767. * @param from defines the start key
  79768. * @param to defines the end key
  79769. */
  79770. createAnimationRange(name: string, from: number, to: number): void;
  79771. /**
  79772. * Delete a specific animation range
  79773. * @param name defines the name of the range
  79774. * @param deleteFrames defines if frames must be removed as well
  79775. */
  79776. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79777. /**
  79778. * Gets a specific animation range
  79779. * @param name defines the name of the range to look for
  79780. * @returns the requested animation range or null if not found
  79781. */
  79782. getAnimationRange(name: string): Nullable<AnimationRange>;
  79783. /**
  79784. * Gets the list of all animation ranges defined on this skeleton
  79785. * @returns an array
  79786. */
  79787. getAnimationRanges(): Nullable<AnimationRange>[];
  79788. /**
  79789. * Copy animation range from a source skeleton.
  79790. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79791. * @param source defines the source skeleton
  79792. * @param name defines the name of the range to copy
  79793. * @param rescaleAsRequired defines if rescaling must be applied if required
  79794. * @returns true if operation was successful
  79795. */
  79796. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79797. /**
  79798. * Forces the skeleton to go to rest pose
  79799. */
  79800. returnToRest(): void;
  79801. private _getHighestAnimationFrame;
  79802. /**
  79803. * Begin a specific animation range
  79804. * @param name defines the name of the range to start
  79805. * @param loop defines if looping must be turned on (false by default)
  79806. * @param speedRatio defines the speed ratio to apply (1 by default)
  79807. * @param onAnimationEnd defines a callback which will be called when animation will end
  79808. * @returns a new animatable
  79809. */
  79810. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79811. /** @hidden */
  79812. _markAsDirty(): void;
  79813. /** @hidden */
  79814. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79815. /** @hidden */
  79816. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79817. private _computeTransformMatrices;
  79818. /**
  79819. * Build all resources required to render a skeleton
  79820. */
  79821. prepare(): void;
  79822. /**
  79823. * Gets the list of animatables currently running for this skeleton
  79824. * @returns an array of animatables
  79825. */
  79826. getAnimatables(): IAnimatable[];
  79827. /**
  79828. * Clone the current skeleton
  79829. * @param name defines the name of the new skeleton
  79830. * @param id defines the id of the enw skeleton
  79831. * @returns the new skeleton
  79832. */
  79833. clone(name: string, id: string): Skeleton;
  79834. /**
  79835. * Enable animation blending for this skeleton
  79836. * @param blendingSpeed defines the blending speed to apply
  79837. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79838. */
  79839. enableBlending(blendingSpeed?: number): void;
  79840. /**
  79841. * Releases all resources associated with the current skeleton
  79842. */
  79843. dispose(): void;
  79844. /**
  79845. * Serialize the skeleton in a JSON object
  79846. * @returns a JSON object
  79847. */
  79848. serialize(): any;
  79849. /**
  79850. * Creates a new skeleton from serialized data
  79851. * @param parsedSkeleton defines the serialized data
  79852. * @param scene defines the hosting scene
  79853. * @returns a new skeleton
  79854. */
  79855. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79856. /**
  79857. * Compute all node absolute transforms
  79858. * @param forceUpdate defines if computation must be done even if cache is up to date
  79859. */
  79860. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79861. /**
  79862. * Gets the root pose matrix
  79863. * @returns a matrix
  79864. */
  79865. getPoseMatrix(): Nullable<Matrix>;
  79866. /**
  79867. * Sorts bones per internal index
  79868. */
  79869. sortBones(): void;
  79870. private _sortBones;
  79871. }
  79872. }
  79873. declare module BABYLON {
  79874. /**
  79875. * Class used to store bone information
  79876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79877. */
  79878. export class Bone extends Node {
  79879. /**
  79880. * defines the bone name
  79881. */
  79882. name: string;
  79883. private static _tmpVecs;
  79884. private static _tmpQuat;
  79885. private static _tmpMats;
  79886. /**
  79887. * Gets the list of child bones
  79888. */
  79889. children: Bone[];
  79890. /** Gets the animations associated with this bone */
  79891. animations: Animation[];
  79892. /**
  79893. * Gets or sets bone length
  79894. */
  79895. length: number;
  79896. /**
  79897. * @hidden Internal only
  79898. * Set this value to map this bone to a different index in the transform matrices
  79899. * Set this value to -1 to exclude the bone from the transform matrices
  79900. */
  79901. _index: Nullable<number>;
  79902. private _skeleton;
  79903. private _localMatrix;
  79904. private _restPose;
  79905. private _baseMatrix;
  79906. private _absoluteTransform;
  79907. private _invertedAbsoluteTransform;
  79908. private _parent;
  79909. private _scalingDeterminant;
  79910. private _worldTransform;
  79911. private _localScaling;
  79912. private _localRotation;
  79913. private _localPosition;
  79914. private _needToDecompose;
  79915. private _needToCompose;
  79916. /** @hidden */
  79917. _linkedTransformNode: Nullable<TransformNode>;
  79918. /** @hidden */
  79919. /** @hidden */
  79920. _matrix: Matrix;
  79921. /**
  79922. * Create a new bone
  79923. * @param name defines the bone name
  79924. * @param skeleton defines the parent skeleton
  79925. * @param parentBone defines the parent (can be null if the bone is the root)
  79926. * @param localMatrix defines the local matrix
  79927. * @param restPose defines the rest pose matrix
  79928. * @param baseMatrix defines the base matrix
  79929. * @param index defines index of the bone in the hiearchy
  79930. */
  79931. constructor(
  79932. /**
  79933. * defines the bone name
  79934. */
  79935. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79936. /**
  79937. * Gets the parent skeleton
  79938. * @returns a skeleton
  79939. */
  79940. getSkeleton(): Skeleton;
  79941. /**
  79942. * Gets parent bone
  79943. * @returns a bone or null if the bone is the root of the bone hierarchy
  79944. */
  79945. getParent(): Nullable<Bone>;
  79946. /**
  79947. * Sets the parent bone
  79948. * @param parent defines the parent (can be null if the bone is the root)
  79949. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79950. */
  79951. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79952. /**
  79953. * Gets the local matrix
  79954. * @returns a matrix
  79955. */
  79956. getLocalMatrix(): Matrix;
  79957. /**
  79958. * Gets the base matrix (initial matrix which remains unchanged)
  79959. * @returns a matrix
  79960. */
  79961. getBaseMatrix(): Matrix;
  79962. /**
  79963. * Gets the rest pose matrix
  79964. * @returns a matrix
  79965. */
  79966. getRestPose(): Matrix;
  79967. /**
  79968. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79969. */
  79970. getWorldMatrix(): Matrix;
  79971. /**
  79972. * Sets the local matrix to rest pose matrix
  79973. */
  79974. returnToRest(): void;
  79975. /**
  79976. * Gets the inverse of the absolute transform matrix.
  79977. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79978. * @returns a matrix
  79979. */
  79980. getInvertedAbsoluteTransform(): Matrix;
  79981. /**
  79982. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79983. * @returns a matrix
  79984. */
  79985. getAbsoluteTransform(): Matrix;
  79986. /**
  79987. * Links with the given transform node.
  79988. * The local matrix of this bone is copied from the transform node every frame.
  79989. * @param transformNode defines the transform node to link to
  79990. */
  79991. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79992. /** Gets or sets current position (in local space) */
  79993. position: Vector3;
  79994. /** Gets or sets current rotation (in local space) */
  79995. rotation: Vector3;
  79996. /** Gets or sets current rotation quaternion (in local space) */
  79997. rotationQuaternion: Quaternion;
  79998. /** Gets or sets current scaling (in local space) */
  79999. scaling: Vector3;
  80000. /**
  80001. * Gets the animation properties override
  80002. */
  80003. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80004. private _decompose;
  80005. private _compose;
  80006. /**
  80007. * Update the base and local matrices
  80008. * @param matrix defines the new base or local matrix
  80009. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80010. * @param updateLocalMatrix defines if the local matrix should be updated
  80011. */
  80012. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80013. /** @hidden */
  80014. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80015. /**
  80016. * Flag the bone as dirty (Forcing it to update everything)
  80017. */
  80018. markAsDirty(): void;
  80019. private _markAsDirtyAndCompose;
  80020. private _markAsDirtyAndDecompose;
  80021. /**
  80022. * Translate the bone in local or world space
  80023. * @param vec The amount to translate the bone
  80024. * @param space The space that the translation is in
  80025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80026. */
  80027. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80028. /**
  80029. * Set the postion of the bone in local or world space
  80030. * @param position The position to set the bone
  80031. * @param space The space that the position is in
  80032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80033. */
  80034. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80035. /**
  80036. * Set the absolute position of the bone (world space)
  80037. * @param position The position to set the bone
  80038. * @param mesh The mesh that this bone is attached to
  80039. */
  80040. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80041. /**
  80042. * Scale the bone on the x, y and z axes (in local space)
  80043. * @param x The amount to scale the bone on the x axis
  80044. * @param y The amount to scale the bone on the y axis
  80045. * @param z The amount to scale the bone on the z axis
  80046. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80047. */
  80048. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80049. /**
  80050. * Set the bone scaling in local space
  80051. * @param scale defines the scaling vector
  80052. */
  80053. setScale(scale: Vector3): void;
  80054. /**
  80055. * Gets the current scaling in local space
  80056. * @returns the current scaling vector
  80057. */
  80058. getScale(): Vector3;
  80059. /**
  80060. * Gets the current scaling in local space and stores it in a target vector
  80061. * @param result defines the target vector
  80062. */
  80063. getScaleToRef(result: Vector3): void;
  80064. /**
  80065. * Set the yaw, pitch, and roll of the bone in local or world space
  80066. * @param yaw The rotation of the bone on the y axis
  80067. * @param pitch The rotation of the bone on the x axis
  80068. * @param roll The rotation of the bone on the z axis
  80069. * @param space The space that the axes of rotation are in
  80070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80071. */
  80072. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80073. /**
  80074. * Add a rotation to the bone on an axis in local or world space
  80075. * @param axis The axis to rotate the bone on
  80076. * @param amount The amount to rotate the bone
  80077. * @param space The space that the axis is in
  80078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80079. */
  80080. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80081. /**
  80082. * Set the rotation of the bone to a particular axis angle in local or world space
  80083. * @param axis The axis to rotate the bone on
  80084. * @param angle The angle that the bone should be rotated to
  80085. * @param space The space that the axis is in
  80086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80087. */
  80088. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80089. /**
  80090. * Set the euler rotation of the bone in local of world space
  80091. * @param rotation The euler rotation that the bone should be set to
  80092. * @param space The space that the rotation is in
  80093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80094. */
  80095. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80096. /**
  80097. * Set the quaternion rotation of the bone in local of world space
  80098. * @param quat The quaternion rotation that the bone should be set to
  80099. * @param space The space that the rotation is in
  80100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80101. */
  80102. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80103. /**
  80104. * Set the rotation matrix of the bone in local of world space
  80105. * @param rotMat The rotation matrix that the bone should be set to
  80106. * @param space The space that the rotation is in
  80107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80108. */
  80109. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80110. private _rotateWithMatrix;
  80111. private _getNegativeRotationToRef;
  80112. /**
  80113. * Get the position of the bone in local or world space
  80114. * @param space The space that the returned position is in
  80115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80116. * @returns The position of the bone
  80117. */
  80118. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80119. /**
  80120. * Copy the position of the bone to a vector3 in local or world space
  80121. * @param space The space that the returned position is in
  80122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80123. * @param result The vector3 to copy the position to
  80124. */
  80125. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80126. /**
  80127. * Get the absolute position of the bone (world space)
  80128. * @param mesh The mesh that this bone is attached to
  80129. * @returns The absolute position of the bone
  80130. */
  80131. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80132. /**
  80133. * Copy the absolute position of the bone (world space) to the result param
  80134. * @param mesh The mesh that this bone is attached to
  80135. * @param result The vector3 to copy the absolute position to
  80136. */
  80137. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80138. /**
  80139. * Compute the absolute transforms of this bone and its children
  80140. */
  80141. computeAbsoluteTransforms(): void;
  80142. /**
  80143. * Get the world direction from an axis that is in the local space of the bone
  80144. * @param localAxis The local direction that is used to compute the world direction
  80145. * @param mesh The mesh that this bone is attached to
  80146. * @returns The world direction
  80147. */
  80148. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80149. /**
  80150. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80151. * @param localAxis The local direction that is used to compute the world direction
  80152. * @param mesh The mesh that this bone is attached to
  80153. * @param result The vector3 that the world direction will be copied to
  80154. */
  80155. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80156. /**
  80157. * Get the euler rotation of the bone in local or world space
  80158. * @param space The space that the rotation should be in
  80159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80160. * @returns The euler rotation
  80161. */
  80162. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80163. /**
  80164. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80165. * @param space The space that the rotation should be in
  80166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80167. * @param result The vector3 that the rotation should be copied to
  80168. */
  80169. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80170. /**
  80171. * Get the quaternion rotation of the bone in either local or world space
  80172. * @param space The space that the rotation should be in
  80173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80174. * @returns The quaternion rotation
  80175. */
  80176. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80177. /**
  80178. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80179. * @param space The space that the rotation should be in
  80180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80181. * @param result The quaternion that the rotation should be copied to
  80182. */
  80183. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80184. /**
  80185. * Get the rotation matrix of the bone in local or world space
  80186. * @param space The space that the rotation should be in
  80187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80188. * @returns The rotation matrix
  80189. */
  80190. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80191. /**
  80192. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80193. * @param space The space that the rotation should be in
  80194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80195. * @param result The quaternion that the rotation should be copied to
  80196. */
  80197. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80198. /**
  80199. * Get the world position of a point that is in the local space of the bone
  80200. * @param position The local position
  80201. * @param mesh The mesh that this bone is attached to
  80202. * @returns The world position
  80203. */
  80204. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80205. /**
  80206. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80207. * @param position The local position
  80208. * @param mesh The mesh that this bone is attached to
  80209. * @param result The vector3 that the world position should be copied to
  80210. */
  80211. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80212. /**
  80213. * Get the local position of a point that is in world space
  80214. * @param position The world position
  80215. * @param mesh The mesh that this bone is attached to
  80216. * @returns The local position
  80217. */
  80218. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80219. /**
  80220. * Get the local position of a point that is in world space and copy it to the result param
  80221. * @param position The world position
  80222. * @param mesh The mesh that this bone is attached to
  80223. * @param result The vector3 that the local position should be copied to
  80224. */
  80225. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80226. }
  80227. }
  80228. declare module BABYLON {
  80229. /**
  80230. * Class used to store an actual running animation
  80231. */
  80232. export class Animatable {
  80233. /** defines the target object */
  80234. target: any;
  80235. /** defines the starting frame number (default is 0) */
  80236. fromFrame: number;
  80237. /** defines the ending frame number (default is 100) */
  80238. toFrame: number;
  80239. /** defines if the animation must loop (default is false) */
  80240. loopAnimation: boolean;
  80241. /** defines a callback to call when animation ends if it is not looping */
  80242. onAnimationEnd?: (() => void) | null | undefined;
  80243. /** defines a callback to call when animation loops */
  80244. onAnimationLoop?: (() => void) | null | undefined;
  80245. private _localDelayOffset;
  80246. private _pausedDelay;
  80247. private _runtimeAnimations;
  80248. private _paused;
  80249. private _scene;
  80250. private _speedRatio;
  80251. private _weight;
  80252. private _syncRoot;
  80253. /**
  80254. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80255. * This will only apply for non looping animation (default is true)
  80256. */
  80257. disposeOnEnd: boolean;
  80258. /**
  80259. * Gets a boolean indicating if the animation has started
  80260. */
  80261. animationStarted: boolean;
  80262. /**
  80263. * Observer raised when the animation ends
  80264. */
  80265. onAnimationEndObservable: Observable<Animatable>;
  80266. /**
  80267. * Observer raised when the animation loops
  80268. */
  80269. onAnimationLoopObservable: Observable<Animatable>;
  80270. /**
  80271. * Gets the root Animatable used to synchronize and normalize animations
  80272. */
  80273. readonly syncRoot: Animatable;
  80274. /**
  80275. * Gets the current frame of the first RuntimeAnimation
  80276. * Used to synchronize Animatables
  80277. */
  80278. readonly masterFrame: number;
  80279. /**
  80280. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80281. */
  80282. weight: number;
  80283. /**
  80284. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80285. */
  80286. speedRatio: number;
  80287. /**
  80288. * Creates a new Animatable
  80289. * @param scene defines the hosting scene
  80290. * @param target defines the target object
  80291. * @param fromFrame defines the starting frame number (default is 0)
  80292. * @param toFrame defines the ending frame number (default is 100)
  80293. * @param loopAnimation defines if the animation must loop (default is false)
  80294. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80295. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80296. * @param animations defines a group of animation to add to the new Animatable
  80297. * @param onAnimationLoop defines a callback to call when animation loops
  80298. */
  80299. constructor(scene: Scene,
  80300. /** defines the target object */
  80301. target: any,
  80302. /** defines the starting frame number (default is 0) */
  80303. fromFrame?: number,
  80304. /** defines the ending frame number (default is 100) */
  80305. toFrame?: number,
  80306. /** defines if the animation must loop (default is false) */
  80307. loopAnimation?: boolean, speedRatio?: number,
  80308. /** defines a callback to call when animation ends if it is not looping */
  80309. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80310. /** defines a callback to call when animation loops */
  80311. onAnimationLoop?: (() => void) | null | undefined);
  80312. /**
  80313. * Synchronize and normalize current Animatable with a source Animatable
  80314. * This is useful when using animation weights and when animations are not of the same length
  80315. * @param root defines the root Animatable to synchronize with
  80316. * @returns the current Animatable
  80317. */
  80318. syncWith(root: Animatable): Animatable;
  80319. /**
  80320. * Gets the list of runtime animations
  80321. * @returns an array of RuntimeAnimation
  80322. */
  80323. getAnimations(): RuntimeAnimation[];
  80324. /**
  80325. * Adds more animations to the current animatable
  80326. * @param target defines the target of the animations
  80327. * @param animations defines the new animations to add
  80328. */
  80329. appendAnimations(target: any, animations: Animation[]): void;
  80330. /**
  80331. * Gets the source animation for a specific property
  80332. * @param property defines the propertyu to look for
  80333. * @returns null or the source animation for the given property
  80334. */
  80335. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80336. /**
  80337. * Gets the runtime animation for a specific property
  80338. * @param property defines the propertyu to look for
  80339. * @returns null or the runtime animation for the given property
  80340. */
  80341. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80342. /**
  80343. * Resets the animatable to its original state
  80344. */
  80345. reset(): void;
  80346. /**
  80347. * Allows the animatable to blend with current running animations
  80348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80349. * @param blendingSpeed defines the blending speed to use
  80350. */
  80351. enableBlending(blendingSpeed: number): void;
  80352. /**
  80353. * Disable animation blending
  80354. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80355. */
  80356. disableBlending(): void;
  80357. /**
  80358. * Jump directly to a given frame
  80359. * @param frame defines the frame to jump to
  80360. */
  80361. goToFrame(frame: number): void;
  80362. /**
  80363. * Pause the animation
  80364. */
  80365. pause(): void;
  80366. /**
  80367. * Restart the animation
  80368. */
  80369. restart(): void;
  80370. private _raiseOnAnimationEnd;
  80371. /**
  80372. * Stop and delete the current animation
  80373. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80374. * @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)
  80375. */
  80376. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80377. /**
  80378. * Wait asynchronously for the animation to end
  80379. * @returns a promise which will be fullfilled when the animation ends
  80380. */
  80381. waitAsync(): Promise<Animatable>;
  80382. /** @hidden */
  80383. _animate(delay: number): boolean;
  80384. }
  80385. interface Scene {
  80386. /** @hidden */
  80387. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80388. /** @hidden */
  80389. _processLateAnimationBindingsForMatrices(holder: {
  80390. totalWeight: number;
  80391. animations: RuntimeAnimation[];
  80392. originalValue: Matrix;
  80393. }): any;
  80394. /** @hidden */
  80395. _processLateAnimationBindingsForQuaternions(holder: {
  80396. totalWeight: number;
  80397. animations: RuntimeAnimation[];
  80398. originalValue: Quaternion;
  80399. }, refQuaternion: Quaternion): Quaternion;
  80400. /** @hidden */
  80401. _processLateAnimationBindings(): void;
  80402. /**
  80403. * Will start the animation sequence of a given target
  80404. * @param target defines the target
  80405. * @param from defines from which frame should animation start
  80406. * @param to defines until which frame should animation run.
  80407. * @param weight defines the weight to apply to the animation (1.0 by default)
  80408. * @param loop defines if the animation loops
  80409. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80410. * @param onAnimationEnd defines the function to be executed when the animation ends
  80411. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80412. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80413. * @param onAnimationLoop defines the callback to call when an animation loops
  80414. * @returns the animatable object created for this animation
  80415. */
  80416. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80417. /**
  80418. * Will start the animation sequence of a given target
  80419. * @param target defines the target
  80420. * @param from defines from which frame should animation start
  80421. * @param to defines until which frame should animation run.
  80422. * @param loop defines if the animation loops
  80423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80424. * @param onAnimationEnd defines the function to be executed when the animation ends
  80425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80427. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80428. * @param onAnimationLoop defines the callback to call when an animation loops
  80429. * @returns the animatable object created for this animation
  80430. */
  80431. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80432. /**
  80433. * Will start the animation sequence of a given target and its hierarchy
  80434. * @param target defines the target
  80435. * @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.
  80436. * @param from defines from which frame should animation start
  80437. * @param to defines until which frame should animation run.
  80438. * @param loop defines if the animation loops
  80439. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80440. * @param onAnimationEnd defines the function to be executed when the animation ends
  80441. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80442. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80443. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80444. * @param onAnimationLoop defines the callback to call when an animation loops
  80445. * @returns the list of created animatables
  80446. */
  80447. 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[];
  80448. /**
  80449. * Begin a new animation on a given node
  80450. * @param target defines the target where the animation will take place
  80451. * @param animations defines the list of animations to start
  80452. * @param from defines the initial value
  80453. * @param to defines the final value
  80454. * @param loop defines if you want animation to loop (off by default)
  80455. * @param speedRatio defines the speed ratio to apply to all animations
  80456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80457. * @param onAnimationLoop defines the callback to call when an animation loops
  80458. * @returns the list of created animatables
  80459. */
  80460. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80461. /**
  80462. * Begin a new animation on a given node and its hierarchy
  80463. * @param target defines the root node where the animation will take place
  80464. * @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.
  80465. * @param animations defines the list of animations to start
  80466. * @param from defines the initial value
  80467. * @param to defines the final value
  80468. * @param loop defines if you want animation to loop (off by default)
  80469. * @param speedRatio defines the speed ratio to apply to all animations
  80470. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80471. * @param onAnimationLoop defines the callback to call when an animation loops
  80472. * @returns the list of animatables created for all nodes
  80473. */
  80474. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80475. /**
  80476. * Gets the animatable associated with a specific target
  80477. * @param target defines the target of the animatable
  80478. * @returns the required animatable if found
  80479. */
  80480. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80481. /**
  80482. * Gets all animatables associated with a given target
  80483. * @param target defines the target to look animatables for
  80484. * @returns an array of Animatables
  80485. */
  80486. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80487. /**
  80488. * Will stop the animation of the given target
  80489. * @param target - the target
  80490. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  80491. * @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)
  80492. */
  80493. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  80494. /**
  80495. * Stops and removes all animations that have been applied to the scene
  80496. */
  80497. stopAllAnimations(): void;
  80498. }
  80499. interface Bone {
  80500. /**
  80501. * Copy an animation range from another bone
  80502. * @param source defines the source bone
  80503. * @param rangeName defines the range name to copy
  80504. * @param frameOffset defines the frame offset
  80505. * @param rescaleAsRequired defines if rescaling must be applied if required
  80506. * @param skelDimensionsRatio defines the scaling ratio
  80507. * @returns true if operation was successful
  80508. */
  80509. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80510. }
  80511. }
  80512. declare module BABYLON {
  80513. /**
  80514. * Defines how a node can be built from a string name.
  80515. */
  80516. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80517. /**
  80518. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80519. */
  80520. export class Node implements IBehaviorAware<Node> {
  80521. /** @hidden */
  80522. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80523. private static _NodeConstructors;
  80524. /**
  80525. * Add a new node constructor
  80526. * @param type defines the type name of the node to construct
  80527. * @param constructorFunc defines the constructor function
  80528. */
  80529. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80530. /**
  80531. * Returns a node constructor based on type name
  80532. * @param type defines the type name
  80533. * @param name defines the new node name
  80534. * @param scene defines the hosting scene
  80535. * @param options defines optional options to transmit to constructors
  80536. * @returns the new constructor or null
  80537. */
  80538. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80539. /**
  80540. * Gets or sets the name of the node
  80541. */
  80542. name: string;
  80543. /**
  80544. * Gets or sets the id of the node
  80545. */
  80546. id: string;
  80547. /**
  80548. * Gets or sets the unique id of the node
  80549. */
  80550. uniqueId: number;
  80551. /**
  80552. * Gets or sets a string used to store user defined state for the node
  80553. */
  80554. state: string;
  80555. /**
  80556. * Gets or sets an object used to store user defined information for the node
  80557. */
  80558. metadata: any;
  80559. /**
  80560. * For internal use only. Please do not use.
  80561. */
  80562. reservedDataStore: any;
  80563. /**
  80564. * Gets or sets a boolean used to define if the node must be serialized
  80565. */
  80566. doNotSerialize: boolean;
  80567. /** @hidden */
  80568. _isDisposed: boolean;
  80569. /**
  80570. * Gets a list of Animations associated with the node
  80571. */
  80572. animations: Animation[];
  80573. protected _ranges: {
  80574. [name: string]: Nullable<AnimationRange>;
  80575. };
  80576. /**
  80577. * Callback raised when the node is ready to be used
  80578. */
  80579. onReady: (node: Node) => void;
  80580. private _isEnabled;
  80581. private _isParentEnabled;
  80582. private _isReady;
  80583. /** @hidden */
  80584. _currentRenderId: number;
  80585. private _parentRenderId;
  80586. protected _childRenderId: number;
  80587. /** @hidden */
  80588. _waitingParentId: Nullable<string>;
  80589. /** @hidden */
  80590. _scene: Scene;
  80591. /** @hidden */
  80592. _cache: any;
  80593. private _parentNode;
  80594. private _children;
  80595. /** @hidden */
  80596. _worldMatrix: Matrix;
  80597. /** @hidden */
  80598. _worldMatrixDeterminant: number;
  80599. /** @hidden */
  80600. private _sceneRootNodesIndex;
  80601. /**
  80602. * Gets a boolean indicating if the node has been disposed
  80603. * @returns true if the node was disposed
  80604. */
  80605. isDisposed(): boolean;
  80606. /**
  80607. * Gets or sets the parent of the node
  80608. */
  80609. parent: Nullable<Node>;
  80610. private addToSceneRootNodes;
  80611. private removeFromSceneRootNodes;
  80612. private _animationPropertiesOverride;
  80613. /**
  80614. * Gets or sets the animation properties override
  80615. */
  80616. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80617. /**
  80618. * Gets a string idenfifying the name of the class
  80619. * @returns "Node" string
  80620. */
  80621. getClassName(): string;
  80622. /** @hidden */
  80623. readonly _isNode: boolean;
  80624. /**
  80625. * An event triggered when the mesh is disposed
  80626. */
  80627. onDisposeObservable: Observable<Node>;
  80628. private _onDisposeObserver;
  80629. /**
  80630. * Sets a callback that will be raised when the node will be disposed
  80631. */
  80632. onDispose: () => void;
  80633. /**
  80634. * Creates a new Node
  80635. * @param name the name and id to be given to this node
  80636. * @param scene the scene this node will be added to
  80637. * @param addToRootNodes the node will be added to scene.rootNodes
  80638. */
  80639. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80640. /**
  80641. * Gets the scene of the node
  80642. * @returns a scene
  80643. */
  80644. getScene(): Scene;
  80645. /**
  80646. * Gets the engine of the node
  80647. * @returns a Engine
  80648. */
  80649. getEngine(): Engine;
  80650. private _behaviors;
  80651. /**
  80652. * Attach a behavior to the node
  80653. * @see http://doc.babylonjs.com/features/behaviour
  80654. * @param behavior defines the behavior to attach
  80655. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80656. * @returns the current Node
  80657. */
  80658. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80659. /**
  80660. * Remove an attached behavior
  80661. * @see http://doc.babylonjs.com/features/behaviour
  80662. * @param behavior defines the behavior to attach
  80663. * @returns the current Node
  80664. */
  80665. removeBehavior(behavior: Behavior<Node>): Node;
  80666. /**
  80667. * Gets the list of attached behaviors
  80668. * @see http://doc.babylonjs.com/features/behaviour
  80669. */
  80670. readonly behaviors: Behavior<Node>[];
  80671. /**
  80672. * Gets an attached behavior by name
  80673. * @param name defines the name of the behavior to look for
  80674. * @see http://doc.babylonjs.com/features/behaviour
  80675. * @returns null if behavior was not found else the requested behavior
  80676. */
  80677. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80678. /**
  80679. * Returns the latest update of the World matrix
  80680. * @returns a Matrix
  80681. */
  80682. getWorldMatrix(): Matrix;
  80683. /** @hidden */
  80684. _getWorldMatrixDeterminant(): number;
  80685. /**
  80686. * Returns directly the latest state of the mesh World matrix.
  80687. * A Matrix is returned.
  80688. */
  80689. readonly worldMatrixFromCache: Matrix;
  80690. /** @hidden */
  80691. _initCache(): void;
  80692. /** @hidden */
  80693. updateCache(force?: boolean): void;
  80694. /** @hidden */
  80695. _updateCache(ignoreParentClass?: boolean): void;
  80696. /** @hidden */
  80697. _isSynchronized(): boolean;
  80698. /** @hidden */
  80699. _markSyncedWithParent(): void;
  80700. /** @hidden */
  80701. isSynchronizedWithParent(): boolean;
  80702. /** @hidden */
  80703. isSynchronized(): boolean;
  80704. /**
  80705. * Is this node ready to be used/rendered
  80706. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80707. * @return true if the node is ready
  80708. */
  80709. isReady(completeCheck?: boolean): boolean;
  80710. /**
  80711. * Is this node enabled?
  80712. * 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
  80713. * @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
  80714. * @return whether this node (and its parent) is enabled
  80715. */
  80716. isEnabled(checkAncestors?: boolean): boolean;
  80717. /** @hidden */
  80718. protected _syncParentEnabledState(): void;
  80719. /**
  80720. * Set the enabled state of this node
  80721. * @param value defines the new enabled state
  80722. */
  80723. setEnabled(value: boolean): void;
  80724. /**
  80725. * Is this node a descendant of the given node?
  80726. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80727. * @param ancestor defines the parent node to inspect
  80728. * @returns a boolean indicating if this node is a descendant of the given node
  80729. */
  80730. isDescendantOf(ancestor: Node): boolean;
  80731. /** @hidden */
  80732. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80733. /**
  80734. * Will return all nodes that have this node as ascendant
  80735. * @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
  80736. * @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
  80737. * @return all children nodes of all types
  80738. */
  80739. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80740. /**
  80741. * Get all child-meshes of this node
  80742. * @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
  80743. * @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
  80744. * @returns an array of AbstractMesh
  80745. */
  80746. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80747. /**
  80748. * Get all direct children of this node
  80749. * @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
  80750. * @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)
  80751. * @returns an array of Node
  80752. */
  80753. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80754. /** @hidden */
  80755. _setReady(state: boolean): void;
  80756. /**
  80757. * Get an animation by name
  80758. * @param name defines the name of the animation to look for
  80759. * @returns null if not found else the requested animation
  80760. */
  80761. getAnimationByName(name: string): Nullable<Animation>;
  80762. /**
  80763. * Creates an animation range for this node
  80764. * @param name defines the name of the range
  80765. * @param from defines the starting key
  80766. * @param to defines the end key
  80767. */
  80768. createAnimationRange(name: string, from: number, to: number): void;
  80769. /**
  80770. * Delete a specific animation range
  80771. * @param name defines the name of the range to delete
  80772. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80773. */
  80774. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80775. /**
  80776. * Get an animation range by name
  80777. * @param name defines the name of the animation range to look for
  80778. * @returns null if not found else the requested animation range
  80779. */
  80780. getAnimationRange(name: string): Nullable<AnimationRange>;
  80781. /**
  80782. * Will start the animation sequence
  80783. * @param name defines the range frames for animation sequence
  80784. * @param loop defines if the animation should loop (false by default)
  80785. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80786. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80787. * @returns the object created for this animation. If range does not exist, it will return null
  80788. */
  80789. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80790. /**
  80791. * Serialize animation ranges into a JSON compatible object
  80792. * @returns serialization object
  80793. */
  80794. serializeAnimationRanges(): any;
  80795. /**
  80796. * Computes the world matrix of the node
  80797. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80798. * @returns the world matrix
  80799. */
  80800. computeWorldMatrix(force?: boolean): Matrix;
  80801. /**
  80802. * Releases resources associated with this node.
  80803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80805. */
  80806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80807. /**
  80808. * Parse animation range data from a serialization object and store them into a given node
  80809. * @param node defines where to store the animation ranges
  80810. * @param parsedNode defines the serialization object to read data from
  80811. * @param scene defines the hosting scene
  80812. */
  80813. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80814. }
  80815. }
  80816. declare module BABYLON {
  80817. /**
  80818. * Class used to store any kind of animation
  80819. */
  80820. export class Animation {
  80821. /**Name of the animation */
  80822. name: string;
  80823. /**Property to animate */
  80824. targetProperty: string;
  80825. /**The frames per second of the animation */
  80826. framePerSecond: number;
  80827. /**The data type of the animation */
  80828. dataType: number;
  80829. /**The loop mode of the animation */
  80830. loopMode?: number | undefined;
  80831. /**Specifies if blending should be enabled */
  80832. enableBlending?: boolean | undefined;
  80833. /**
  80834. * Use matrix interpolation instead of using direct key value when animating matrices
  80835. */
  80836. static AllowMatricesInterpolation: boolean;
  80837. /**
  80838. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80839. */
  80840. static AllowMatrixDecomposeForInterpolation: boolean;
  80841. /**
  80842. * Stores the key frames of the animation
  80843. */
  80844. private _keys;
  80845. /**
  80846. * Stores the easing function of the animation
  80847. */
  80848. private _easingFunction;
  80849. /**
  80850. * @hidden Internal use only
  80851. */
  80852. _runtimeAnimations: RuntimeAnimation[];
  80853. /**
  80854. * The set of event that will be linked to this animation
  80855. */
  80856. private _events;
  80857. /**
  80858. * Stores an array of target property paths
  80859. */
  80860. targetPropertyPath: string[];
  80861. /**
  80862. * Stores the blending speed of the animation
  80863. */
  80864. blendingSpeed: number;
  80865. /**
  80866. * Stores the animation ranges for the animation
  80867. */
  80868. private _ranges;
  80869. /**
  80870. * @hidden Internal use
  80871. */
  80872. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80873. /**
  80874. * Sets up an animation
  80875. * @param property The property to animate
  80876. * @param animationType The animation type to apply
  80877. * @param framePerSecond The frames per second of the animation
  80878. * @param easingFunction The easing function used in the animation
  80879. * @returns The created animation
  80880. */
  80881. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80882. /**
  80883. * Create and start an animation on a node
  80884. * @param name defines the name of the global animation that will be run on all nodes
  80885. * @param node defines the root node where the animation will take place
  80886. * @param targetProperty defines property to animate
  80887. * @param framePerSecond defines the number of frame per second yo use
  80888. * @param totalFrame defines the number of frames in total
  80889. * @param from defines the initial value
  80890. * @param to defines the final value
  80891. * @param loopMode defines which loop mode you want to use (off by default)
  80892. * @param easingFunction defines the easing function to use (linear by default)
  80893. * @param onAnimationEnd defines the callback to call when animation end
  80894. * @returns the animatable created for this animation
  80895. */
  80896. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80897. /**
  80898. * Create and start an animation on a node and its descendants
  80899. * @param name defines the name of the global animation that will be run on all nodes
  80900. * @param node defines the root node where the animation will take place
  80901. * @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
  80902. * @param targetProperty defines property to animate
  80903. * @param framePerSecond defines the number of frame per second to use
  80904. * @param totalFrame defines the number of frames in total
  80905. * @param from defines the initial value
  80906. * @param to defines the final value
  80907. * @param loopMode defines which loop mode you want to use (off by default)
  80908. * @param easingFunction defines the easing function to use (linear by default)
  80909. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80910. * @returns the list of animatables created for all nodes
  80911. * @example https://www.babylonjs-playground.com/#MH0VLI
  80912. */
  80913. 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[]>;
  80914. /**
  80915. * Creates a new animation, merges it with the existing animations and starts it
  80916. * @param name Name of the animation
  80917. * @param node Node which contains the scene that begins the animations
  80918. * @param targetProperty Specifies which property to animate
  80919. * @param framePerSecond The frames per second of the animation
  80920. * @param totalFrame The total number of frames
  80921. * @param from The frame at the beginning of the animation
  80922. * @param to The frame at the end of the animation
  80923. * @param loopMode Specifies the loop mode of the animation
  80924. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80925. * @param onAnimationEnd Callback to run once the animation is complete
  80926. * @returns Nullable animation
  80927. */
  80928. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80929. /**
  80930. * Transition property of an host to the target Value
  80931. * @param property The property to transition
  80932. * @param targetValue The target Value of the property
  80933. * @param host The object where the property to animate belongs
  80934. * @param scene Scene used to run the animation
  80935. * @param frameRate Framerate (in frame/s) to use
  80936. * @param transition The transition type we want to use
  80937. * @param duration The duration of the animation, in milliseconds
  80938. * @param onAnimationEnd Callback trigger at the end of the animation
  80939. * @returns Nullable animation
  80940. */
  80941. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  80942. /**
  80943. * Return the array of runtime animations currently using this animation
  80944. */
  80945. readonly runtimeAnimations: RuntimeAnimation[];
  80946. /**
  80947. * Specifies if any of the runtime animations are currently running
  80948. */
  80949. readonly hasRunningRuntimeAnimations: boolean;
  80950. /**
  80951. * Initializes the animation
  80952. * @param name Name of the animation
  80953. * @param targetProperty Property to animate
  80954. * @param framePerSecond The frames per second of the animation
  80955. * @param dataType The data type of the animation
  80956. * @param loopMode The loop mode of the animation
  80957. * @param enableBlending Specifies if blending should be enabled
  80958. */
  80959. constructor(
  80960. /**Name of the animation */
  80961. name: string,
  80962. /**Property to animate */
  80963. targetProperty: string,
  80964. /**The frames per second of the animation */
  80965. framePerSecond: number,
  80966. /**The data type of the animation */
  80967. dataType: number,
  80968. /**The loop mode of the animation */
  80969. loopMode?: number | undefined,
  80970. /**Specifies if blending should be enabled */
  80971. enableBlending?: boolean | undefined);
  80972. /**
  80973. * Converts the animation to a string
  80974. * @param fullDetails support for multiple levels of logging within scene loading
  80975. * @returns String form of the animation
  80976. */
  80977. toString(fullDetails?: boolean): string;
  80978. /**
  80979. * Add an event to this animation
  80980. * @param event Event to add
  80981. */
  80982. addEvent(event: AnimationEvent): void;
  80983. /**
  80984. * Remove all events found at the given frame
  80985. * @param frame The frame to remove events from
  80986. */
  80987. removeEvents(frame: number): void;
  80988. /**
  80989. * Retrieves all the events from the animation
  80990. * @returns Events from the animation
  80991. */
  80992. getEvents(): AnimationEvent[];
  80993. /**
  80994. * Creates an animation range
  80995. * @param name Name of the animation range
  80996. * @param from Starting frame of the animation range
  80997. * @param to Ending frame of the animation
  80998. */
  80999. createRange(name: string, from: number, to: number): void;
  81000. /**
  81001. * Deletes an animation range by name
  81002. * @param name Name of the animation range to delete
  81003. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81004. */
  81005. deleteRange(name: string, deleteFrames?: boolean): void;
  81006. /**
  81007. * Gets the animation range by name, or null if not defined
  81008. * @param name Name of the animation range
  81009. * @returns Nullable animation range
  81010. */
  81011. getRange(name: string): Nullable<AnimationRange>;
  81012. /**
  81013. * Gets the key frames from the animation
  81014. * @returns The key frames of the animation
  81015. */
  81016. getKeys(): Array<IAnimationKey>;
  81017. /**
  81018. * Gets the highest frame rate of the animation
  81019. * @returns Highest frame rate of the animation
  81020. */
  81021. getHighestFrame(): number;
  81022. /**
  81023. * Gets the easing function of the animation
  81024. * @returns Easing function of the animation
  81025. */
  81026. getEasingFunction(): IEasingFunction;
  81027. /**
  81028. * Sets the easing function of the animation
  81029. * @param easingFunction A custom mathematical formula for animation
  81030. */
  81031. setEasingFunction(easingFunction: EasingFunction): void;
  81032. /**
  81033. * Interpolates a scalar linearly
  81034. * @param startValue Start value of the animation curve
  81035. * @param endValue End value of the animation curve
  81036. * @param gradient Scalar amount to interpolate
  81037. * @returns Interpolated scalar value
  81038. */
  81039. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81040. /**
  81041. * Interpolates a scalar cubically
  81042. * @param startValue Start value of the animation curve
  81043. * @param outTangent End tangent of the animation
  81044. * @param endValue End value of the animation curve
  81045. * @param inTangent Start tangent of the animation curve
  81046. * @param gradient Scalar amount to interpolate
  81047. * @returns Interpolated scalar value
  81048. */
  81049. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81050. /**
  81051. * Interpolates a quaternion using a spherical linear interpolation
  81052. * @param startValue Start value of the animation curve
  81053. * @param endValue End value of the animation curve
  81054. * @param gradient Scalar amount to interpolate
  81055. * @returns Interpolated quaternion value
  81056. */
  81057. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81058. /**
  81059. * Interpolates a quaternion cubically
  81060. * @param startValue Start value of the animation curve
  81061. * @param outTangent End tangent of the animation curve
  81062. * @param endValue End value of the animation curve
  81063. * @param inTangent Start tangent of the animation curve
  81064. * @param gradient Scalar amount to interpolate
  81065. * @returns Interpolated quaternion value
  81066. */
  81067. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81068. /**
  81069. * Interpolates a Vector3 linearl
  81070. * @param startValue Start value of the animation curve
  81071. * @param endValue End value of the animation curve
  81072. * @param gradient Scalar amount to interpolate
  81073. * @returns Interpolated scalar value
  81074. */
  81075. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81076. /**
  81077. * Interpolates a Vector3 cubically
  81078. * @param startValue Start value of the animation curve
  81079. * @param outTangent End tangent of the animation
  81080. * @param endValue End value of the animation curve
  81081. * @param inTangent Start tangent of the animation curve
  81082. * @param gradient Scalar amount to interpolate
  81083. * @returns InterpolatedVector3 value
  81084. */
  81085. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81086. /**
  81087. * Interpolates a Vector2 linearly
  81088. * @param startValue Start value of the animation curve
  81089. * @param endValue End value of the animation curve
  81090. * @param gradient Scalar amount to interpolate
  81091. * @returns Interpolated Vector2 value
  81092. */
  81093. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81094. /**
  81095. * Interpolates a Vector2 cubically
  81096. * @param startValue Start value of the animation curve
  81097. * @param outTangent End tangent of the animation
  81098. * @param endValue End value of the animation curve
  81099. * @param inTangent Start tangent of the animation curve
  81100. * @param gradient Scalar amount to interpolate
  81101. * @returns Interpolated Vector2 value
  81102. */
  81103. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81104. /**
  81105. * Interpolates a size linearly
  81106. * @param startValue Start value of the animation curve
  81107. * @param endValue End value of the animation curve
  81108. * @param gradient Scalar amount to interpolate
  81109. * @returns Interpolated Size value
  81110. */
  81111. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81112. /**
  81113. * Interpolates a Color3 linearly
  81114. * @param startValue Start value of the animation curve
  81115. * @param endValue End value of the animation curve
  81116. * @param gradient Scalar amount to interpolate
  81117. * @returns Interpolated Color3 value
  81118. */
  81119. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81120. /**
  81121. * @hidden Internal use only
  81122. */
  81123. _getKeyValue(value: any): any;
  81124. /**
  81125. * @hidden Internal use only
  81126. */
  81127. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81128. /**
  81129. * Defines the function to use to interpolate matrices
  81130. * @param startValue defines the start matrix
  81131. * @param endValue defines the end matrix
  81132. * @param gradient defines the gradient between both matrices
  81133. * @param result defines an optional target matrix where to store the interpolation
  81134. * @returns the interpolated matrix
  81135. */
  81136. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81137. /**
  81138. * Makes a copy of the animation
  81139. * @returns Cloned animation
  81140. */
  81141. clone(): Animation;
  81142. /**
  81143. * Sets the key frames of the animation
  81144. * @param values The animation key frames to set
  81145. */
  81146. setKeys(values: Array<IAnimationKey>): void;
  81147. /**
  81148. * Serializes the animation to an object
  81149. * @returns Serialized object
  81150. */
  81151. serialize(): any;
  81152. /**
  81153. * Float animation type
  81154. */
  81155. private static _ANIMATIONTYPE_FLOAT;
  81156. /**
  81157. * Vector3 animation type
  81158. */
  81159. private static _ANIMATIONTYPE_VECTOR3;
  81160. /**
  81161. * Quaternion animation type
  81162. */
  81163. private static _ANIMATIONTYPE_QUATERNION;
  81164. /**
  81165. * Matrix animation type
  81166. */
  81167. private static _ANIMATIONTYPE_MATRIX;
  81168. /**
  81169. * Color3 animation type
  81170. */
  81171. private static _ANIMATIONTYPE_COLOR3;
  81172. /**
  81173. * Vector2 animation type
  81174. */
  81175. private static _ANIMATIONTYPE_VECTOR2;
  81176. /**
  81177. * Size animation type
  81178. */
  81179. private static _ANIMATIONTYPE_SIZE;
  81180. /**
  81181. * Relative Loop Mode
  81182. */
  81183. private static _ANIMATIONLOOPMODE_RELATIVE;
  81184. /**
  81185. * Cycle Loop Mode
  81186. */
  81187. private static _ANIMATIONLOOPMODE_CYCLE;
  81188. /**
  81189. * Constant Loop Mode
  81190. */
  81191. private static _ANIMATIONLOOPMODE_CONSTANT;
  81192. /**
  81193. * Get the float animation type
  81194. */
  81195. static readonly ANIMATIONTYPE_FLOAT: number;
  81196. /**
  81197. * Get the Vector3 animation type
  81198. */
  81199. static readonly ANIMATIONTYPE_VECTOR3: number;
  81200. /**
  81201. * Get the Vector2 animation type
  81202. */
  81203. static readonly ANIMATIONTYPE_VECTOR2: number;
  81204. /**
  81205. * Get the Size animation type
  81206. */
  81207. static readonly ANIMATIONTYPE_SIZE: number;
  81208. /**
  81209. * Get the Quaternion animation type
  81210. */
  81211. static readonly ANIMATIONTYPE_QUATERNION: number;
  81212. /**
  81213. * Get the Matrix animation type
  81214. */
  81215. static readonly ANIMATIONTYPE_MATRIX: number;
  81216. /**
  81217. * Get the Color3 animation type
  81218. */
  81219. static readonly ANIMATIONTYPE_COLOR3: number;
  81220. /**
  81221. * Get the Relative Loop Mode
  81222. */
  81223. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81224. /**
  81225. * Get the Cycle Loop Mode
  81226. */
  81227. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81228. /**
  81229. * Get the Constant Loop Mode
  81230. */
  81231. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81232. /** @hidden */
  81233. static _UniversalLerp(left: any, right: any, amount: number): any;
  81234. /**
  81235. * Parses an animation object and creates an animation
  81236. * @param parsedAnimation Parsed animation object
  81237. * @returns Animation object
  81238. */
  81239. static Parse(parsedAnimation: any): Animation;
  81240. /**
  81241. * Appends the serialized animations from the source animations
  81242. * @param source Source containing the animations
  81243. * @param destination Target to store the animations
  81244. */
  81245. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81246. }
  81247. }
  81248. declare module BABYLON {
  81249. /**
  81250. * Base class of all the textures in babylon.
  81251. * It groups all the common properties the materials, post process, lights... might need
  81252. * in order to make a correct use of the texture.
  81253. */
  81254. export class BaseTexture implements IAnimatable {
  81255. /**
  81256. * Default anisotropic filtering level for the application.
  81257. * It is set to 4 as a good tradeoff between perf and quality.
  81258. */
  81259. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81260. /**
  81261. * Gets or sets the unique id of the texture
  81262. */
  81263. uniqueId: number;
  81264. /**
  81265. * Define the name of the texture.
  81266. */
  81267. name: string;
  81268. /**
  81269. * Gets or sets an object used to store user defined information.
  81270. */
  81271. metadata: any;
  81272. /**
  81273. * For internal use only. Please do not use.
  81274. */
  81275. reservedDataStore: any;
  81276. private _hasAlpha;
  81277. /**
  81278. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81279. */
  81280. hasAlpha: boolean;
  81281. /**
  81282. * Defines if the alpha value should be determined via the rgb values.
  81283. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81284. */
  81285. getAlphaFromRGB: boolean;
  81286. /**
  81287. * Intensity or strength of the texture.
  81288. * It is commonly used by materials to fine tune the intensity of the texture
  81289. */
  81290. level: number;
  81291. /**
  81292. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81293. * This is part of the texture as textures usually maps to one uv set.
  81294. */
  81295. coordinatesIndex: number;
  81296. private _coordinatesMode;
  81297. /**
  81298. * How a texture is mapped.
  81299. *
  81300. * | Value | Type | Description |
  81301. * | ----- | ----------------------------------- | ----------- |
  81302. * | 0 | EXPLICIT_MODE | |
  81303. * | 1 | SPHERICAL_MODE | |
  81304. * | 2 | PLANAR_MODE | |
  81305. * | 3 | CUBIC_MODE | |
  81306. * | 4 | PROJECTION_MODE | |
  81307. * | 5 | SKYBOX_MODE | |
  81308. * | 6 | INVCUBIC_MODE | |
  81309. * | 7 | EQUIRECTANGULAR_MODE | |
  81310. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81311. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81312. */
  81313. coordinatesMode: number;
  81314. /**
  81315. * | Value | Type | Description |
  81316. * | ----- | ------------------ | ----------- |
  81317. * | 0 | CLAMP_ADDRESSMODE | |
  81318. * | 1 | WRAP_ADDRESSMODE | |
  81319. * | 2 | MIRROR_ADDRESSMODE | |
  81320. */
  81321. wrapU: number;
  81322. /**
  81323. * | Value | Type | Description |
  81324. * | ----- | ------------------ | ----------- |
  81325. * | 0 | CLAMP_ADDRESSMODE | |
  81326. * | 1 | WRAP_ADDRESSMODE | |
  81327. * | 2 | MIRROR_ADDRESSMODE | |
  81328. */
  81329. wrapV: number;
  81330. /**
  81331. * | Value | Type | Description |
  81332. * | ----- | ------------------ | ----------- |
  81333. * | 0 | CLAMP_ADDRESSMODE | |
  81334. * | 1 | WRAP_ADDRESSMODE | |
  81335. * | 2 | MIRROR_ADDRESSMODE | |
  81336. */
  81337. wrapR: number;
  81338. /**
  81339. * With compliant hardware and browser (supporting anisotropic filtering)
  81340. * this defines the level of anisotropic filtering in the texture.
  81341. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81342. */
  81343. anisotropicFilteringLevel: number;
  81344. /**
  81345. * Define if the texture is a cube texture or if false a 2d texture.
  81346. */
  81347. isCube: boolean;
  81348. /**
  81349. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81350. */
  81351. is3D: boolean;
  81352. /**
  81353. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81354. * HDR texture are usually stored in linear space.
  81355. * This only impacts the PBR and Background materials
  81356. */
  81357. gammaSpace: boolean;
  81358. /**
  81359. * Gets whether or not the texture contains RGBD data.
  81360. */
  81361. readonly isRGBD: boolean;
  81362. /**
  81363. * Is Z inverted in the texture (useful in a cube texture).
  81364. */
  81365. invertZ: boolean;
  81366. /**
  81367. * Are mip maps generated for this texture or not.
  81368. */
  81369. readonly noMipmap: boolean;
  81370. /**
  81371. * @hidden
  81372. */
  81373. lodLevelInAlpha: boolean;
  81374. /**
  81375. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81376. */
  81377. lodGenerationOffset: number;
  81378. /**
  81379. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81380. */
  81381. lodGenerationScale: number;
  81382. /**
  81383. * Define if the texture is a render target.
  81384. */
  81385. isRenderTarget: boolean;
  81386. /**
  81387. * Define the unique id of the texture in the scene.
  81388. */
  81389. readonly uid: string;
  81390. /**
  81391. * Return a string representation of the texture.
  81392. * @returns the texture as a string
  81393. */
  81394. toString(): string;
  81395. /**
  81396. * Get the class name of the texture.
  81397. * @returns "BaseTexture"
  81398. */
  81399. getClassName(): string;
  81400. /**
  81401. * Define the list of animation attached to the texture.
  81402. */
  81403. animations: Animation[];
  81404. /**
  81405. * An event triggered when the texture is disposed.
  81406. */
  81407. onDisposeObservable: Observable<BaseTexture>;
  81408. private _onDisposeObserver;
  81409. /**
  81410. * Callback triggered when the texture has been disposed.
  81411. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81412. */
  81413. onDispose: () => void;
  81414. /**
  81415. * Define the current state of the loading sequence when in delayed load mode.
  81416. */
  81417. delayLoadState: number;
  81418. private _scene;
  81419. /** @hidden */
  81420. _texture: Nullable<InternalTexture>;
  81421. private _uid;
  81422. /**
  81423. * Define if the texture is preventinga material to render or not.
  81424. * If not and the texture is not ready, the engine will use a default black texture instead.
  81425. */
  81426. readonly isBlocking: boolean;
  81427. /**
  81428. * Instantiates a new BaseTexture.
  81429. * Base class of all the textures in babylon.
  81430. * It groups all the common properties the materials, post process, lights... might need
  81431. * in order to make a correct use of the texture.
  81432. * @param scene Define the scene the texture blongs to
  81433. */
  81434. constructor(scene: Nullable<Scene>);
  81435. /**
  81436. * Get the scene the texture belongs to.
  81437. * @returns the scene or null if undefined
  81438. */
  81439. getScene(): Nullable<Scene>;
  81440. /**
  81441. * Get the texture transform matrix used to offset tile the texture for istance.
  81442. * @returns the transformation matrix
  81443. */
  81444. getTextureMatrix(): Matrix;
  81445. /**
  81446. * Get the texture reflection matrix used to rotate/transform the reflection.
  81447. * @returns the reflection matrix
  81448. */
  81449. getReflectionTextureMatrix(): Matrix;
  81450. /**
  81451. * Get the underlying lower level texture from Babylon.
  81452. * @returns the insternal texture
  81453. */
  81454. getInternalTexture(): Nullable<InternalTexture>;
  81455. /**
  81456. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81457. * @returns true if ready or not blocking
  81458. */
  81459. isReadyOrNotBlocking(): boolean;
  81460. /**
  81461. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81462. * @returns true if fully ready
  81463. */
  81464. isReady(): boolean;
  81465. private _cachedSize;
  81466. /**
  81467. * Get the size of the texture.
  81468. * @returns the texture size.
  81469. */
  81470. getSize(): ISize;
  81471. /**
  81472. * Get the base size of the texture.
  81473. * It can be different from the size if the texture has been resized for POT for instance
  81474. * @returns the base size
  81475. */
  81476. getBaseSize(): ISize;
  81477. /**
  81478. * Update the sampling mode of the texture.
  81479. * Default is Trilinear mode.
  81480. *
  81481. * | Value | Type | Description |
  81482. * | ----- | ------------------ | ----------- |
  81483. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81484. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81485. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81486. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81487. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81488. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81489. * | 7 | NEAREST_LINEAR | |
  81490. * | 8 | NEAREST_NEAREST | |
  81491. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81492. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81493. * | 11 | LINEAR_LINEAR | |
  81494. * | 12 | LINEAR_NEAREST | |
  81495. *
  81496. * > _mag_: magnification filter (close to the viewer)
  81497. * > _min_: minification filter (far from the viewer)
  81498. * > _mip_: filter used between mip map levels
  81499. *@param samplingMode Define the new sampling mode of the texture
  81500. */
  81501. updateSamplingMode(samplingMode: number): void;
  81502. /**
  81503. * Scales the texture if is `canRescale()`
  81504. * @param ratio the resize factor we want to use to rescale
  81505. */
  81506. scale(ratio: number): void;
  81507. /**
  81508. * Get if the texture can rescale.
  81509. */
  81510. readonly canRescale: boolean;
  81511. /** @hidden */
  81512. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81513. /** @hidden */
  81514. _rebuild(): void;
  81515. /**
  81516. * Triggers the load sequence in delayed load mode.
  81517. */
  81518. delayLoad(): void;
  81519. /**
  81520. * Clones the texture.
  81521. * @returns the cloned texture
  81522. */
  81523. clone(): Nullable<BaseTexture>;
  81524. /**
  81525. * Get the texture underlying type (INT, FLOAT...)
  81526. */
  81527. readonly textureType: number;
  81528. /**
  81529. * Get the texture underlying format (RGB, RGBA...)
  81530. */
  81531. readonly textureFormat: number;
  81532. /**
  81533. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81534. * This will returns an RGBA array buffer containing either in values (0-255) or
  81535. * float values (0-1) depending of the underlying buffer type.
  81536. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81537. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81538. * @param buffer defines a user defined buffer to fill with data (can be null)
  81539. * @returns The Array buffer containing the pixels data.
  81540. */
  81541. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81542. /**
  81543. * Release and destroy the underlying lower level texture aka internalTexture.
  81544. */
  81545. releaseInternalTexture(): void;
  81546. /**
  81547. * Get the polynomial representation of the texture data.
  81548. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81549. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81550. */
  81551. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81552. /** @hidden */
  81553. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81554. /** @hidden */
  81555. readonly _lodTextureMid: Nullable<BaseTexture>;
  81556. /** @hidden */
  81557. readonly _lodTextureLow: Nullable<BaseTexture>;
  81558. /**
  81559. * Dispose the texture and release its associated resources.
  81560. */
  81561. dispose(): void;
  81562. /**
  81563. * Serialize the texture into a JSON representation that can be parsed later on.
  81564. * @returns the JSON representation of the texture
  81565. */
  81566. serialize(): any;
  81567. /**
  81568. * Helper function to be called back once a list of texture contains only ready textures.
  81569. * @param textures Define the list of textures to wait for
  81570. * @param callback Define the callback triggered once the entire list will be ready
  81571. */
  81572. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81573. }
  81574. }
  81575. declare module BABYLON {
  81576. /**
  81577. * Uniform buffer objects.
  81578. *
  81579. * Handles blocks of uniform on the GPU.
  81580. *
  81581. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81582. *
  81583. * For more information, please refer to :
  81584. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81585. */
  81586. export class UniformBuffer {
  81587. private _engine;
  81588. private _buffer;
  81589. private _data;
  81590. private _bufferData;
  81591. private _dynamic?;
  81592. private _uniformLocations;
  81593. private _uniformSizes;
  81594. private _uniformLocationPointer;
  81595. private _needSync;
  81596. private _noUBO;
  81597. private _currentEffect;
  81598. private static _MAX_UNIFORM_SIZE;
  81599. private static _tempBuffer;
  81600. /**
  81601. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81602. * This is dynamic to allow compat with webgl 1 and 2.
  81603. * You will need to pass the name of the uniform as well as the value.
  81604. */
  81605. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81606. /**
  81607. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81608. * This is dynamic to allow compat with webgl 1 and 2.
  81609. * You will need to pass the name of the uniform as well as the value.
  81610. */
  81611. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81612. /**
  81613. * Lambda to Update a single float in a uniform buffer.
  81614. * This is dynamic to allow compat with webgl 1 and 2.
  81615. * You will need to pass the name of the uniform as well as the value.
  81616. */
  81617. updateFloat: (name: string, x: number) => void;
  81618. /**
  81619. * Lambda to Update a vec2 of float in a uniform buffer.
  81620. * This is dynamic to allow compat with webgl 1 and 2.
  81621. * You will need to pass the name of the uniform as well as the value.
  81622. */
  81623. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81624. /**
  81625. * Lambda to Update a vec3 of float in a uniform buffer.
  81626. * This is dynamic to allow compat with webgl 1 and 2.
  81627. * You will need to pass the name of the uniform as well as the value.
  81628. */
  81629. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81630. /**
  81631. * Lambda to Update a vec4 of float in a uniform buffer.
  81632. * This is dynamic to allow compat with webgl 1 and 2.
  81633. * You will need to pass the name of the uniform as well as the value.
  81634. */
  81635. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81636. /**
  81637. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81638. * This is dynamic to allow compat with webgl 1 and 2.
  81639. * You will need to pass the name of the uniform as well as the value.
  81640. */
  81641. updateMatrix: (name: string, mat: Matrix) => void;
  81642. /**
  81643. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81644. * This is dynamic to allow compat with webgl 1 and 2.
  81645. * You will need to pass the name of the uniform as well as the value.
  81646. */
  81647. updateVector3: (name: string, vector: Vector3) => void;
  81648. /**
  81649. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81650. * This is dynamic to allow compat with webgl 1 and 2.
  81651. * You will need to pass the name of the uniform as well as the value.
  81652. */
  81653. updateVector4: (name: string, vector: Vector4) => void;
  81654. /**
  81655. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81656. * This is dynamic to allow compat with webgl 1 and 2.
  81657. * You will need to pass the name of the uniform as well as the value.
  81658. */
  81659. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81660. /**
  81661. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81662. * This is dynamic to allow compat with webgl 1 and 2.
  81663. * You will need to pass the name of the uniform as well as the value.
  81664. */
  81665. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81666. /**
  81667. * Instantiates a new Uniform buffer objects.
  81668. *
  81669. * Handles blocks of uniform on the GPU.
  81670. *
  81671. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81672. *
  81673. * For more information, please refer to :
  81674. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81675. * @param engine Define the engine the buffer is associated with
  81676. * @param data Define the data contained in the buffer
  81677. * @param dynamic Define if the buffer is updatable
  81678. */
  81679. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81680. /**
  81681. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81682. * or just falling back on setUniformXXX calls.
  81683. */
  81684. readonly useUbo: boolean;
  81685. /**
  81686. * Indicates if the WebGL underlying uniform buffer is in sync
  81687. * with the javascript cache data.
  81688. */
  81689. readonly isSync: boolean;
  81690. /**
  81691. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81692. * Also, a dynamic UniformBuffer will disable cache verification and always
  81693. * update the underlying WebGL uniform buffer to the GPU.
  81694. * @returns if Dynamic, otherwise false
  81695. */
  81696. isDynamic(): boolean;
  81697. /**
  81698. * The data cache on JS side.
  81699. * @returns the underlying data as a float array
  81700. */
  81701. getData(): Float32Array;
  81702. /**
  81703. * The underlying WebGL Uniform buffer.
  81704. * @returns the webgl buffer
  81705. */
  81706. getBuffer(): Nullable<WebGLBuffer>;
  81707. /**
  81708. * std140 layout specifies how to align data within an UBO structure.
  81709. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81710. * for specs.
  81711. */
  81712. private _fillAlignment;
  81713. /**
  81714. * Adds an uniform in the buffer.
  81715. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81716. * for the layout to be correct !
  81717. * @param name Name of the uniform, as used in the uniform block in the shader.
  81718. * @param size Data size, or data directly.
  81719. */
  81720. addUniform(name: string, size: number | number[]): void;
  81721. /**
  81722. * Adds a Matrix 4x4 to the uniform buffer.
  81723. * @param name Name of the uniform, as used in the uniform block in the shader.
  81724. * @param mat A 4x4 matrix.
  81725. */
  81726. addMatrix(name: string, mat: Matrix): void;
  81727. /**
  81728. * Adds a vec2 to the uniform buffer.
  81729. * @param name Name of the uniform, as used in the uniform block in the shader.
  81730. * @param x Define the x component value of the vec2
  81731. * @param y Define the y component value of the vec2
  81732. */
  81733. addFloat2(name: string, x: number, y: number): void;
  81734. /**
  81735. * Adds a vec3 to the uniform buffer.
  81736. * @param name Name of the uniform, as used in the uniform block in the shader.
  81737. * @param x Define the x component value of the vec3
  81738. * @param y Define the y component value of the vec3
  81739. * @param z Define the z component value of the vec3
  81740. */
  81741. addFloat3(name: string, x: number, y: number, z: number): void;
  81742. /**
  81743. * Adds a vec3 to the uniform buffer.
  81744. * @param name Name of the uniform, as used in the uniform block in the shader.
  81745. * @param color Define the vec3 from a Color
  81746. */
  81747. addColor3(name: string, color: Color3): void;
  81748. /**
  81749. * Adds a vec4 to the uniform buffer.
  81750. * @param name Name of the uniform, as used in the uniform block in the shader.
  81751. * @param color Define the rgb components from a Color
  81752. * @param alpha Define the a component of the vec4
  81753. */
  81754. addColor4(name: string, color: Color3, alpha: number): void;
  81755. /**
  81756. * Adds a vec3 to the uniform buffer.
  81757. * @param name Name of the uniform, as used in the uniform block in the shader.
  81758. * @param vector Define the vec3 components from a Vector
  81759. */
  81760. addVector3(name: string, vector: Vector3): void;
  81761. /**
  81762. * Adds a Matrix 3x3 to the uniform buffer.
  81763. * @param name Name of the uniform, as used in the uniform block in the shader.
  81764. */
  81765. addMatrix3x3(name: string): void;
  81766. /**
  81767. * Adds a Matrix 2x2 to the uniform buffer.
  81768. * @param name Name of the uniform, as used in the uniform block in the shader.
  81769. */
  81770. addMatrix2x2(name: string): void;
  81771. /**
  81772. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81773. */
  81774. create(): void;
  81775. /** @hidden */
  81776. _rebuild(): void;
  81777. /**
  81778. * Updates the WebGL Uniform Buffer on the GPU.
  81779. * If the `dynamic` flag is set to true, no cache comparison is done.
  81780. * Otherwise, the buffer will be updated only if the cache differs.
  81781. */
  81782. update(): void;
  81783. /**
  81784. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81785. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81786. * @param data Define the flattened data
  81787. * @param size Define the size of the data.
  81788. */
  81789. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81790. private _updateMatrix3x3ForUniform;
  81791. private _updateMatrix3x3ForEffect;
  81792. private _updateMatrix2x2ForEffect;
  81793. private _updateMatrix2x2ForUniform;
  81794. private _updateFloatForEffect;
  81795. private _updateFloatForUniform;
  81796. private _updateFloat2ForEffect;
  81797. private _updateFloat2ForUniform;
  81798. private _updateFloat3ForEffect;
  81799. private _updateFloat3ForUniform;
  81800. private _updateFloat4ForEffect;
  81801. private _updateFloat4ForUniform;
  81802. private _updateMatrixForEffect;
  81803. private _updateMatrixForUniform;
  81804. private _updateVector3ForEffect;
  81805. private _updateVector3ForUniform;
  81806. private _updateVector4ForEffect;
  81807. private _updateVector4ForUniform;
  81808. private _updateColor3ForEffect;
  81809. private _updateColor3ForUniform;
  81810. private _updateColor4ForEffect;
  81811. private _updateColor4ForUniform;
  81812. /**
  81813. * Sets a sampler uniform on the effect.
  81814. * @param name Define the name of the sampler.
  81815. * @param texture Define the texture to set in the sampler
  81816. */
  81817. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81818. /**
  81819. * Directly updates the value of the uniform in the cache AND on the GPU.
  81820. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81821. * @param data Define the flattened data
  81822. */
  81823. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81824. /**
  81825. * Binds this uniform buffer to an effect.
  81826. * @param effect Define the effect to bind the buffer to
  81827. * @param name Name of the uniform block in the shader.
  81828. */
  81829. bindToEffect(effect: Effect, name: string): void;
  81830. /**
  81831. * Disposes the uniform buffer.
  81832. */
  81833. dispose(): void;
  81834. }
  81835. }
  81836. declare module BABYLON {
  81837. /**
  81838. * This represents the required contract to create a new type of texture loader.
  81839. */
  81840. export interface IInternalTextureLoader {
  81841. /**
  81842. * Defines wether the loader supports cascade loading the different faces.
  81843. */
  81844. supportCascades: boolean;
  81845. /**
  81846. * This returns if the loader support the current file information.
  81847. * @param extension defines the file extension of the file being loaded
  81848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81849. * @param fallback defines the fallback internal texture if any
  81850. * @param isBase64 defines whether the texture is encoded as a base64
  81851. * @param isBuffer defines whether the texture data are stored as a buffer
  81852. * @returns true if the loader can load the specified file
  81853. */
  81854. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81855. /**
  81856. * Transform the url before loading if required.
  81857. * @param rootUrl the url of the texture
  81858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81859. * @returns the transformed texture
  81860. */
  81861. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81862. /**
  81863. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81864. * @param rootUrl the url of the texture
  81865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81866. * @returns the fallback texture
  81867. */
  81868. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81869. /**
  81870. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81871. * @param data contains the texture data
  81872. * @param texture defines the BabylonJS internal texture
  81873. * @param createPolynomials will be true if polynomials have been requested
  81874. * @param onLoad defines the callback to trigger once the texture is ready
  81875. * @param onError defines the callback to trigger in case of error
  81876. */
  81877. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81878. /**
  81879. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81880. * @param data contains the texture data
  81881. * @param texture defines the BabylonJS internal texture
  81882. * @param callback defines the method to call once ready to upload
  81883. */
  81884. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81885. }
  81886. }
  81887. declare module BABYLON {
  81888. /**
  81889. * Creation options of the multi render target texture.
  81890. */
  81891. export interface IMultiRenderTargetOptions {
  81892. /**
  81893. * Define if the texture needs to create mip maps after render.
  81894. */
  81895. generateMipMaps?: boolean;
  81896. /**
  81897. * Define the types of all the draw buffers we want to create
  81898. */
  81899. types?: number[];
  81900. /**
  81901. * Define the sampling modes of all the draw buffers we want to create
  81902. */
  81903. samplingModes?: number[];
  81904. /**
  81905. * Define if a depth buffer is required
  81906. */
  81907. generateDepthBuffer?: boolean;
  81908. /**
  81909. * Define if a stencil buffer is required
  81910. */
  81911. generateStencilBuffer?: boolean;
  81912. /**
  81913. * Define if a depth texture is required instead of a depth buffer
  81914. */
  81915. generateDepthTexture?: boolean;
  81916. /**
  81917. * Define the number of desired draw buffers
  81918. */
  81919. textureCount?: number;
  81920. /**
  81921. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81922. */
  81923. doNotChangeAspectRatio?: boolean;
  81924. /**
  81925. * Define the default type of the buffers we are creating
  81926. */
  81927. defaultType?: number;
  81928. }
  81929. /**
  81930. * A multi render target, like a render target provides the ability to render to a texture.
  81931. * Unlike the render target, it can render to several draw buffers in one draw.
  81932. * This is specially interesting in deferred rendering or for any effects requiring more than
  81933. * just one color from a single pass.
  81934. */
  81935. export class MultiRenderTarget extends RenderTargetTexture {
  81936. private _internalTextures;
  81937. private _textures;
  81938. private _multiRenderTargetOptions;
  81939. /**
  81940. * Get if draw buffers are currently supported by the used hardware and browser.
  81941. */
  81942. readonly isSupported: boolean;
  81943. /**
  81944. * Get the list of textures generated by the multi render target.
  81945. */
  81946. readonly textures: Texture[];
  81947. /**
  81948. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  81949. */
  81950. readonly depthTexture: Texture;
  81951. /**
  81952. * Set the wrapping mode on U of all the textures we are rendering to.
  81953. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81954. */
  81955. wrapU: number;
  81956. /**
  81957. * Set the wrapping mode on V of all the textures we are rendering to.
  81958. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81959. */
  81960. wrapV: number;
  81961. /**
  81962. * Instantiate a new multi render target texture.
  81963. * A multi render target, like a render target provides the ability to render to a texture.
  81964. * Unlike the render target, it can render to several draw buffers in one draw.
  81965. * This is specially interesting in deferred rendering or for any effects requiring more than
  81966. * just one color from a single pass.
  81967. * @param name Define the name of the texture
  81968. * @param size Define the size of the buffers to render to
  81969. * @param count Define the number of target we are rendering into
  81970. * @param scene Define the scene the texture belongs to
  81971. * @param options Define the options used to create the multi render target
  81972. */
  81973. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  81974. /** @hidden */
  81975. _rebuild(): void;
  81976. private _createInternalTextures;
  81977. private _createTextures;
  81978. /**
  81979. * Define the number of samples used if MSAA is enabled.
  81980. */
  81981. samples: number;
  81982. /**
  81983. * Resize all the textures in the multi render target.
  81984. * Be carrefull as it will recreate all the data in the new texture.
  81985. * @param size Define the new size
  81986. */
  81987. resize(size: any): void;
  81988. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  81989. /**
  81990. * Dispose the render targets and their associated resources
  81991. */
  81992. dispose(): void;
  81993. /**
  81994. * Release all the underlying texture used as draw buffers.
  81995. */
  81996. releaseInternalTextures(): void;
  81997. }
  81998. }
  81999. declare module BABYLON {
  82000. /**
  82001. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82003. */
  82004. export class Analyser {
  82005. /**
  82006. * Gets or sets the smoothing
  82007. * @ignorenaming
  82008. */
  82009. SMOOTHING: number;
  82010. /**
  82011. * Gets or sets the FFT table size
  82012. * @ignorenaming
  82013. */
  82014. FFT_SIZE: number;
  82015. /**
  82016. * Gets or sets the bar graph amplitude
  82017. * @ignorenaming
  82018. */
  82019. BARGRAPHAMPLITUDE: number;
  82020. /**
  82021. * Gets or sets the position of the debug canvas
  82022. * @ignorenaming
  82023. */
  82024. DEBUGCANVASPOS: {
  82025. x: number;
  82026. y: number;
  82027. };
  82028. /**
  82029. * Gets or sets the debug canvas size
  82030. * @ignorenaming
  82031. */
  82032. DEBUGCANVASSIZE: {
  82033. width: number;
  82034. height: number;
  82035. };
  82036. private _byteFreqs;
  82037. private _byteTime;
  82038. private _floatFreqs;
  82039. private _webAudioAnalyser;
  82040. private _debugCanvas;
  82041. private _debugCanvasContext;
  82042. private _scene;
  82043. private _registerFunc;
  82044. private _audioEngine;
  82045. /**
  82046. * Creates a new analyser
  82047. * @param scene defines hosting scene
  82048. */
  82049. constructor(scene: Scene);
  82050. /**
  82051. * Get the number of data values you will have to play with for the visualization
  82052. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82053. * @returns a number
  82054. */
  82055. getFrequencyBinCount(): number;
  82056. /**
  82057. * Gets the current frequency data as a byte array
  82058. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82059. * @returns a Uint8Array
  82060. */
  82061. getByteFrequencyData(): Uint8Array;
  82062. /**
  82063. * Gets the current waveform as a byte array
  82064. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82065. * @returns a Uint8Array
  82066. */
  82067. getByteTimeDomainData(): Uint8Array;
  82068. /**
  82069. * Gets the current frequency data as a float array
  82070. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82071. * @returns a Float32Array
  82072. */
  82073. getFloatFrequencyData(): Float32Array;
  82074. /**
  82075. * Renders the debug canvas
  82076. */
  82077. drawDebugCanvas(): void;
  82078. /**
  82079. * Stops rendering the debug canvas and removes it
  82080. */
  82081. stopDebugCanvas(): void;
  82082. /**
  82083. * Connects two audio nodes
  82084. * @param inputAudioNode defines first node to connect
  82085. * @param outputAudioNode defines second node to connect
  82086. */
  82087. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82088. /**
  82089. * Releases all associated resources
  82090. */
  82091. dispose(): void;
  82092. }
  82093. }
  82094. declare module BABYLON {
  82095. /**
  82096. * This represents an audio engine and it is responsible
  82097. * to play, synchronize and analyse sounds throughout the application.
  82098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82099. */
  82100. export interface IAudioEngine extends IDisposable {
  82101. /**
  82102. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82103. */
  82104. readonly canUseWebAudio: boolean;
  82105. /**
  82106. * Gets the current AudioContext if available.
  82107. */
  82108. readonly audioContext: Nullable<AudioContext>;
  82109. /**
  82110. * The master gain node defines the global audio volume of your audio engine.
  82111. */
  82112. readonly masterGain: GainNode;
  82113. /**
  82114. * Gets whether or not mp3 are supported by your browser.
  82115. */
  82116. readonly isMP3supported: boolean;
  82117. /**
  82118. * Gets whether or not ogg are supported by your browser.
  82119. */
  82120. readonly isOGGsupported: boolean;
  82121. /**
  82122. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82123. * @ignoreNaming
  82124. */
  82125. WarnedWebAudioUnsupported: boolean;
  82126. /**
  82127. * Defines if the audio engine relies on a custom unlocked button.
  82128. * In this case, the embedded button will not be displayed.
  82129. */
  82130. useCustomUnlockedButton: boolean;
  82131. /**
  82132. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82133. */
  82134. readonly unlocked: boolean;
  82135. /**
  82136. * Event raised when audio has been unlocked on the browser.
  82137. */
  82138. onAudioUnlockedObservable: Observable<AudioEngine>;
  82139. /**
  82140. * Event raised when audio has been locked on the browser.
  82141. */
  82142. onAudioLockedObservable: Observable<AudioEngine>;
  82143. /**
  82144. * Flags the audio engine in Locked state.
  82145. * This happens due to new browser policies preventing audio to autoplay.
  82146. */
  82147. lock(): void;
  82148. /**
  82149. * Unlocks the audio engine once a user action has been done on the dom.
  82150. * This is helpful to resume play once browser policies have been satisfied.
  82151. */
  82152. unlock(): void;
  82153. }
  82154. /**
  82155. * This represents the default audio engine used in babylon.
  82156. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82158. */
  82159. export class AudioEngine implements IAudioEngine {
  82160. private _audioContext;
  82161. private _audioContextInitialized;
  82162. private _muteButton;
  82163. private _hostElement;
  82164. /**
  82165. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82166. */
  82167. canUseWebAudio: boolean;
  82168. /**
  82169. * The master gain node defines the global audio volume of your audio engine.
  82170. */
  82171. masterGain: GainNode;
  82172. /**
  82173. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82174. * @ignoreNaming
  82175. */
  82176. WarnedWebAudioUnsupported: boolean;
  82177. /**
  82178. * Gets whether or not mp3 are supported by your browser.
  82179. */
  82180. isMP3supported: boolean;
  82181. /**
  82182. * Gets whether or not ogg are supported by your browser.
  82183. */
  82184. isOGGsupported: boolean;
  82185. /**
  82186. * Gets whether audio has been unlocked on the device.
  82187. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82188. * a user interaction has happened.
  82189. */
  82190. unlocked: boolean;
  82191. /**
  82192. * Defines if the audio engine relies on a custom unlocked button.
  82193. * In this case, the embedded button will not be displayed.
  82194. */
  82195. useCustomUnlockedButton: boolean;
  82196. /**
  82197. * Event raised when audio has been unlocked on the browser.
  82198. */
  82199. onAudioUnlockedObservable: Observable<AudioEngine>;
  82200. /**
  82201. * Event raised when audio has been locked on the browser.
  82202. */
  82203. onAudioLockedObservable: Observable<AudioEngine>;
  82204. /**
  82205. * Gets the current AudioContext if available.
  82206. */
  82207. readonly audioContext: Nullable<AudioContext>;
  82208. private _connectedAnalyser;
  82209. /**
  82210. * Instantiates a new audio engine.
  82211. *
  82212. * There should be only one per page as some browsers restrict the number
  82213. * of audio contexts you can create.
  82214. * @param hostElement defines the host element where to display the mute icon if necessary
  82215. */
  82216. constructor(hostElement?: Nullable<HTMLElement>);
  82217. /**
  82218. * Flags the audio engine in Locked state.
  82219. * This happens due to new browser policies preventing audio to autoplay.
  82220. */
  82221. lock(): void;
  82222. /**
  82223. * Unlocks the audio engine once a user action has been done on the dom.
  82224. * This is helpful to resume play once browser policies have been satisfied.
  82225. */
  82226. unlock(): void;
  82227. private _resumeAudioContext;
  82228. private _initializeAudioContext;
  82229. private _tryToRun;
  82230. private _triggerRunningState;
  82231. private _triggerSuspendedState;
  82232. private _displayMuteButton;
  82233. private _moveButtonToTopLeft;
  82234. private _onResize;
  82235. private _hideMuteButton;
  82236. /**
  82237. * Destroy and release the resources associated with the audio ccontext.
  82238. */
  82239. dispose(): void;
  82240. /**
  82241. * Gets the global volume sets on the master gain.
  82242. * @returns the global volume if set or -1 otherwise
  82243. */
  82244. getGlobalVolume(): number;
  82245. /**
  82246. * Sets the global volume of your experience (sets on the master gain).
  82247. * @param newVolume Defines the new global volume of the application
  82248. */
  82249. setGlobalVolume(newVolume: number): void;
  82250. /**
  82251. * Connect the audio engine to an audio analyser allowing some amazing
  82252. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82254. * @param analyser The analyser to connect to the engine
  82255. */
  82256. connectToAnalyser(analyser: Analyser): void;
  82257. }
  82258. }
  82259. declare module BABYLON {
  82260. /**
  82261. * Interface used to present a loading screen while loading a scene
  82262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82263. */
  82264. export interface ILoadingScreen {
  82265. /**
  82266. * Function called to display the loading screen
  82267. */
  82268. displayLoadingUI: () => void;
  82269. /**
  82270. * Function called to hide the loading screen
  82271. */
  82272. hideLoadingUI: () => void;
  82273. /**
  82274. * Gets or sets the color to use for the background
  82275. */
  82276. loadingUIBackgroundColor: string;
  82277. /**
  82278. * Gets or sets the text to display while loading
  82279. */
  82280. loadingUIText: string;
  82281. }
  82282. /**
  82283. * Class used for the default loading screen
  82284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82285. */
  82286. export class DefaultLoadingScreen implements ILoadingScreen {
  82287. private _renderingCanvas;
  82288. private _loadingText;
  82289. private _loadingDivBackgroundColor;
  82290. private _loadingDiv;
  82291. private _loadingTextDiv;
  82292. /**
  82293. * Creates a new default loading screen
  82294. * @param _renderingCanvas defines the canvas used to render the scene
  82295. * @param _loadingText defines the default text to display
  82296. * @param _loadingDivBackgroundColor defines the default background color
  82297. */
  82298. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82299. /**
  82300. * Function called to display the loading screen
  82301. */
  82302. displayLoadingUI(): void;
  82303. /**
  82304. * Function called to hide the loading screen
  82305. */
  82306. hideLoadingUI(): void;
  82307. /**
  82308. * Gets or sets the text to display while loading
  82309. */
  82310. loadingUIText: string;
  82311. /**
  82312. * Gets or sets the color to use for the background
  82313. */
  82314. loadingUIBackgroundColor: string;
  82315. private _resizeLoadingUI;
  82316. }
  82317. }
  82318. declare module BABYLON {
  82319. /**
  82320. * Settings for finer control over video usage
  82321. */
  82322. export interface VideoTextureSettings {
  82323. /**
  82324. * Applies `autoplay` to video, if specified
  82325. */
  82326. autoPlay?: boolean;
  82327. /**
  82328. * Applies `loop` to video, if specified
  82329. */
  82330. loop?: boolean;
  82331. /**
  82332. * Automatically updates internal texture from video at every frame in the render loop
  82333. */
  82334. autoUpdateTexture: boolean;
  82335. /**
  82336. * Image src displayed during the video loading or until the user interacts with the video.
  82337. */
  82338. poster?: string;
  82339. }
  82340. /**
  82341. * If you want to display a video in your scene, this is the special texture for that.
  82342. * This special texture works similar to other textures, with the exception of a few parameters.
  82343. * @see https://doc.babylonjs.com/how_to/video_texture
  82344. */
  82345. export class VideoTexture extends Texture {
  82346. /**
  82347. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82348. */
  82349. readonly autoUpdateTexture: boolean;
  82350. /**
  82351. * The video instance used by the texture internally
  82352. */
  82353. readonly video: HTMLVideoElement;
  82354. private _onUserActionRequestedObservable;
  82355. /**
  82356. * Event triggerd when a dom action is required by the user to play the video.
  82357. * This happens due to recent changes in browser policies preventing video to auto start.
  82358. */
  82359. readonly onUserActionRequestedObservable: Observable<Texture>;
  82360. private _generateMipMaps;
  82361. private _engine;
  82362. private _stillImageCaptured;
  82363. private _displayingPosterTexture;
  82364. private _settings;
  82365. private _createInternalTextureOnEvent;
  82366. /**
  82367. * Creates a video texture.
  82368. * If you want to display a video in your scene, this is the special texture for that.
  82369. * This special texture works similar to other textures, with the exception of a few parameters.
  82370. * @see https://doc.babylonjs.com/how_to/video_texture
  82371. * @param name optional name, will detect from video source, if not defined
  82372. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82373. * @param scene is obviously the current scene.
  82374. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82375. * @param invertY is false by default but can be used to invert video on Y axis
  82376. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82377. * @param settings allows finer control over video usage
  82378. */
  82379. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82380. private _getName;
  82381. private _getVideo;
  82382. private _createInternalTexture;
  82383. private reset;
  82384. /**
  82385. * @hidden Internal method to initiate `update`.
  82386. */
  82387. _rebuild(): void;
  82388. /**
  82389. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82390. */
  82391. update(): void;
  82392. /**
  82393. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82394. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82395. */
  82396. updateTexture(isVisible: boolean): void;
  82397. protected _updateInternalTexture: () => void;
  82398. /**
  82399. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82400. * @param url New url.
  82401. */
  82402. updateURL(url: string): void;
  82403. /**
  82404. * Dispose the texture and release its associated resources.
  82405. */
  82406. dispose(): void;
  82407. /**
  82408. * Creates a video texture straight from your WebCam video feed.
  82409. * @param scene Define the scene the texture should be created in
  82410. * @param onReady Define a callback to triggered once the texture will be ready
  82411. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82412. */
  82413. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82414. minWidth: number;
  82415. maxWidth: number;
  82416. minHeight: number;
  82417. maxHeight: number;
  82418. deviceId: string;
  82419. }): void;
  82420. }
  82421. }
  82422. declare module BABYLON {
  82423. /**
  82424. * Interface for attribute information associated with buffer instanciation
  82425. */
  82426. export class InstancingAttributeInfo {
  82427. /**
  82428. * Index/offset of the attribute in the vertex shader
  82429. */
  82430. index: number;
  82431. /**
  82432. * size of the attribute, 1, 2, 3 or 4
  82433. */
  82434. attributeSize: number;
  82435. /**
  82436. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82437. * default is FLOAT
  82438. */
  82439. attribyteType: number;
  82440. /**
  82441. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82442. */
  82443. normalized: boolean;
  82444. /**
  82445. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82446. */
  82447. offset: number;
  82448. /**
  82449. * Name of the GLSL attribute, for debugging purpose only
  82450. */
  82451. attributeName: string;
  82452. }
  82453. /**
  82454. * Define options used to create a depth texture
  82455. */
  82456. export class DepthTextureCreationOptions {
  82457. /** Specifies whether or not a stencil should be allocated in the texture */
  82458. generateStencil?: boolean;
  82459. /** Specifies whether or not bilinear filtering is enable on the texture */
  82460. bilinearFiltering?: boolean;
  82461. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82462. comparisonFunction?: number;
  82463. /** Specifies if the created texture is a cube texture */
  82464. isCube?: boolean;
  82465. }
  82466. /**
  82467. * Class used to describe the capabilities of the engine relatively to the current browser
  82468. */
  82469. export class EngineCapabilities {
  82470. /** Maximum textures units per fragment shader */
  82471. maxTexturesImageUnits: number;
  82472. /** Maximum texture units per vertex shader */
  82473. maxVertexTextureImageUnits: number;
  82474. /** Maximum textures units in the entire pipeline */
  82475. maxCombinedTexturesImageUnits: number;
  82476. /** Maximum texture size */
  82477. maxTextureSize: number;
  82478. /** Maximum cube texture size */
  82479. maxCubemapTextureSize: number;
  82480. /** Maximum render texture size */
  82481. maxRenderTextureSize: number;
  82482. /** Maximum number of vertex attributes */
  82483. maxVertexAttribs: number;
  82484. /** Maximum number of varyings */
  82485. maxVaryingVectors: number;
  82486. /** Maximum number of uniforms per vertex shader */
  82487. maxVertexUniformVectors: number;
  82488. /** Maximum number of uniforms per fragment shader */
  82489. maxFragmentUniformVectors: number;
  82490. /** Defines if standard derivates (dx/dy) are supported */
  82491. standardDerivatives: boolean;
  82492. /** Defines if s3tc texture compression is supported */
  82493. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82494. /** Defines if pvrtc texture compression is supported */
  82495. pvrtc: any;
  82496. /** Defines if etc1 texture compression is supported */
  82497. etc1: any;
  82498. /** Defines if etc2 texture compression is supported */
  82499. etc2: any;
  82500. /** Defines if astc texture compression is supported */
  82501. astc: any;
  82502. /** Defines if float textures are supported */
  82503. textureFloat: boolean;
  82504. /** Defines if vertex array objects are supported */
  82505. vertexArrayObject: boolean;
  82506. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82507. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82508. /** Gets the maximum level of anisotropy supported */
  82509. maxAnisotropy: number;
  82510. /** Defines if instancing is supported */
  82511. instancedArrays: boolean;
  82512. /** Defines if 32 bits indices are supported */
  82513. uintIndices: boolean;
  82514. /** Defines if high precision shaders are supported */
  82515. highPrecisionShaderSupported: boolean;
  82516. /** Defines if depth reading in the fragment shader is supported */
  82517. fragmentDepthSupported: boolean;
  82518. /** Defines if float texture linear filtering is supported*/
  82519. textureFloatLinearFiltering: boolean;
  82520. /** Defines if rendering to float textures is supported */
  82521. textureFloatRender: boolean;
  82522. /** Defines if half float textures are supported*/
  82523. textureHalfFloat: boolean;
  82524. /** Defines if half float texture linear filtering is supported*/
  82525. textureHalfFloatLinearFiltering: boolean;
  82526. /** Defines if rendering to half float textures is supported */
  82527. textureHalfFloatRender: boolean;
  82528. /** Defines if textureLOD shader command is supported */
  82529. textureLOD: boolean;
  82530. /** Defines if draw buffers extension is supported */
  82531. drawBuffersExtension: boolean;
  82532. /** Defines if depth textures are supported */
  82533. depthTextureExtension: boolean;
  82534. /** Defines if float color buffer are supported */
  82535. colorBufferFloat: boolean;
  82536. /** Gets disjoint timer query extension (null if not supported) */
  82537. timerQuery: EXT_disjoint_timer_query;
  82538. /** Defines if timestamp can be used with timer query */
  82539. canUseTimestampForTimerQuery: boolean;
  82540. /** Function used to let the system compiles shaders in background */
  82541. parallelShaderCompile: {
  82542. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82543. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82544. COMPLETION_STATUS_KHR: number;
  82545. };
  82546. }
  82547. /** Interface defining initialization parameters for Engine class */
  82548. export interface EngineOptions extends WebGLContextAttributes {
  82549. /**
  82550. * Defines if the engine should no exceed a specified device ratio
  82551. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82552. */
  82553. limitDeviceRatio?: number;
  82554. /**
  82555. * Defines if webvr should be enabled automatically
  82556. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82557. */
  82558. autoEnableWebVR?: boolean;
  82559. /**
  82560. * Defines if webgl2 should be turned off even if supported
  82561. * @see http://doc.babylonjs.com/features/webgl2
  82562. */
  82563. disableWebGL2Support?: boolean;
  82564. /**
  82565. * Defines if webaudio should be initialized as well
  82566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82567. */
  82568. audioEngine?: boolean;
  82569. /**
  82570. * Defines if animations should run using a deterministic lock step
  82571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82572. */
  82573. deterministicLockstep?: boolean;
  82574. /** Defines the maximum steps to use with deterministic lock step mode */
  82575. lockstepMaxSteps?: number;
  82576. /**
  82577. * Defines that engine should ignore context lost events
  82578. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82579. */
  82580. doNotHandleContextLost?: boolean;
  82581. /**
  82582. * Defines that engine should ignore modifying touch action attribute and style
  82583. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82584. */
  82585. doNotHandleTouchAction?: boolean;
  82586. }
  82587. /**
  82588. * Defines the interface used by display changed events
  82589. */
  82590. export interface IDisplayChangedEventArgs {
  82591. /** Gets the vrDisplay object (if any) */
  82592. vrDisplay: Nullable<any>;
  82593. /** Gets a boolean indicating if webVR is supported */
  82594. vrSupported: boolean;
  82595. }
  82596. /**
  82597. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82598. */
  82599. export class Engine {
  82600. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82601. static ExceptionList: ({
  82602. key: string;
  82603. capture: string;
  82604. captureConstraint: number;
  82605. targets: string[];
  82606. } | {
  82607. key: string;
  82608. capture: null;
  82609. captureConstraint: null;
  82610. targets: string[];
  82611. })[];
  82612. /** Gets the list of created engines */
  82613. static readonly Instances: Engine[];
  82614. /**
  82615. * Gets the latest created engine
  82616. */
  82617. static readonly LastCreatedEngine: Nullable<Engine>;
  82618. /**
  82619. * Gets the latest created scene
  82620. */
  82621. static readonly LastCreatedScene: Nullable<Scene>;
  82622. /**
  82623. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82624. * @param flag defines which part of the materials must be marked as dirty
  82625. * @param predicate defines a predicate used to filter which materials should be affected
  82626. */
  82627. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82628. /**
  82629. * Hidden
  82630. */
  82631. static _TextureLoaders: IInternalTextureLoader[];
  82632. /** Defines that alpha blending is disabled */
  82633. static readonly ALPHA_DISABLE: number;
  82634. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82635. static readonly ALPHA_ADD: number;
  82636. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82637. static readonly ALPHA_COMBINE: number;
  82638. /** Defines that alpha blending to DEST - SRC * DEST */
  82639. static readonly ALPHA_SUBTRACT: number;
  82640. /** Defines that alpha blending to SRC * DEST */
  82641. static readonly ALPHA_MULTIPLY: number;
  82642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82643. static readonly ALPHA_MAXIMIZED: number;
  82644. /** Defines that alpha blending to SRC + DEST */
  82645. static readonly ALPHA_ONEONE: number;
  82646. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82647. static readonly ALPHA_PREMULTIPLIED: number;
  82648. /**
  82649. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82650. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82651. */
  82652. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82653. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82654. static readonly ALPHA_INTERPOLATE: number;
  82655. /**
  82656. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82657. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82658. */
  82659. static readonly ALPHA_SCREENMODE: number;
  82660. /** Defines that the ressource is not delayed*/
  82661. static readonly DELAYLOADSTATE_NONE: number;
  82662. /** Defines that the ressource was successfully delay loaded */
  82663. static readonly DELAYLOADSTATE_LOADED: number;
  82664. /** Defines that the ressource is currently delay loading */
  82665. static readonly DELAYLOADSTATE_LOADING: number;
  82666. /** Defines that the ressource is delayed and has not started loading */
  82667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82669. static readonly NEVER: number;
  82670. /** 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 */
  82671. static readonly ALWAYS: number;
  82672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82673. static readonly LESS: number;
  82674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82675. static readonly EQUAL: number;
  82676. /** 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 */
  82677. static readonly LEQUAL: number;
  82678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82679. static readonly GREATER: number;
  82680. /** 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 */
  82681. static readonly GEQUAL: number;
  82682. /** 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 */
  82683. static readonly NOTEQUAL: number;
  82684. /** Passed to stencilOperation to specify that stencil value must be kept */
  82685. static readonly KEEP: number;
  82686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82687. static readonly REPLACE: number;
  82688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82689. static readonly INCR: number;
  82690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82691. static readonly DECR: number;
  82692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82693. static readonly INVERT: number;
  82694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82695. static readonly INCR_WRAP: number;
  82696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82697. static readonly DECR_WRAP: number;
  82698. /** Texture is not repeating outside of 0..1 UVs */
  82699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82700. /** Texture is repeating outside of 0..1 UVs */
  82701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82702. /** Texture is repeating and mirrored */
  82703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82704. /** ALPHA */
  82705. static readonly TEXTUREFORMAT_ALPHA: number;
  82706. /** LUMINANCE */
  82707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82708. /** LUMINANCE_ALPHA */
  82709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82710. /** RGB */
  82711. static readonly TEXTUREFORMAT_RGB: number;
  82712. /** RGBA */
  82713. static readonly TEXTUREFORMAT_RGBA: number;
  82714. /** RED */
  82715. static readonly TEXTUREFORMAT_RED: number;
  82716. /** RED (2nd reference) */
  82717. static readonly TEXTUREFORMAT_R: number;
  82718. /** RG */
  82719. static readonly TEXTUREFORMAT_RG: number;
  82720. /** RED_INTEGER */
  82721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82722. /** RED_INTEGER (2nd reference) */
  82723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82724. /** RG_INTEGER */
  82725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82726. /** RGB_INTEGER */
  82727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82728. /** RGBA_INTEGER */
  82729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82730. /** UNSIGNED_BYTE */
  82731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82732. /** UNSIGNED_BYTE (2nd reference) */
  82733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82734. /** FLOAT */
  82735. static readonly TEXTURETYPE_FLOAT: number;
  82736. /** HALF_FLOAT */
  82737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82738. /** BYTE */
  82739. static readonly TEXTURETYPE_BYTE: number;
  82740. /** SHORT */
  82741. static readonly TEXTURETYPE_SHORT: number;
  82742. /** UNSIGNED_SHORT */
  82743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82744. /** INT */
  82745. static readonly TEXTURETYPE_INT: number;
  82746. /** UNSIGNED_INT */
  82747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82748. /** UNSIGNED_SHORT_4_4_4_4 */
  82749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82750. /** UNSIGNED_SHORT_5_5_5_1 */
  82751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82752. /** UNSIGNED_SHORT_5_6_5 */
  82753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82754. /** UNSIGNED_INT_2_10_10_10_REV */
  82755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82756. /** UNSIGNED_INT_24_8 */
  82757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82758. /** UNSIGNED_INT_10F_11F_11F_REV */
  82759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82760. /** UNSIGNED_INT_5_9_9_9_REV */
  82761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82764. /** nearest is mag = nearest and min = nearest and mip = linear */
  82765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82768. /** Trilinear is mag = linear and min = linear and mip = linear */
  82769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82770. /** nearest is mag = nearest and min = nearest and mip = linear */
  82771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82774. /** Trilinear is mag = linear and min = linear and mip = linear */
  82775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82776. /** mag = nearest and min = nearest and mip = nearest */
  82777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82778. /** mag = nearest and min = linear and mip = nearest */
  82779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82780. /** mag = nearest and min = linear and mip = linear */
  82781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82782. /** mag = nearest and min = linear and mip = none */
  82783. static readonly TEXTURE_NEAREST_LINEAR: number;
  82784. /** mag = nearest and min = nearest and mip = none */
  82785. static readonly TEXTURE_NEAREST_NEAREST: number;
  82786. /** mag = linear and min = nearest and mip = nearest */
  82787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82788. /** mag = linear and min = nearest and mip = linear */
  82789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82790. /** mag = linear and min = linear and mip = none */
  82791. static readonly TEXTURE_LINEAR_LINEAR: number;
  82792. /** mag = linear and min = nearest and mip = none */
  82793. static readonly TEXTURE_LINEAR_NEAREST: number;
  82794. /** Explicit coordinates mode */
  82795. static readonly TEXTURE_EXPLICIT_MODE: number;
  82796. /** Spherical coordinates mode */
  82797. static readonly TEXTURE_SPHERICAL_MODE: number;
  82798. /** Planar coordinates mode */
  82799. static readonly TEXTURE_PLANAR_MODE: number;
  82800. /** Cubic coordinates mode */
  82801. static readonly TEXTURE_CUBIC_MODE: number;
  82802. /** Projection coordinates mode */
  82803. static readonly TEXTURE_PROJECTION_MODE: number;
  82804. /** Skybox coordinates mode */
  82805. static readonly TEXTURE_SKYBOX_MODE: number;
  82806. /** Inverse Cubic coordinates mode */
  82807. static readonly TEXTURE_INVCUBIC_MODE: number;
  82808. /** Equirectangular coordinates mode */
  82809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82810. /** Equirectangular Fixed coordinates mode */
  82811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82812. /** Equirectangular Fixed Mirrored coordinates mode */
  82813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82815. static readonly SCALEMODE_FLOOR: number;
  82816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82817. static readonly SCALEMODE_NEAREST: number;
  82818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82819. static readonly SCALEMODE_CEILING: number;
  82820. /**
  82821. * Returns the current version of the framework
  82822. */
  82823. static readonly Version: string;
  82824. /**
  82825. * Returns a string describing the current engine
  82826. */
  82827. readonly description: string;
  82828. /**
  82829. * Gets or sets the epsilon value used by collision engine
  82830. */
  82831. static CollisionsEpsilon: number;
  82832. /**
  82833. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82834. */
  82835. static ShadersRepository: string;
  82836. /**
  82837. * Method called to create the default loading screen.
  82838. * This can be overriden in your own app.
  82839. * @param canvas The rendering canvas element
  82840. * @returns The loading screen
  82841. */
  82842. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82843. /**
  82844. * Method called to create the default rescale post process on each engine.
  82845. */
  82846. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82847. /**
  82848. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82849. */
  82850. forcePOTTextures: boolean;
  82851. /**
  82852. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82853. */
  82854. isFullscreen: boolean;
  82855. /**
  82856. * Gets a boolean indicating if the pointer is currently locked
  82857. */
  82858. isPointerLock: boolean;
  82859. /**
  82860. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82861. */
  82862. cullBackFaces: boolean;
  82863. /**
  82864. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82865. */
  82866. renderEvenInBackground: boolean;
  82867. /**
  82868. * Gets or sets a boolean indicating that cache can be kept between frames
  82869. */
  82870. preventCacheWipeBetweenFrames: boolean;
  82871. /**
  82872. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82873. **/
  82874. enableOfflineSupport: boolean;
  82875. /**
  82876. * 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)
  82877. **/
  82878. disableManifestCheck: boolean;
  82879. /**
  82880. * Gets the list of created scenes
  82881. */
  82882. scenes: Scene[];
  82883. /**
  82884. * Event raised when a new scene is created
  82885. */
  82886. onNewSceneAddedObservable: Observable<Scene>;
  82887. /**
  82888. * Gets the list of created postprocesses
  82889. */
  82890. postProcesses: PostProcess[];
  82891. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82892. validateShaderPrograms: boolean;
  82893. /**
  82894. * Observable event triggered each time the rendering canvas is resized
  82895. */
  82896. onResizeObservable: Observable<Engine>;
  82897. /**
  82898. * Observable event triggered each time the canvas loses focus
  82899. */
  82900. onCanvasBlurObservable: Observable<Engine>;
  82901. /**
  82902. * Observable event triggered each time the canvas gains focus
  82903. */
  82904. onCanvasFocusObservable: Observable<Engine>;
  82905. /**
  82906. * Observable event triggered each time the canvas receives pointerout event
  82907. */
  82908. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82909. /**
  82910. * Observable event triggered before each texture is initialized
  82911. */
  82912. onBeforeTextureInitObservable: Observable<Texture>;
  82913. private _vrDisplay;
  82914. private _vrSupported;
  82915. private _oldSize;
  82916. private _oldHardwareScaleFactor;
  82917. private _vrExclusivePointerMode;
  82918. private _webVRInitPromise;
  82919. /**
  82920. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82921. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82922. */
  82923. readonly isInVRExclusivePointerMode: boolean;
  82924. /**
  82925. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82926. */
  82927. disableUniformBuffers: boolean;
  82928. /** @hidden */
  82929. _uniformBuffers: UniformBuffer[];
  82930. /**
  82931. * Gets a boolean indicating that the engine supports uniform buffers
  82932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82933. */
  82934. readonly supportsUniformBuffers: boolean;
  82935. /**
  82936. * Observable raised when the engine begins a new frame
  82937. */
  82938. onBeginFrameObservable: Observable<Engine>;
  82939. /**
  82940. * If set, will be used to request the next animation frame for the render loop
  82941. */
  82942. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  82943. /**
  82944. * Observable raised when the engine ends the current frame
  82945. */
  82946. onEndFrameObservable: Observable<Engine>;
  82947. /**
  82948. * Observable raised when the engine is about to compile a shader
  82949. */
  82950. onBeforeShaderCompilationObservable: Observable<Engine>;
  82951. /**
  82952. * Observable raised when the engine has jsut compiled a shader
  82953. */
  82954. onAfterShaderCompilationObservable: Observable<Engine>;
  82955. /** @hidden */
  82956. _gl: WebGLRenderingContext;
  82957. private _renderingCanvas;
  82958. private _windowIsBackground;
  82959. private _webGLVersion;
  82960. /**
  82961. * Gets a boolean indicating that only power of 2 textures are supported
  82962. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  82963. */
  82964. readonly needPOTTextures: boolean;
  82965. /** @hidden */
  82966. _badOS: boolean;
  82967. /** @hidden */
  82968. _badDesktopOS: boolean;
  82969. /**
  82970. * Gets or sets a value indicating if we want to disable texture binding optimization.
  82971. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  82972. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  82973. */
  82974. disableTextureBindingOptimization: boolean;
  82975. /**
  82976. * Gets the audio engine
  82977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82978. * @ignorenaming
  82979. */
  82980. static audioEngine: IAudioEngine;
  82981. /**
  82982. * Default AudioEngine factory responsible of creating the Audio Engine.
  82983. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  82984. */
  82985. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  82986. /**
  82987. * Default offline support factory responsible of creating a tool used to store data locally.
  82988. * By default, this will create a Database object if the workload has been embedded.
  82989. */
  82990. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  82991. private _onFocus;
  82992. private _onBlur;
  82993. private _onCanvasPointerOut;
  82994. private _onCanvasBlur;
  82995. private _onCanvasFocus;
  82996. private _onFullscreenChange;
  82997. private _onPointerLockChange;
  82998. private _onVRDisplayPointerRestricted;
  82999. private _onVRDisplayPointerUnrestricted;
  83000. private _onVrDisplayConnect;
  83001. private _onVrDisplayDisconnect;
  83002. private _onVrDisplayPresentChange;
  83003. /**
  83004. * Observable signaled when VR display mode changes
  83005. */
  83006. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83007. /**
  83008. * Observable signaled when VR request present is complete
  83009. */
  83010. onVRRequestPresentComplete: Observable<boolean>;
  83011. /**
  83012. * Observable signaled when VR request present starts
  83013. */
  83014. onVRRequestPresentStart: Observable<Engine>;
  83015. private _hardwareScalingLevel;
  83016. /** @hidden */
  83017. protected _caps: EngineCapabilities;
  83018. private _pointerLockRequested;
  83019. private _isStencilEnable;
  83020. private _colorWrite;
  83021. private _loadingScreen;
  83022. /** @hidden */
  83023. _drawCalls: PerfCounter;
  83024. /** @hidden */
  83025. _textureCollisions: PerfCounter;
  83026. private _glVersion;
  83027. private _glRenderer;
  83028. private _glVendor;
  83029. private _videoTextureSupported;
  83030. private _renderingQueueLaunched;
  83031. private _activeRenderLoops;
  83032. private _deterministicLockstep;
  83033. private _lockstepMaxSteps;
  83034. /**
  83035. * Observable signaled when a context lost event is raised
  83036. */
  83037. onContextLostObservable: Observable<Engine>;
  83038. /**
  83039. * Observable signaled when a context restored event is raised
  83040. */
  83041. onContextRestoredObservable: Observable<Engine>;
  83042. private _onContextLost;
  83043. private _onContextRestored;
  83044. private _contextWasLost;
  83045. private _doNotHandleContextLost;
  83046. /**
  83047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83049. */
  83050. doNotHandleContextLost: boolean;
  83051. private _performanceMonitor;
  83052. private _fps;
  83053. private _deltaTime;
  83054. /**
  83055. * Turn this value on if you want to pause FPS computation when in background
  83056. */
  83057. disablePerformanceMonitorInBackground: boolean;
  83058. /**
  83059. * Gets the performance monitor attached to this engine
  83060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83061. */
  83062. readonly performanceMonitor: PerformanceMonitor;
  83063. /** @hidden */
  83064. protected _depthCullingState: _DepthCullingState;
  83065. /** @hidden */
  83066. protected _stencilState: _StencilState;
  83067. /** @hidden */
  83068. protected _alphaState: _AlphaState;
  83069. /** @hidden */
  83070. protected _alphaMode: number;
  83071. protected _internalTexturesCache: InternalTexture[];
  83072. /** @hidden */
  83073. protected _activeChannel: number;
  83074. private _currentTextureChannel;
  83075. /** @hidden */
  83076. protected _boundTexturesCache: {
  83077. [key: string]: Nullable<InternalTexture>;
  83078. };
  83079. /** @hidden */
  83080. protected _currentEffect: Nullable<Effect>;
  83081. /** @hidden */
  83082. protected _currentProgram: Nullable<WebGLProgram>;
  83083. private _compiledEffects;
  83084. private _vertexAttribArraysEnabled;
  83085. /** @hidden */
  83086. protected _cachedViewport: Nullable<Viewport>;
  83087. private _cachedVertexArrayObject;
  83088. /** @hidden */
  83089. protected _cachedVertexBuffers: any;
  83090. /** @hidden */
  83091. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83092. /** @hidden */
  83093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83094. /** @hidden */
  83095. protected _currentRenderTarget: Nullable<InternalTexture>;
  83096. private _uintIndicesCurrentlySet;
  83097. private _currentBoundBuffer;
  83098. /** @hidden */
  83099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83100. private _currentBufferPointers;
  83101. private _currentInstanceLocations;
  83102. private _currentInstanceBuffers;
  83103. private _textureUnits;
  83104. private _firstBoundInternalTextureTracker;
  83105. private _lastBoundInternalTextureTracker;
  83106. private _workingCanvas;
  83107. private _workingContext;
  83108. private _rescalePostProcess;
  83109. private _dummyFramebuffer;
  83110. private _externalData;
  83111. private _bindedRenderFunction;
  83112. private _vaoRecordInProgress;
  83113. private _mustWipeVertexAttributes;
  83114. private _emptyTexture;
  83115. private _emptyCubeTexture;
  83116. private _emptyTexture3D;
  83117. /** @hidden */
  83118. _frameHandler: number;
  83119. private _nextFreeTextureSlots;
  83120. private _maxSimultaneousTextures;
  83121. private _activeRequests;
  83122. private _texturesSupported;
  83123. private _textureFormatInUse;
  83124. /**
  83125. * Gets the list of texture formats supported
  83126. */
  83127. readonly texturesSupported: Array<string>;
  83128. /**
  83129. * Gets the list of texture formats in use
  83130. */
  83131. readonly textureFormatInUse: Nullable<string>;
  83132. /**
  83133. * Gets the current viewport
  83134. */
  83135. readonly currentViewport: Nullable<Viewport>;
  83136. /**
  83137. * Gets the default empty texture
  83138. */
  83139. readonly emptyTexture: InternalTexture;
  83140. /**
  83141. * Gets the default empty 3D texture
  83142. */
  83143. readonly emptyTexture3D: InternalTexture;
  83144. /**
  83145. * Gets the default empty cube texture
  83146. */
  83147. readonly emptyCubeTexture: InternalTexture;
  83148. /**
  83149. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83150. */
  83151. readonly premultipliedAlpha: boolean;
  83152. /**
  83153. * Creates a new engine
  83154. * @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
  83155. * @param antialias defines enable antialiasing (default: false)
  83156. * @param options defines further options to be sent to the getContext() function
  83157. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83158. */
  83159. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83160. private _disableTouchAction;
  83161. private _rebuildInternalTextures;
  83162. private _rebuildEffects;
  83163. /**
  83164. * Gets a boolean indicating if all created effects are ready
  83165. * @returns true if all effects are ready
  83166. */
  83167. areAllEffectsReady(): boolean;
  83168. private _rebuildBuffers;
  83169. private _initGLContext;
  83170. /**
  83171. * Gets version of the current webGL context
  83172. */
  83173. readonly webGLVersion: number;
  83174. /**
  83175. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83176. */
  83177. readonly isStencilEnable: boolean;
  83178. private _prepareWorkingCanvas;
  83179. /**
  83180. * Reset the texture cache to empty state
  83181. */
  83182. resetTextureCache(): void;
  83183. /**
  83184. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83186. * @returns true if engine is in deterministic lock step mode
  83187. */
  83188. isDeterministicLockStep(): boolean;
  83189. /**
  83190. * Gets the max steps when engine is running in deterministic lock step
  83191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83192. * @returns the max steps
  83193. */
  83194. getLockstepMaxSteps(): number;
  83195. /**
  83196. * Gets an object containing information about the current webGL context
  83197. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83198. */
  83199. getGlInfo(): {
  83200. vendor: string;
  83201. renderer: string;
  83202. version: string;
  83203. };
  83204. /**
  83205. * Gets current aspect ratio
  83206. * @param camera defines the camera to use to get the aspect ratio
  83207. * @param useScreen defines if screen size must be used (or the current render target if any)
  83208. * @returns a number defining the aspect ratio
  83209. */
  83210. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83211. /**
  83212. * Gets current screen aspect ratio
  83213. * @returns a number defining the aspect ratio
  83214. */
  83215. getScreenAspectRatio(): number;
  83216. /**
  83217. * Gets the current render width
  83218. * @param useScreen defines if screen size must be used (or the current render target if any)
  83219. * @returns a number defining the current render width
  83220. */
  83221. getRenderWidth(useScreen?: boolean): number;
  83222. /**
  83223. * Gets the current render height
  83224. * @param useScreen defines if screen size must be used (or the current render target if any)
  83225. * @returns a number defining the current render height
  83226. */
  83227. getRenderHeight(useScreen?: boolean): number;
  83228. /**
  83229. * Gets the HTML canvas attached with the current webGL context
  83230. * @returns a HTML canvas
  83231. */
  83232. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83233. /**
  83234. * Gets the client rect of the HTML canvas attached with the current webGL context
  83235. * @returns a client rectanglee
  83236. */
  83237. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83238. /**
  83239. * Defines the hardware scaling level.
  83240. * By default the hardware scaling level is computed from the window device ratio.
  83241. * 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.
  83242. * @param level defines the level to use
  83243. */
  83244. setHardwareScalingLevel(level: number): void;
  83245. /**
  83246. * Gets the current hardware scaling level.
  83247. * By default the hardware scaling level is computed from the window device ratio.
  83248. * 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.
  83249. * @returns a number indicating the current hardware scaling level
  83250. */
  83251. getHardwareScalingLevel(): number;
  83252. /**
  83253. * Gets the list of loaded textures
  83254. * @returns an array containing all loaded textures
  83255. */
  83256. getLoadedTexturesCache(): InternalTexture[];
  83257. /**
  83258. * Gets the object containing all engine capabilities
  83259. * @returns the EngineCapabilities object
  83260. */
  83261. getCaps(): EngineCapabilities;
  83262. /**
  83263. * Gets the current depth function
  83264. * @returns a number defining the depth function
  83265. */
  83266. getDepthFunction(): Nullable<number>;
  83267. /**
  83268. * Sets the current depth function
  83269. * @param depthFunc defines the function to use
  83270. */
  83271. setDepthFunction(depthFunc: number): void;
  83272. /**
  83273. * Sets the current depth function to GREATER
  83274. */
  83275. setDepthFunctionToGreater(): void;
  83276. /**
  83277. * Sets the current depth function to GEQUAL
  83278. */
  83279. setDepthFunctionToGreaterOrEqual(): void;
  83280. /**
  83281. * Sets the current depth function to LESS
  83282. */
  83283. setDepthFunctionToLess(): void;
  83284. /**
  83285. * Sets the current depth function to LEQUAL
  83286. */
  83287. setDepthFunctionToLessOrEqual(): void;
  83288. /**
  83289. * Gets a boolean indicating if stencil buffer is enabled
  83290. * @returns the current stencil buffer state
  83291. */
  83292. getStencilBuffer(): boolean;
  83293. /**
  83294. * Enable or disable the stencil buffer
  83295. * @param enable defines if the stencil buffer must be enabled or disabled
  83296. */
  83297. setStencilBuffer(enable: boolean): void;
  83298. /**
  83299. * Gets the current stencil mask
  83300. * @returns a number defining the new stencil mask to use
  83301. */
  83302. getStencilMask(): number;
  83303. /**
  83304. * Sets the current stencil mask
  83305. * @param mask defines the new stencil mask to use
  83306. */
  83307. setStencilMask(mask: number): void;
  83308. /**
  83309. * Gets the current stencil function
  83310. * @returns a number defining the stencil function to use
  83311. */
  83312. getStencilFunction(): number;
  83313. /**
  83314. * Gets the current stencil reference value
  83315. * @returns a number defining the stencil reference value to use
  83316. */
  83317. getStencilFunctionReference(): number;
  83318. /**
  83319. * Gets the current stencil mask
  83320. * @returns a number defining the stencil mask to use
  83321. */
  83322. getStencilFunctionMask(): number;
  83323. /**
  83324. * Sets the current stencil function
  83325. * @param stencilFunc defines the new stencil function to use
  83326. */
  83327. setStencilFunction(stencilFunc: number): void;
  83328. /**
  83329. * Sets the current stencil reference
  83330. * @param reference defines the new stencil reference to use
  83331. */
  83332. setStencilFunctionReference(reference: number): void;
  83333. /**
  83334. * Sets the current stencil mask
  83335. * @param mask defines the new stencil mask to use
  83336. */
  83337. setStencilFunctionMask(mask: number): void;
  83338. /**
  83339. * Gets the current stencil operation when stencil fails
  83340. * @returns a number defining stencil operation to use when stencil fails
  83341. */
  83342. getStencilOperationFail(): number;
  83343. /**
  83344. * Gets the current stencil operation when depth fails
  83345. * @returns a number defining stencil operation to use when depth fails
  83346. */
  83347. getStencilOperationDepthFail(): number;
  83348. /**
  83349. * Gets the current stencil operation when stencil passes
  83350. * @returns a number defining stencil operation to use when stencil passes
  83351. */
  83352. getStencilOperationPass(): number;
  83353. /**
  83354. * Sets the stencil operation to use when stencil fails
  83355. * @param operation defines the stencil operation to use when stencil fails
  83356. */
  83357. setStencilOperationFail(operation: number): void;
  83358. /**
  83359. * Sets the stencil operation to use when depth fails
  83360. * @param operation defines the stencil operation to use when depth fails
  83361. */
  83362. setStencilOperationDepthFail(operation: number): void;
  83363. /**
  83364. * Sets the stencil operation to use when stencil passes
  83365. * @param operation defines the stencil operation to use when stencil passes
  83366. */
  83367. setStencilOperationPass(operation: number): void;
  83368. /**
  83369. * Sets a boolean indicating if the dithering state is enabled or disabled
  83370. * @param value defines the dithering state
  83371. */
  83372. setDitheringState(value: boolean): void;
  83373. /**
  83374. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83375. * @param value defines the rasterizer state
  83376. */
  83377. setRasterizerState(value: boolean): void;
  83378. /**
  83379. * stop executing a render loop function and remove it from the execution array
  83380. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83381. */
  83382. stopRenderLoop(renderFunction?: () => void): void;
  83383. /** @hidden */
  83384. _renderLoop(): void;
  83385. /**
  83386. * Register and execute a render loop. The engine can have more than one render function
  83387. * @param renderFunction defines the function to continuously execute
  83388. */
  83389. runRenderLoop(renderFunction: () => void): void;
  83390. /**
  83391. * Toggle full screen mode
  83392. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83393. */
  83394. switchFullscreen(requestPointerLock: boolean): void;
  83395. /**
  83396. * Enters full screen mode
  83397. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83398. */
  83399. enterFullscreen(requestPointerLock: boolean): void;
  83400. /**
  83401. * Exits full screen mode
  83402. */
  83403. exitFullscreen(): void;
  83404. /**
  83405. * Clear the current render buffer or the current render target (if any is set up)
  83406. * @param color defines the color to use
  83407. * @param backBuffer defines if the back buffer must be cleared
  83408. * @param depth defines if the depth buffer must be cleared
  83409. * @param stencil defines if the stencil buffer must be cleared
  83410. */
  83411. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83412. /**
  83413. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83414. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83415. * @param y defines the y-coordinate of the corner of the clear rectangle
  83416. * @param width defines the width of the clear rectangle
  83417. * @param height defines the height of the clear rectangle
  83418. * @param clearColor defines the clear color
  83419. */
  83420. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83421. /**
  83422. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83423. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83424. * @param y defines the y-coordinate of the corner of the clear rectangle
  83425. * @param width defines the width of the clear rectangle
  83426. * @param height defines the height of the clear rectangle
  83427. */
  83428. enableScissor(x: number, y: number, width: number, height: number): void;
  83429. /**
  83430. * Disable previously set scissor test rectangle
  83431. */
  83432. disableScissor(): void;
  83433. private _viewportCached;
  83434. /** @hidden */
  83435. _viewport(x: number, y: number, width: number, height: number): void;
  83436. /**
  83437. * Set the WebGL's viewport
  83438. * @param viewport defines the viewport element to be used
  83439. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83440. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83441. */
  83442. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83443. /**
  83444. * Directly set the WebGL Viewport
  83445. * @param x defines the x coordinate of the viewport (in screen space)
  83446. * @param y defines the y coordinate of the viewport (in screen space)
  83447. * @param width defines the width of the viewport (in screen space)
  83448. * @param height defines the height of the viewport (in screen space)
  83449. * @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
  83450. */
  83451. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83452. /**
  83453. * Begin a new frame
  83454. */
  83455. beginFrame(): void;
  83456. /**
  83457. * Enf the current frame
  83458. */
  83459. endFrame(): void;
  83460. /**
  83461. * Resize the view according to the canvas' size
  83462. */
  83463. resize(): void;
  83464. /**
  83465. * Force a specific size of the canvas
  83466. * @param width defines the new canvas' width
  83467. * @param height defines the new canvas' height
  83468. */
  83469. setSize(width: number, height: number): void;
  83470. /**
  83471. * Gets a boolean indicating if a webVR device was detected
  83472. * @returns true if a webVR device was detected
  83473. */
  83474. isVRDevicePresent(): boolean;
  83475. /**
  83476. * Gets the current webVR device
  83477. * @returns the current webVR device (or null)
  83478. */
  83479. getVRDevice(): any;
  83480. /**
  83481. * Initializes a webVR display and starts listening to display change events
  83482. * The onVRDisplayChangedObservable will be notified upon these changes
  83483. * @returns The onVRDisplayChangedObservable
  83484. */
  83485. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83486. /**
  83487. * Initializes a webVR display and starts listening to display change events
  83488. * The onVRDisplayChangedObservable will be notified upon these changes
  83489. * @returns A promise containing a VRDisplay and if vr is supported
  83490. */
  83491. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83492. /**
  83493. * Call this function to switch to webVR mode
  83494. * Will do nothing if webVR is not supported or if there is no webVR device
  83495. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83496. */
  83497. enableVR(): void;
  83498. /**
  83499. * Call this function to leave webVR mode
  83500. * Will do nothing if webVR is not supported or if there is no webVR device
  83501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83502. */
  83503. disableVR(): void;
  83504. private _onVRFullScreenTriggered;
  83505. private _getVRDisplaysAsync;
  83506. /**
  83507. * Binds the frame buffer to the specified texture.
  83508. * @param texture The texture to render to or null for the default canvas
  83509. * @param faceIndex The face of the texture to render to in case of cube texture
  83510. * @param requiredWidth The width of the target to render to
  83511. * @param requiredHeight The height of the target to render to
  83512. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83513. * @param depthStencilTexture The depth stencil texture to use to render
  83514. * @param lodLevel defines le lod level to bind to the frame buffer
  83515. */
  83516. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83517. private bindUnboundFramebuffer;
  83518. /**
  83519. * Unbind the current render target texture from the webGL context
  83520. * @param texture defines the render target texture to unbind
  83521. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83522. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83523. */
  83524. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83525. /**
  83526. * Unbind a list of render target textures from the webGL context
  83527. * This is used only when drawBuffer extension or webGL2 are active
  83528. * @param textures defines the render target textures to unbind
  83529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83531. */
  83532. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83533. /**
  83534. * Force the mipmap generation for the given render target texture
  83535. * @param texture defines the render target texture to use
  83536. */
  83537. generateMipMapsForCubemap(texture: InternalTexture): void;
  83538. /**
  83539. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83540. */
  83541. flushFramebuffer(): void;
  83542. /**
  83543. * Unbind the current render target and bind the default framebuffer
  83544. */
  83545. restoreDefaultFramebuffer(): void;
  83546. /**
  83547. * Create an uniform buffer
  83548. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83549. * @param elements defines the content of the uniform buffer
  83550. * @returns the webGL uniform buffer
  83551. */
  83552. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83553. /**
  83554. * Create a dynamic uniform buffer
  83555. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83556. * @param elements defines the content of the uniform buffer
  83557. * @returns the webGL uniform buffer
  83558. */
  83559. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83560. /**
  83561. * Update an existing uniform buffer
  83562. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83563. * @param uniformBuffer defines the target uniform buffer
  83564. * @param elements defines the content to update
  83565. * @param offset defines the offset in the uniform buffer where update should start
  83566. * @param count defines the size of the data to update
  83567. */
  83568. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83569. private _resetVertexBufferBinding;
  83570. /**
  83571. * Creates a vertex buffer
  83572. * @param data the data for the vertex buffer
  83573. * @returns the new WebGL static buffer
  83574. */
  83575. createVertexBuffer(data: DataArray): WebGLBuffer;
  83576. /**
  83577. * Creates a dynamic vertex buffer
  83578. * @param data the data for the dynamic vertex buffer
  83579. * @returns the new WebGL dynamic buffer
  83580. */
  83581. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83582. /**
  83583. * Update a dynamic index buffer
  83584. * @param indexBuffer defines the target index buffer
  83585. * @param indices defines the data to update
  83586. * @param offset defines the offset in the target index buffer where update should start
  83587. */
  83588. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83589. /**
  83590. * Updates a dynamic vertex buffer.
  83591. * @param vertexBuffer the vertex buffer to update
  83592. * @param data the data used to update the vertex buffer
  83593. * @param byteOffset the byte offset of the data
  83594. * @param byteLength the byte length of the data
  83595. */
  83596. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83597. private _resetIndexBufferBinding;
  83598. /**
  83599. * Creates a new index buffer
  83600. * @param indices defines the content of the index buffer
  83601. * @param updatable defines if the index buffer must be updatable
  83602. * @returns a new webGL buffer
  83603. */
  83604. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83605. /**
  83606. * Bind a webGL buffer to the webGL context
  83607. * @param buffer defines the buffer to bind
  83608. */
  83609. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83610. /**
  83611. * Bind an uniform buffer to the current webGL context
  83612. * @param buffer defines the buffer to bind
  83613. */
  83614. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83615. /**
  83616. * Bind a buffer to the current webGL context at a given location
  83617. * @param buffer defines the buffer to bind
  83618. * @param location defines the index where to bind the buffer
  83619. */
  83620. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83621. /**
  83622. * Bind a specific block at a given index in a specific shader program
  83623. * @param shaderProgram defines the shader program
  83624. * @param blockName defines the block name
  83625. * @param index defines the index where to bind the block
  83626. */
  83627. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83628. private bindIndexBuffer;
  83629. private bindBuffer;
  83630. /**
  83631. * update the bound buffer with the given data
  83632. * @param data defines the data to update
  83633. */
  83634. updateArrayBuffer(data: Float32Array): void;
  83635. private _vertexAttribPointer;
  83636. private _bindIndexBufferWithCache;
  83637. private _bindVertexBuffersAttributes;
  83638. /**
  83639. * Records a vertex array object
  83640. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83641. * @param vertexBuffers defines the list of vertex buffers to store
  83642. * @param indexBuffer defines the index buffer to store
  83643. * @param effect defines the effect to store
  83644. * @returns the new vertex array object
  83645. */
  83646. recordVertexArrayObject(vertexBuffers: {
  83647. [key: string]: VertexBuffer;
  83648. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83649. /**
  83650. * Bind a specific vertex array object
  83651. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83652. * @param vertexArrayObject defines the vertex array object to bind
  83653. * @param indexBuffer defines the index buffer to bind
  83654. */
  83655. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83656. /**
  83657. * Bind webGl buffers directly to the webGL context
  83658. * @param vertexBuffer defines the vertex buffer to bind
  83659. * @param indexBuffer defines the index buffer to bind
  83660. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83661. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83662. * @param effect defines the effect associated with the vertex buffer
  83663. */
  83664. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83665. private _unbindVertexArrayObject;
  83666. /**
  83667. * Bind a list of vertex buffers to the webGL context
  83668. * @param vertexBuffers defines the list of vertex buffers to bind
  83669. * @param indexBuffer defines the index buffer to bind
  83670. * @param effect defines the effect associated with the vertex buffers
  83671. */
  83672. bindBuffers(vertexBuffers: {
  83673. [key: string]: Nullable<VertexBuffer>;
  83674. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83675. /**
  83676. * Unbind all instance attributes
  83677. */
  83678. unbindInstanceAttributes(): void;
  83679. /**
  83680. * Release and free the memory of a vertex array object
  83681. * @param vao defines the vertex array object to delete
  83682. */
  83683. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83684. /** @hidden */
  83685. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83686. /**
  83687. * Creates a webGL buffer to use with instanciation
  83688. * @param capacity defines the size of the buffer
  83689. * @returns the webGL buffer
  83690. */
  83691. createInstancesBuffer(capacity: number): WebGLBuffer;
  83692. /**
  83693. * Delete a webGL buffer used with instanciation
  83694. * @param buffer defines the webGL buffer to delete
  83695. */
  83696. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83697. /**
  83698. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83699. * @param instancesBuffer defines the webGL buffer to update and bind
  83700. * @param data defines the data to store in the buffer
  83701. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83702. */
  83703. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83704. /**
  83705. * Apply all cached states (depth, culling, stencil and alpha)
  83706. */
  83707. applyStates(): void;
  83708. /**
  83709. * Send a draw order
  83710. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83711. * @param indexStart defines the starting index
  83712. * @param indexCount defines the number of index to draw
  83713. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83714. */
  83715. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83716. /**
  83717. * Draw a list of points
  83718. * @param verticesStart defines the index of first vertex to draw
  83719. * @param verticesCount defines the count of vertices to draw
  83720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83721. */
  83722. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83723. /**
  83724. * Draw a list of unindexed primitives
  83725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83726. * @param verticesStart defines the index of first vertex to draw
  83727. * @param verticesCount defines the count of vertices to draw
  83728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83729. */
  83730. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83731. /**
  83732. * Draw a list of indexed primitives
  83733. * @param fillMode defines the primitive to use
  83734. * @param indexStart defines the starting index
  83735. * @param indexCount defines the number of index to draw
  83736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83737. */
  83738. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83739. /**
  83740. * Draw a list of unindexed primitives
  83741. * @param fillMode defines the primitive to use
  83742. * @param verticesStart defines the index of first vertex to draw
  83743. * @param verticesCount defines the count of vertices to draw
  83744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83745. */
  83746. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83747. private _drawMode;
  83748. /** @hidden */
  83749. _releaseEffect(effect: Effect): void;
  83750. /** @hidden */
  83751. _deleteProgram(program: WebGLProgram): void;
  83752. /**
  83753. * Create a new effect (used to store vertex/fragment shaders)
  83754. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83755. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83756. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83757. * @param samplers defines an array of string used to represent textures
  83758. * @param defines defines the string containing the defines to use to compile the shaders
  83759. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83760. * @param onCompiled defines a function to call when the effect creation is successful
  83761. * @param onError defines a function to call when the effect creation has failed
  83762. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83763. * @returns the new Effect
  83764. */
  83765. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  83766. private _compileShader;
  83767. private _compileRawShader;
  83768. /**
  83769. * Directly creates a webGL program
  83770. * @param vertexCode defines the vertex shader code to use
  83771. * @param fragmentCode defines the fragment shader code to use
  83772. * @param context defines the webGL context to use (if not set, the current one will be used)
  83773. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83774. * @returns the new webGL program
  83775. */
  83776. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83777. /**
  83778. * Creates a webGL program
  83779. * @param vertexCode defines the vertex shader code to use
  83780. * @param fragmentCode defines the fragment shader code to use
  83781. * @param defines defines the string containing the defines to use to compile the shaders
  83782. * @param context defines the webGL context to use (if not set, the current one will be used)
  83783. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83784. * @returns the new webGL program
  83785. */
  83786. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83787. private _createShaderProgram;
  83788. private _finalizeProgram;
  83789. /** @hidden */
  83790. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83791. /** @hidden */
  83792. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83793. /**
  83794. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83795. * @param shaderProgram defines the webGL program to use
  83796. * @param uniformsNames defines the list of uniform names
  83797. * @returns an array of webGL uniform locations
  83798. */
  83799. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83800. /**
  83801. * Gets the lsit of active attributes for a given webGL program
  83802. * @param shaderProgram defines the webGL program to use
  83803. * @param attributesNames defines the list of attribute names to get
  83804. * @returns an array of indices indicating the offset of each attribute
  83805. */
  83806. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83807. /**
  83808. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83809. * @param effect defines the effect to activate
  83810. */
  83811. enableEffect(effect: Nullable<Effect>): void;
  83812. /**
  83813. * Set the value of an uniform to an array of int32
  83814. * @param uniform defines the webGL uniform location where to store the value
  83815. * @param array defines the array of int32 to store
  83816. */
  83817. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83818. /**
  83819. * Set the value of an uniform to an array of int32 (stored as vec2)
  83820. * @param uniform defines the webGL uniform location where to store the value
  83821. * @param array defines the array of int32 to store
  83822. */
  83823. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83824. /**
  83825. * Set the value of an uniform to an array of int32 (stored as vec3)
  83826. * @param uniform defines the webGL uniform location where to store the value
  83827. * @param array defines the array of int32 to store
  83828. */
  83829. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83830. /**
  83831. * Set the value of an uniform to an array of int32 (stored as vec4)
  83832. * @param uniform defines the webGL uniform location where to store the value
  83833. * @param array defines the array of int32 to store
  83834. */
  83835. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83836. /**
  83837. * Set the value of an uniform to an array of float32
  83838. * @param uniform defines the webGL uniform location where to store the value
  83839. * @param array defines the array of float32 to store
  83840. */
  83841. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83842. /**
  83843. * Set the value of an uniform to an array of float32 (stored as vec2)
  83844. * @param uniform defines the webGL uniform location where to store the value
  83845. * @param array defines the array of float32 to store
  83846. */
  83847. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83848. /**
  83849. * Set the value of an uniform to an array of float32 (stored as vec3)
  83850. * @param uniform defines the webGL uniform location where to store the value
  83851. * @param array defines the array of float32 to store
  83852. */
  83853. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83854. /**
  83855. * Set the value of an uniform to an array of float32 (stored as vec4)
  83856. * @param uniform defines the webGL uniform location where to store the value
  83857. * @param array defines the array of float32 to store
  83858. */
  83859. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83860. /**
  83861. * Set the value of an uniform to an array of number
  83862. * @param uniform defines the webGL uniform location where to store the value
  83863. * @param array defines the array of number to store
  83864. */
  83865. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83866. /**
  83867. * Set the value of an uniform to an array of number (stored as vec2)
  83868. * @param uniform defines the webGL uniform location where to store the value
  83869. * @param array defines the array of number to store
  83870. */
  83871. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83872. /**
  83873. * Set the value of an uniform to an array of number (stored as vec3)
  83874. * @param uniform defines the webGL uniform location where to store the value
  83875. * @param array defines the array of number to store
  83876. */
  83877. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83878. /**
  83879. * Set the value of an uniform to an array of number (stored as vec4)
  83880. * @param uniform defines the webGL uniform location where to store the value
  83881. * @param array defines the array of number to store
  83882. */
  83883. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83884. /**
  83885. * Set the value of an uniform to an array of float32 (stored as matrices)
  83886. * @param uniform defines the webGL uniform location where to store the value
  83887. * @param matrices defines the array of float32 to store
  83888. */
  83889. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83890. /**
  83891. * Set the value of an uniform to a matrix
  83892. * @param uniform defines the webGL uniform location where to store the value
  83893. * @param matrix defines the matrix to store
  83894. */
  83895. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83896. /**
  83897. * Set the value of an uniform to a matrix (3x3)
  83898. * @param uniform defines the webGL uniform location where to store the value
  83899. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83900. */
  83901. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83902. /**
  83903. * Set the value of an uniform to a matrix (2x2)
  83904. * @param uniform defines the webGL uniform location where to store the value
  83905. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83906. */
  83907. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83908. /**
  83909. * Set the value of an uniform to a number (int)
  83910. * @param uniform defines the webGL uniform location where to store the value
  83911. * @param value defines the int number to store
  83912. */
  83913. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83914. /**
  83915. * Set the value of an uniform to a number (float)
  83916. * @param uniform defines the webGL uniform location where to store the value
  83917. * @param value defines the float number to store
  83918. */
  83919. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83920. /**
  83921. * Set the value of an uniform to a vec2
  83922. * @param uniform defines the webGL uniform location where to store the value
  83923. * @param x defines the 1st component of the value
  83924. * @param y defines the 2nd component of the value
  83925. */
  83926. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83927. /**
  83928. * Set the value of an uniform to a vec3
  83929. * @param uniform defines the webGL uniform location where to store the value
  83930. * @param x defines the 1st component of the value
  83931. * @param y defines the 2nd component of the value
  83932. * @param z defines the 3rd component of the value
  83933. */
  83934. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  83935. /**
  83936. * Set the value of an uniform to a boolean
  83937. * @param uniform defines the webGL uniform location where to store the value
  83938. * @param bool defines the boolean to store
  83939. */
  83940. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  83941. /**
  83942. * Set the value of an uniform to a vec4
  83943. * @param uniform defines the webGL uniform location where to store the value
  83944. * @param x defines the 1st component of the value
  83945. * @param y defines the 2nd component of the value
  83946. * @param z defines the 3rd component of the value
  83947. * @param w defines the 4th component of the value
  83948. */
  83949. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  83950. /**
  83951. * Set the value of an uniform to a Color3
  83952. * @param uniform defines the webGL uniform location where to store the value
  83953. * @param color3 defines the color to store
  83954. */
  83955. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  83956. /**
  83957. * Set the value of an uniform to a Color3 and an alpha value
  83958. * @param uniform defines the webGL uniform location where to store the value
  83959. * @param color3 defines the color to store
  83960. * @param alpha defines the alpha component to store
  83961. */
  83962. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  83963. /**
  83964. * Sets a Color4 on a uniform variable
  83965. * @param uniform defines the uniform location
  83966. * @param color4 defines the value to be set
  83967. */
  83968. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  83969. /**
  83970. * Set various states to the webGL context
  83971. * @param culling defines backface culling state
  83972. * @param zOffset defines the value to apply to zOffset (0 by default)
  83973. * @param force defines if states must be applied even if cache is up to date
  83974. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  83975. */
  83976. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  83977. /**
  83978. * Set the z offset to apply to current rendering
  83979. * @param value defines the offset to apply
  83980. */
  83981. setZOffset(value: number): void;
  83982. /**
  83983. * Gets the current value of the zOffset
  83984. * @returns the current zOffset state
  83985. */
  83986. getZOffset(): number;
  83987. /**
  83988. * Enable or disable depth buffering
  83989. * @param enable defines the state to set
  83990. */
  83991. setDepthBuffer(enable: boolean): void;
  83992. /**
  83993. * Gets a boolean indicating if depth writing is enabled
  83994. * @returns the current depth writing state
  83995. */
  83996. getDepthWrite(): boolean;
  83997. /**
  83998. * Enable or disable depth writing
  83999. * @param enable defines the state to set
  84000. */
  84001. setDepthWrite(enable: boolean): void;
  84002. /**
  84003. * Enable or disable color writing
  84004. * @param enable defines the state to set
  84005. */
  84006. setColorWrite(enable: boolean): void;
  84007. /**
  84008. * Gets a boolean indicating if color writing is enabled
  84009. * @returns the current color writing state
  84010. */
  84011. getColorWrite(): boolean;
  84012. /**
  84013. * Sets alpha constants used by some alpha blending modes
  84014. * @param r defines the red component
  84015. * @param g defines the green component
  84016. * @param b defines the blue component
  84017. * @param a defines the alpha component
  84018. */
  84019. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84020. /**
  84021. * Sets the current alpha mode
  84022. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84023. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84025. */
  84026. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84027. /**
  84028. * Gets the current alpha mode
  84029. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84030. * @returns the current alpha mode
  84031. */
  84032. getAlphaMode(): number;
  84033. /**
  84034. * Clears the list of texture accessible through engine.
  84035. * This can help preventing texture load conflict due to name collision.
  84036. */
  84037. clearInternalTexturesCache(): void;
  84038. /**
  84039. * Force the entire cache to be cleared
  84040. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84041. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84042. */
  84043. wipeCaches(bruteForce?: boolean): void;
  84044. /**
  84045. * Set the compressed texture format to use, based on the formats you have, and the formats
  84046. * supported by the hardware / browser.
  84047. *
  84048. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84049. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84050. * to API arguments needed to compressed textures. This puts the burden on the container
  84051. * generator to house the arcane code for determining these for current & future formats.
  84052. *
  84053. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84054. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84055. *
  84056. * Note: The result of this call is not taken into account when a texture is base64.
  84057. *
  84058. * @param formatsAvailable defines the list of those format families you have created
  84059. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84060. *
  84061. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84062. * @returns The extension selected.
  84063. */
  84064. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84065. private _getSamplingParameters;
  84066. private _partialLoadImg;
  84067. private _cascadeLoadImgs;
  84068. /** @hidden */
  84069. _createTexture(): WebGLTexture;
  84070. /**
  84071. * Usually called from Texture.ts.
  84072. * Passed information to create a WebGLTexture
  84073. * @param urlArg defines a value which contains one of the following:
  84074. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84075. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84076. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84078. * @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)
  84079. * @param scene needed for loading to the correct scene
  84080. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84081. * @param onLoad optional callback to be called upon successful completion
  84082. * @param onError optional callback to be called upon failure
  84083. * @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
  84084. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84085. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84086. * @param forcedExtension defines the extension to use to pick the right loader
  84087. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84088. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84089. */
  84090. 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;
  84091. private _rescaleTexture;
  84092. /**
  84093. * Update a raw texture
  84094. * @param texture defines the texture to update
  84095. * @param data defines the data to store in the texture
  84096. * @param format defines the format of the data
  84097. * @param invertY defines if data must be stored with Y axis inverted
  84098. * @param compression defines the compression used (null by default)
  84099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84100. */
  84101. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84102. /**
  84103. * Creates a raw texture
  84104. * @param data defines the data to store in the texture
  84105. * @param width defines the width of the texture
  84106. * @param height defines the height of the texture
  84107. * @param format defines the format of the data
  84108. * @param generateMipMaps defines if the engine should generate the mip levels
  84109. * @param invertY defines if data must be stored with Y axis inverted
  84110. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84111. * @param compression defines the compression used (null by default)
  84112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84113. * @returns the raw texture inside an InternalTexture
  84114. */
  84115. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84116. private _unpackFlipYCached;
  84117. /**
  84118. * In case you are sharing the context with other applications, it might
  84119. * be interested to not cache the unpack flip y state to ensure a consistent
  84120. * value would be set.
  84121. */
  84122. enableUnpackFlipYCached: boolean;
  84123. /** @hidden */
  84124. _unpackFlipY(value: boolean): void;
  84125. /** @hidden */
  84126. _getUnpackAlignement(): number;
  84127. /**
  84128. * Creates a dynamic texture
  84129. * @param width defines the width of the texture
  84130. * @param height defines the height of the texture
  84131. * @param generateMipMaps defines if the engine should generate the mip levels
  84132. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84133. * @returns the dynamic texture inside an InternalTexture
  84134. */
  84135. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84136. /**
  84137. * Update the sampling mode of a given texture
  84138. * @param samplingMode defines the required sampling mode
  84139. * @param texture defines the texture to update
  84140. */
  84141. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84142. /**
  84143. * Update the content of a dynamic texture
  84144. * @param texture defines the texture to update
  84145. * @param canvas defines the canvas containing the source
  84146. * @param invertY defines if data must be stored with Y axis inverted
  84147. * @param premulAlpha defines if alpha is stored as premultiplied
  84148. * @param format defines the format of the data
  84149. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84150. */
  84151. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84152. /**
  84153. * Update a video texture
  84154. * @param texture defines the texture to update
  84155. * @param video defines the video element to use
  84156. * @param invertY defines if data must be stored with Y axis inverted
  84157. */
  84158. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84159. /**
  84160. * Updates a depth texture Comparison Mode and Function.
  84161. * If the comparison Function is equal to 0, the mode will be set to none.
  84162. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84163. * @param texture The texture to set the comparison function for
  84164. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84165. */
  84166. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84167. private _setupDepthStencilTexture;
  84168. /**
  84169. * Creates a depth stencil texture.
  84170. * This is only available in WebGL 2 or with the depth texture extension available.
  84171. * @param size The size of face edge in the texture.
  84172. * @param options The options defining the texture.
  84173. * @returns The texture
  84174. */
  84175. createDepthStencilTexture(size: number | {
  84176. width: number;
  84177. height: number;
  84178. }, options: DepthTextureCreationOptions): InternalTexture;
  84179. /**
  84180. * Creates a depth stencil texture.
  84181. * This is only available in WebGL 2 or with the depth texture extension available.
  84182. * @param size The size of face edge in the texture.
  84183. * @param options The options defining the texture.
  84184. * @returns The texture
  84185. */
  84186. private _createDepthStencilTexture;
  84187. /**
  84188. * Creates a depth stencil cube texture.
  84189. * This is only available in WebGL 2.
  84190. * @param size The size of face edge in the cube texture.
  84191. * @param options The options defining the cube texture.
  84192. * @returns The cube texture
  84193. */
  84194. private _createDepthStencilCubeTexture;
  84195. /**
  84196. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84197. * @param renderTarget The render target to set the frame buffer for
  84198. */
  84199. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84200. /**
  84201. * Creates a new render target texture
  84202. * @param size defines the size of the texture
  84203. * @param options defines the options used to create the texture
  84204. * @returns a new render target texture stored in an InternalTexture
  84205. */
  84206. createRenderTargetTexture(size: number | {
  84207. width: number;
  84208. height: number;
  84209. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84210. /**
  84211. * Create a multi render target texture
  84212. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84213. * @param size defines the size of the texture
  84214. * @param options defines the creation options
  84215. * @returns the cube texture as an InternalTexture
  84216. */
  84217. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84218. private _setupFramebufferDepthAttachments;
  84219. /**
  84220. * Updates the sample count of a render target texture
  84221. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84222. * @param texture defines the texture to update
  84223. * @param samples defines the sample count to set
  84224. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84225. */
  84226. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84227. /**
  84228. * Update the sample count for a given multiple render target texture
  84229. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84230. * @param textures defines the textures to update
  84231. * @param samples defines the sample count to set
  84232. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84233. */
  84234. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84235. /** @hidden */
  84236. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84237. /** @hidden */
  84238. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84239. /** @hidden */
  84240. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84241. /** @hidden */
  84242. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84243. /**
  84244. * Creates a new render target cube texture
  84245. * @param size defines the size of the texture
  84246. * @param options defines the options used to create the texture
  84247. * @returns a new render target cube texture stored in an InternalTexture
  84248. */
  84249. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84250. /**
  84251. * Creates a cube texture
  84252. * @param rootUrl defines the url where the files to load is located
  84253. * @param scene defines the current scene
  84254. * @param files defines the list of files to load (1 per face)
  84255. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84256. * @param onLoad defines an optional callback raised when the texture is loaded
  84257. * @param onError defines an optional callback raised if there is an issue to load the texture
  84258. * @param format defines the format of the data
  84259. * @param forcedExtension defines the extension to use to pick the right loader
  84260. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84261. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84262. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84263. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84264. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84265. * @returns the cube texture as an InternalTexture
  84266. */
  84267. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  84268. /**
  84269. * @hidden
  84270. */
  84271. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84272. /**
  84273. * Update a raw cube texture
  84274. * @param texture defines the texture to udpdate
  84275. * @param data defines the data to store
  84276. * @param format defines the data format
  84277. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84278. * @param invertY defines if data must be stored with Y axis inverted
  84279. * @param compression defines the compression used (null by default)
  84280. * @param level defines which level of the texture to update
  84281. */
  84282. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84283. /**
  84284. * Creates a new raw cube texture
  84285. * @param data defines the array of data to use to create each face
  84286. * @param size defines the size of the textures
  84287. * @param format defines the format of the data
  84288. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84289. * @param generateMipMaps defines if the engine should generate the mip levels
  84290. * @param invertY defines if data must be stored with Y axis inverted
  84291. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84292. * @param compression defines the compression used (null by default)
  84293. * @returns the cube texture as an InternalTexture
  84294. */
  84295. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84296. /**
  84297. * Creates a new raw cube texture from a specified url
  84298. * @param url defines the url where the data is located
  84299. * @param scene defines the current scene
  84300. * @param size defines the size of the textures
  84301. * @param format defines the format of the data
  84302. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84303. * @param noMipmap defines if the engine should avoid generating the mip levels
  84304. * @param callback defines a callback used to extract texture data from loaded data
  84305. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84306. * @param onLoad defines a callback called when texture is loaded
  84307. * @param onError defines a callback called if there is an error
  84308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84309. * @param invertY defines if data must be stored with Y axis inverted
  84310. * @returns the cube texture as an InternalTexture
  84311. */
  84312. 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;
  84313. /**
  84314. * Update a raw 3D texture
  84315. * @param texture defines the texture to update
  84316. * @param data defines the data to store
  84317. * @param format defines the data format
  84318. * @param invertY defines if data must be stored with Y axis inverted
  84319. * @param compression defines the used compression (can be null)
  84320. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84321. */
  84322. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84323. /**
  84324. * Creates a new raw 3D texture
  84325. * @param data defines the data used to create the texture
  84326. * @param width defines the width of the texture
  84327. * @param height defines the height of the texture
  84328. * @param depth defines the depth of the texture
  84329. * @param format defines the format of the texture
  84330. * @param generateMipMaps defines if the engine must generate mip levels
  84331. * @param invertY defines if data must be stored with Y axis inverted
  84332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84333. * @param compression defines the compressed used (can be null)
  84334. * @param textureType defines the compressed used (can be null)
  84335. * @returns a new raw 3D texture (stored in an InternalTexture)
  84336. */
  84337. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84338. private _prepareWebGLTextureContinuation;
  84339. private _prepareWebGLTexture;
  84340. private _convertRGBtoRGBATextureData;
  84341. /** @hidden */
  84342. _releaseFramebufferObjects(texture: InternalTexture): void;
  84343. /** @hidden */
  84344. _releaseTexture(texture: InternalTexture): void;
  84345. private setProgram;
  84346. private _boundUniforms;
  84347. /**
  84348. * Binds an effect to the webGL context
  84349. * @param effect defines the effect to bind
  84350. */
  84351. bindSamplers(effect: Effect): void;
  84352. private _moveBoundTextureOnTop;
  84353. private _getCorrectTextureChannel;
  84354. private _linkTrackers;
  84355. private _removeDesignatedSlot;
  84356. private _activateCurrentTexture;
  84357. /** @hidden */
  84358. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84359. /** @hidden */
  84360. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84361. /**
  84362. * Sets a texture to the webGL context from a postprocess
  84363. * @param channel defines the channel to use
  84364. * @param postProcess defines the source postprocess
  84365. */
  84366. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84367. /**
  84368. * Binds the output of the passed in post process to the texture channel specified
  84369. * @param channel The channel the texture should be bound to
  84370. * @param postProcess The post process which's output should be bound
  84371. */
  84372. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84373. /**
  84374. * Unbind all textures from the webGL context
  84375. */
  84376. unbindAllTextures(): void;
  84377. /**
  84378. * Sets a texture to the according uniform.
  84379. * @param channel The texture channel
  84380. * @param uniform The uniform to set
  84381. * @param texture The texture to apply
  84382. */
  84383. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84384. /**
  84385. * Sets a depth stencil texture from a render target to the according uniform.
  84386. * @param channel The texture channel
  84387. * @param uniform The uniform to set
  84388. * @param texture The render target texture containing the depth stencil texture to apply
  84389. */
  84390. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84391. private _bindSamplerUniformToChannel;
  84392. private _getTextureWrapMode;
  84393. private _setTexture;
  84394. /**
  84395. * Sets an array of texture to the webGL context
  84396. * @param channel defines the channel where the texture array must be set
  84397. * @param uniform defines the associated uniform location
  84398. * @param textures defines the array of textures to bind
  84399. */
  84400. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84401. /** @hidden */
  84402. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84403. private _setTextureParameterFloat;
  84404. private _setTextureParameterInteger;
  84405. /**
  84406. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84407. * @param x defines the x coordinate of the rectangle where pixels must be read
  84408. * @param y defines the y coordinate of the rectangle where pixels must be read
  84409. * @param width defines the width of the rectangle where pixels must be read
  84410. * @param height defines the height of the rectangle where pixels must be read
  84411. * @returns a Uint8Array containing RGBA colors
  84412. */
  84413. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84414. /**
  84415. * Add an externaly attached data from its key.
  84416. * This method call will fail and return false, if such key already exists.
  84417. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84418. * @param key the unique key that identifies the data
  84419. * @param data the data object to associate to the key for this Engine instance
  84420. * @return true if no such key were already present and the data was added successfully, false otherwise
  84421. */
  84422. addExternalData<T>(key: string, data: T): boolean;
  84423. /**
  84424. * Get an externaly attached data from its key
  84425. * @param key the unique key that identifies the data
  84426. * @return the associated data, if present (can be null), or undefined if not present
  84427. */
  84428. getExternalData<T>(key: string): T;
  84429. /**
  84430. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84431. * @param key the unique key that identifies the data
  84432. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84433. * @return the associated data, can be null if the factory returned null.
  84434. */
  84435. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84436. /**
  84437. * Remove an externaly attached data from the Engine instance
  84438. * @param key the unique key that identifies the data
  84439. * @return true if the data was successfully removed, false if it doesn't exist
  84440. */
  84441. removeExternalData(key: string): boolean;
  84442. /**
  84443. * Unbind all vertex attributes from the webGL context
  84444. */
  84445. unbindAllAttributes(): void;
  84446. /**
  84447. * 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
  84448. */
  84449. releaseEffects(): void;
  84450. /**
  84451. * Dispose and release all associated resources
  84452. */
  84453. dispose(): void;
  84454. /**
  84455. * Display the loading screen
  84456. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84457. */
  84458. displayLoadingUI(): void;
  84459. /**
  84460. * Hide the loading screen
  84461. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84462. */
  84463. hideLoadingUI(): void;
  84464. /**
  84465. * Gets the current loading screen object
  84466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84467. */
  84468. /**
  84469. * Sets the current loading screen object
  84470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84471. */
  84472. loadingScreen: ILoadingScreen;
  84473. /**
  84474. * Sets the current loading screen text
  84475. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84476. */
  84477. loadingUIText: string;
  84478. /**
  84479. * Sets the current loading screen background color
  84480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84481. */
  84482. loadingUIBackgroundColor: string;
  84483. /**
  84484. * Attach a new callback raised when context lost event is fired
  84485. * @param callback defines the callback to call
  84486. */
  84487. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84488. /**
  84489. * Attach a new callback raised when context restored event is fired
  84490. * @param callback defines the callback to call
  84491. */
  84492. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84493. /**
  84494. * Gets the source code of the vertex shader associated with a specific webGL program
  84495. * @param program defines the program to use
  84496. * @returns a string containing the source code of the vertex shader associated with the program
  84497. */
  84498. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84499. /**
  84500. * Gets the source code of the fragment shader associated with a specific webGL program
  84501. * @param program defines the program to use
  84502. * @returns a string containing the source code of the fragment shader associated with the program
  84503. */
  84504. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84505. /**
  84506. * Get the current error code of the webGL context
  84507. * @returns the error code
  84508. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84509. */
  84510. getError(): number;
  84511. /**
  84512. * Gets the current framerate
  84513. * @returns a number representing the framerate
  84514. */
  84515. getFps(): number;
  84516. /**
  84517. * Gets the time spent between current and previous frame
  84518. * @returns a number representing the delta time in ms
  84519. */
  84520. getDeltaTime(): number;
  84521. private _measureFps;
  84522. /** @hidden */
  84523. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84524. private _canRenderToFloatFramebuffer;
  84525. private _canRenderToHalfFloatFramebuffer;
  84526. private _canRenderToFramebuffer;
  84527. /** @hidden */
  84528. _getWebGLTextureType(type: number): number;
  84529. private _getInternalFormat;
  84530. /** @hidden */
  84531. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84532. /** @hidden */
  84533. _getRGBAMultiSampleBufferFormat(type: number): number;
  84534. /** @hidden */
  84535. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  84536. /** @hidden */
  84537. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84538. private _partialLoadFile;
  84539. private _cascadeLoadFiles;
  84540. /**
  84541. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84542. * @returns true if the engine can be created
  84543. * @ignorenaming
  84544. */
  84545. static isSupported(): boolean;
  84546. }
  84547. }
  84548. declare module BABYLON {
  84549. /**
  84550. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84551. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84552. */
  84553. export class EffectFallbacks {
  84554. private _defines;
  84555. private _currentRank;
  84556. private _maxRank;
  84557. private _mesh;
  84558. /**
  84559. * Removes the fallback from the bound mesh.
  84560. */
  84561. unBindMesh(): void;
  84562. /**
  84563. * Adds a fallback on the specified property.
  84564. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84565. * @param define The name of the define in the shader
  84566. */
  84567. addFallback(rank: number, define: string): void;
  84568. /**
  84569. * Sets the mesh to use CPU skinning when needing to fallback.
  84570. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84571. * @param mesh The mesh to use the fallbacks.
  84572. */
  84573. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84574. /**
  84575. * Checks to see if more fallbacks are still availible.
  84576. */
  84577. readonly isMoreFallbacks: boolean;
  84578. /**
  84579. * Removes the defines that shoould be removed when falling back.
  84580. * @param currentDefines defines the current define statements for the shader.
  84581. * @param effect defines the current effect we try to compile
  84582. * @returns The resulting defines with defines of the current rank removed.
  84583. */
  84584. reduce(currentDefines: string, effect: Effect): string;
  84585. }
  84586. /**
  84587. * Options to be used when creating an effect.
  84588. */
  84589. export class EffectCreationOptions {
  84590. /**
  84591. * Atrributes that will be used in the shader.
  84592. */
  84593. attributes: string[];
  84594. /**
  84595. * Uniform varible names that will be set in the shader.
  84596. */
  84597. uniformsNames: string[];
  84598. /**
  84599. * Uniform buffer varible names that will be set in the shader.
  84600. */
  84601. uniformBuffersNames: string[];
  84602. /**
  84603. * Sampler texture variable names that will be set in the shader.
  84604. */
  84605. samplers: string[];
  84606. /**
  84607. * Define statements that will be set in the shader.
  84608. */
  84609. defines: any;
  84610. /**
  84611. * Possible fallbacks for this effect to improve performance when needed.
  84612. */
  84613. fallbacks: Nullable<EffectFallbacks>;
  84614. /**
  84615. * Callback that will be called when the shader is compiled.
  84616. */
  84617. onCompiled: Nullable<(effect: Effect) => void>;
  84618. /**
  84619. * Callback that will be called if an error occurs during shader compilation.
  84620. */
  84621. onError: Nullable<(effect: Effect, errors: string) => void>;
  84622. /**
  84623. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84624. */
  84625. indexParameters: any;
  84626. /**
  84627. * Max number of lights that can be used in the shader.
  84628. */
  84629. maxSimultaneousLights: number;
  84630. /**
  84631. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84632. */
  84633. transformFeedbackVaryings: Nullable<string[]>;
  84634. }
  84635. /**
  84636. * Effect containing vertex and fragment shader that can be executed on an object.
  84637. */
  84638. export class Effect {
  84639. /**
  84640. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84641. */
  84642. static ShadersRepository: string;
  84643. /**
  84644. * Name of the effect.
  84645. */
  84646. name: any;
  84647. /**
  84648. * String container all the define statements that should be set on the shader.
  84649. */
  84650. defines: string;
  84651. /**
  84652. * Callback that will be called when the shader is compiled.
  84653. */
  84654. onCompiled: Nullable<(effect: Effect) => void>;
  84655. /**
  84656. * Callback that will be called if an error occurs during shader compilation.
  84657. */
  84658. onError: Nullable<(effect: Effect, errors: string) => void>;
  84659. /**
  84660. * Callback that will be called when effect is bound.
  84661. */
  84662. onBind: Nullable<(effect: Effect) => void>;
  84663. /**
  84664. * Unique ID of the effect.
  84665. */
  84666. uniqueId: number;
  84667. /**
  84668. * Observable that will be called when the shader is compiled.
  84669. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84670. */
  84671. onCompileObservable: Observable<Effect>;
  84672. /**
  84673. * Observable that will be called if an error occurs during shader compilation.
  84674. */
  84675. onErrorObservable: Observable<Effect>;
  84676. /** @hidden */
  84677. _onBindObservable: Nullable<Observable<Effect>>;
  84678. /**
  84679. * Observable that will be called when effect is bound.
  84680. */
  84681. readonly onBindObservable: Observable<Effect>;
  84682. /** @hidden */
  84683. _bonesComputationForcedToCPU: boolean;
  84684. private static _uniqueIdSeed;
  84685. private _engine;
  84686. private _uniformBuffersNames;
  84687. private _uniformsNames;
  84688. private _samplers;
  84689. private _isReady;
  84690. private _compilationError;
  84691. private _attributesNames;
  84692. private _attributes;
  84693. private _uniforms;
  84694. /**
  84695. * Key for the effect.
  84696. * @hidden
  84697. */
  84698. _key: string;
  84699. private _indexParameters;
  84700. private _fallbacks;
  84701. private _vertexSourceCode;
  84702. private _fragmentSourceCode;
  84703. private _vertexSourceCodeOverride;
  84704. private _fragmentSourceCodeOverride;
  84705. private _transformFeedbackVaryings;
  84706. /**
  84707. * Compiled shader to webGL program.
  84708. * @hidden
  84709. */
  84710. _program: WebGLProgram;
  84711. private _valueCache;
  84712. private static _baseCache;
  84713. /**
  84714. * Instantiates an effect.
  84715. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84716. * @param baseName Name of the effect.
  84717. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84718. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84719. * @param samplers List of sampler variables that will be passed to the shader.
  84720. * @param engine Engine to be used to render the effect
  84721. * @param defines Define statements to be added to the shader.
  84722. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84723. * @param onCompiled Callback that will be called when the shader is compiled.
  84724. * @param onError Callback that will be called if an error occurs during shader compilation.
  84725. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84726. */
  84727. 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);
  84728. /**
  84729. * Unique key for this effect
  84730. */
  84731. readonly key: string;
  84732. /**
  84733. * If the effect has been compiled and prepared.
  84734. * @returns if the effect is compiled and prepared.
  84735. */
  84736. isReady(): boolean;
  84737. /**
  84738. * The engine the effect was initialized with.
  84739. * @returns the engine.
  84740. */
  84741. getEngine(): Engine;
  84742. /**
  84743. * The compiled webGL program for the effect
  84744. * @returns the webGL program.
  84745. */
  84746. getProgram(): WebGLProgram;
  84747. /**
  84748. * The set of names of attribute variables for the shader.
  84749. * @returns An array of attribute names.
  84750. */
  84751. getAttributesNames(): string[];
  84752. /**
  84753. * Returns the attribute at the given index.
  84754. * @param index The index of the attribute.
  84755. * @returns The location of the attribute.
  84756. */
  84757. getAttributeLocation(index: number): number;
  84758. /**
  84759. * Returns the attribute based on the name of the variable.
  84760. * @param name of the attribute to look up.
  84761. * @returns the attribute location.
  84762. */
  84763. getAttributeLocationByName(name: string): number;
  84764. /**
  84765. * The number of attributes.
  84766. * @returns the numnber of attributes.
  84767. */
  84768. getAttributesCount(): number;
  84769. /**
  84770. * Gets the index of a uniform variable.
  84771. * @param uniformName of the uniform to look up.
  84772. * @returns the index.
  84773. */
  84774. getUniformIndex(uniformName: string): number;
  84775. /**
  84776. * Returns the attribute based on the name of the variable.
  84777. * @param uniformName of the uniform to look up.
  84778. * @returns the location of the uniform.
  84779. */
  84780. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84781. /**
  84782. * Returns an array of sampler variable names
  84783. * @returns The array of sampler variable neames.
  84784. */
  84785. getSamplers(): string[];
  84786. /**
  84787. * The error from the last compilation.
  84788. * @returns the error string.
  84789. */
  84790. getCompilationError(): string;
  84791. /**
  84792. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84793. * @param func The callback to be used.
  84794. */
  84795. executeWhenCompiled(func: (effect: Effect) => void): void;
  84796. private _checkIsReady;
  84797. /** @hidden */
  84798. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84799. /** @hidden */
  84800. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84801. /** @hidden */
  84802. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84803. private _processShaderConversion;
  84804. private _processIncludes;
  84805. private _processPrecision;
  84806. /**
  84807. * Recompiles the webGL program
  84808. * @param vertexSourceCode The source code for the vertex shader.
  84809. * @param fragmentSourceCode The source code for the fragment shader.
  84810. * @param onCompiled Callback called when completed.
  84811. * @param onError Callback called on error.
  84812. * @hidden
  84813. */
  84814. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84815. /**
  84816. * Gets the uniform locations of the the specified variable names
  84817. * @param names THe names of the variables to lookup.
  84818. * @returns Array of locations in the same order as variable names.
  84819. */
  84820. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84821. /**
  84822. * Prepares the effect
  84823. * @hidden
  84824. */
  84825. _prepareEffect(): void;
  84826. /**
  84827. * Checks if the effect is supported. (Must be called after compilation)
  84828. */
  84829. readonly isSupported: boolean;
  84830. /**
  84831. * Binds a texture to the engine to be used as output of the shader.
  84832. * @param channel Name of the output variable.
  84833. * @param texture Texture to bind.
  84834. * @hidden
  84835. */
  84836. _bindTexture(channel: string, texture: InternalTexture): void;
  84837. /**
  84838. * Sets a texture on the engine to be used in the shader.
  84839. * @param channel Name of the sampler variable.
  84840. * @param texture Texture to set.
  84841. */
  84842. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84843. /**
  84844. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84845. * @param channel Name of the sampler variable.
  84846. * @param texture Texture to set.
  84847. */
  84848. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84849. /**
  84850. * Sets an array of textures on the engine to be used in the shader.
  84851. * @param channel Name of the variable.
  84852. * @param textures Textures to set.
  84853. */
  84854. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84855. /**
  84856. * 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)
  84857. * @param channel Name of the sampler variable.
  84858. * @param postProcess Post process to get the input texture from.
  84859. */
  84860. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84861. /**
  84862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84863. * 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)
  84864. * @param channel Name of the sampler variable.
  84865. * @param postProcess Post process to get the output texture from.
  84866. */
  84867. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84868. /** @hidden */
  84869. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84870. /** @hidden */
  84871. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84872. /** @hidden */
  84873. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84874. /** @hidden */
  84875. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84876. /**
  84877. * Binds a buffer to a uniform.
  84878. * @param buffer Buffer to bind.
  84879. * @param name Name of the uniform variable to bind to.
  84880. */
  84881. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84882. /**
  84883. * Binds block to a uniform.
  84884. * @param blockName Name of the block to bind.
  84885. * @param index Index to bind.
  84886. */
  84887. bindUniformBlock(blockName: string, index: number): void;
  84888. /**
  84889. * Sets an interger value on a uniform variable.
  84890. * @param uniformName Name of the variable.
  84891. * @param value Value to be set.
  84892. * @returns this effect.
  84893. */
  84894. setInt(uniformName: string, value: number): Effect;
  84895. /**
  84896. * Sets an int array on a uniform variable.
  84897. * @param uniformName Name of the variable.
  84898. * @param array array to be set.
  84899. * @returns this effect.
  84900. */
  84901. setIntArray(uniformName: string, array: Int32Array): Effect;
  84902. /**
  84903. * 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)
  84904. * @param uniformName Name of the variable.
  84905. * @param array array to be set.
  84906. * @returns this effect.
  84907. */
  84908. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84909. /**
  84910. * 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)
  84911. * @param uniformName Name of the variable.
  84912. * @param array array to be set.
  84913. * @returns this effect.
  84914. */
  84915. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84916. /**
  84917. * 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)
  84918. * @param uniformName Name of the variable.
  84919. * @param array array to be set.
  84920. * @returns this effect.
  84921. */
  84922. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84923. /**
  84924. * Sets an float array on a uniform variable.
  84925. * @param uniformName Name of the variable.
  84926. * @param array array to be set.
  84927. * @returns this effect.
  84928. */
  84929. setFloatArray(uniformName: string, array: Float32Array): Effect;
  84930. /**
  84931. * 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)
  84932. * @param uniformName Name of the variable.
  84933. * @param array array to be set.
  84934. * @returns this effect.
  84935. */
  84936. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  84937. /**
  84938. * 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)
  84939. * @param uniformName Name of the variable.
  84940. * @param array array to be set.
  84941. * @returns this effect.
  84942. */
  84943. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  84944. /**
  84945. * 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)
  84946. * @param uniformName Name of the variable.
  84947. * @param array array to be set.
  84948. * @returns this effect.
  84949. */
  84950. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  84951. /**
  84952. * Sets an array on a uniform variable.
  84953. * @param uniformName Name of the variable.
  84954. * @param array array to be set.
  84955. * @returns this effect.
  84956. */
  84957. setArray(uniformName: string, array: number[]): Effect;
  84958. /**
  84959. * 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)
  84960. * @param uniformName Name of the variable.
  84961. * @param array array to be set.
  84962. * @returns this effect.
  84963. */
  84964. setArray2(uniformName: string, array: number[]): Effect;
  84965. /**
  84966. * 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)
  84967. * @param uniformName Name of the variable.
  84968. * @param array array to be set.
  84969. * @returns this effect.
  84970. */
  84971. setArray3(uniformName: string, array: number[]): Effect;
  84972. /**
  84973. * 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)
  84974. * @param uniformName Name of the variable.
  84975. * @param array array to be set.
  84976. * @returns this effect.
  84977. */
  84978. setArray4(uniformName: string, array: number[]): Effect;
  84979. /**
  84980. * Sets matrices on a uniform variable.
  84981. * @param uniformName Name of the variable.
  84982. * @param matrices matrices to be set.
  84983. * @returns this effect.
  84984. */
  84985. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  84986. /**
  84987. * Sets matrix on a uniform variable.
  84988. * @param uniformName Name of the variable.
  84989. * @param matrix matrix to be set.
  84990. * @returns this effect.
  84991. */
  84992. setMatrix(uniformName: string, matrix: Matrix): Effect;
  84993. /**
  84994. * 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)
  84995. * @param uniformName Name of the variable.
  84996. * @param matrix matrix to be set.
  84997. * @returns this effect.
  84998. */
  84999. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85000. /**
  85001. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85002. * @param uniformName Name of the variable.
  85003. * @param matrix matrix to be set.
  85004. * @returns this effect.
  85005. */
  85006. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85007. /**
  85008. * Sets a float on a uniform variable.
  85009. * @param uniformName Name of the variable.
  85010. * @param value value to be set.
  85011. * @returns this effect.
  85012. */
  85013. setFloat(uniformName: string, value: number): Effect;
  85014. /**
  85015. * Sets a boolean on a uniform variable.
  85016. * @param uniformName Name of the variable.
  85017. * @param bool value to be set.
  85018. * @returns this effect.
  85019. */
  85020. setBool(uniformName: string, bool: boolean): Effect;
  85021. /**
  85022. * Sets a Vector2 on a uniform variable.
  85023. * @param uniformName Name of the variable.
  85024. * @param vector2 vector2 to be set.
  85025. * @returns this effect.
  85026. */
  85027. setVector2(uniformName: string, vector2: Vector2): Effect;
  85028. /**
  85029. * Sets a float2 on a uniform variable.
  85030. * @param uniformName Name of the variable.
  85031. * @param x First float in float2.
  85032. * @param y Second float in float2.
  85033. * @returns this effect.
  85034. */
  85035. setFloat2(uniformName: string, x: number, y: number): Effect;
  85036. /**
  85037. * Sets a Vector3 on a uniform variable.
  85038. * @param uniformName Name of the variable.
  85039. * @param vector3 Value to be set.
  85040. * @returns this effect.
  85041. */
  85042. setVector3(uniformName: string, vector3: Vector3): Effect;
  85043. /**
  85044. * Sets a float3 on a uniform variable.
  85045. * @param uniformName Name of the variable.
  85046. * @param x First float in float3.
  85047. * @param y Second float in float3.
  85048. * @param z Third float in float3.
  85049. * @returns this effect.
  85050. */
  85051. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85052. /**
  85053. * Sets a Vector4 on a uniform variable.
  85054. * @param uniformName Name of the variable.
  85055. * @param vector4 Value to be set.
  85056. * @returns this effect.
  85057. */
  85058. setVector4(uniformName: string, vector4: Vector4): Effect;
  85059. /**
  85060. * Sets a float4 on a uniform variable.
  85061. * @param uniformName Name of the variable.
  85062. * @param x First float in float4.
  85063. * @param y Second float in float4.
  85064. * @param z Third float in float4.
  85065. * @param w Fourth float in float4.
  85066. * @returns this effect.
  85067. */
  85068. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85069. /**
  85070. * Sets a Color3 on a uniform variable.
  85071. * @param uniformName Name of the variable.
  85072. * @param color3 Value to be set.
  85073. * @returns this effect.
  85074. */
  85075. setColor3(uniformName: string, color3: Color3): Effect;
  85076. /**
  85077. * Sets a Color4 on a uniform variable.
  85078. * @param uniformName Name of the variable.
  85079. * @param color3 Value to be set.
  85080. * @param alpha Alpha value to be set.
  85081. * @returns this effect.
  85082. */
  85083. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85084. /**
  85085. * Sets a Color4 on a uniform variable
  85086. * @param uniformName defines the name of the variable
  85087. * @param color4 defines the value to be set
  85088. * @returns this effect.
  85089. */
  85090. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85091. /**
  85092. * This function will add a new shader to the shader store
  85093. * @param name the name of the shader
  85094. * @param pixelShader optional pixel shader content
  85095. * @param vertexShader optional vertex shader content
  85096. */
  85097. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85098. /**
  85099. * Store of each shader (The can be looked up using effect.key)
  85100. */
  85101. static ShadersStore: {
  85102. [key: string]: string;
  85103. };
  85104. /**
  85105. * Store of each included file for a shader (The can be looked up using effect.key)
  85106. */
  85107. static IncludesShadersStore: {
  85108. [key: string]: string;
  85109. };
  85110. /**
  85111. * Resets the cache of effects.
  85112. */
  85113. static ResetCache(): void;
  85114. }
  85115. }
  85116. declare module BABYLON {
  85117. /**
  85118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85120. * 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;
  85121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85122. */
  85123. export class ColorCurves {
  85124. private _dirty;
  85125. private _tempColor;
  85126. private _globalCurve;
  85127. private _highlightsCurve;
  85128. private _midtonesCurve;
  85129. private _shadowsCurve;
  85130. private _positiveCurve;
  85131. private _negativeCurve;
  85132. private _globalHue;
  85133. private _globalDensity;
  85134. private _globalSaturation;
  85135. private _globalExposure;
  85136. /**
  85137. * Gets the global Hue value.
  85138. * 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).
  85139. */
  85140. /**
  85141. * Sets the global Hue value.
  85142. * 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).
  85143. */
  85144. globalHue: number;
  85145. /**
  85146. * Gets the global Density value.
  85147. * 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.
  85148. * Values less than zero provide a filter of opposite hue.
  85149. */
  85150. /**
  85151. * Sets the global Density value.
  85152. * 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.
  85153. * Values less than zero provide a filter of opposite hue.
  85154. */
  85155. globalDensity: number;
  85156. /**
  85157. * Gets the global Saturation value.
  85158. * 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.
  85159. */
  85160. /**
  85161. * Sets the global Saturation value.
  85162. * 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.
  85163. */
  85164. globalSaturation: number;
  85165. /**
  85166. * Gets the global Exposure value.
  85167. * 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.
  85168. */
  85169. /**
  85170. * Sets the global Exposure value.
  85171. * 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.
  85172. */
  85173. globalExposure: number;
  85174. private _highlightsHue;
  85175. private _highlightsDensity;
  85176. private _highlightsSaturation;
  85177. private _highlightsExposure;
  85178. /**
  85179. * Gets the highlights Hue value.
  85180. * 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).
  85181. */
  85182. /**
  85183. * Sets the highlights Hue value.
  85184. * 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).
  85185. */
  85186. highlightsHue: number;
  85187. /**
  85188. * Gets the highlights Density value.
  85189. * 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.
  85190. * Values less than zero provide a filter of opposite hue.
  85191. */
  85192. /**
  85193. * Sets the highlights Density value.
  85194. * 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.
  85195. * Values less than zero provide a filter of opposite hue.
  85196. */
  85197. highlightsDensity: number;
  85198. /**
  85199. * Gets the highlights Saturation value.
  85200. * 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.
  85201. */
  85202. /**
  85203. * Sets the highlights Saturation value.
  85204. * 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.
  85205. */
  85206. highlightsSaturation: number;
  85207. /**
  85208. * Gets the highlights Exposure value.
  85209. * 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.
  85210. */
  85211. /**
  85212. * Sets the highlights Exposure value.
  85213. * 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.
  85214. */
  85215. highlightsExposure: number;
  85216. private _midtonesHue;
  85217. private _midtonesDensity;
  85218. private _midtonesSaturation;
  85219. private _midtonesExposure;
  85220. /**
  85221. * Gets the midtones Hue value.
  85222. * 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).
  85223. */
  85224. /**
  85225. * Sets the midtones Hue value.
  85226. * 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).
  85227. */
  85228. midtonesHue: number;
  85229. /**
  85230. * Gets the midtones Density value.
  85231. * 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.
  85232. * Values less than zero provide a filter of opposite hue.
  85233. */
  85234. /**
  85235. * Sets the midtones Density value.
  85236. * 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.
  85237. * Values less than zero provide a filter of opposite hue.
  85238. */
  85239. midtonesDensity: number;
  85240. /**
  85241. * Gets the midtones Saturation value.
  85242. * 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.
  85243. */
  85244. /**
  85245. * Sets the midtones Saturation value.
  85246. * 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.
  85247. */
  85248. midtonesSaturation: number;
  85249. /**
  85250. * Gets the midtones Exposure value.
  85251. * 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.
  85252. */
  85253. /**
  85254. * Sets the midtones Exposure value.
  85255. * 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.
  85256. */
  85257. midtonesExposure: number;
  85258. private _shadowsHue;
  85259. private _shadowsDensity;
  85260. private _shadowsSaturation;
  85261. private _shadowsExposure;
  85262. /**
  85263. * Gets the shadows Hue value.
  85264. * 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).
  85265. */
  85266. /**
  85267. * Sets the shadows Hue value.
  85268. * 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).
  85269. */
  85270. shadowsHue: number;
  85271. /**
  85272. * Gets the shadows Density value.
  85273. * 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.
  85274. * Values less than zero provide a filter of opposite hue.
  85275. */
  85276. /**
  85277. * Sets the shadows Density value.
  85278. * 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.
  85279. * Values less than zero provide a filter of opposite hue.
  85280. */
  85281. shadowsDensity: number;
  85282. /**
  85283. * Gets the shadows Saturation value.
  85284. * 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.
  85285. */
  85286. /**
  85287. * Sets the shadows Saturation value.
  85288. * 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.
  85289. */
  85290. shadowsSaturation: number;
  85291. /**
  85292. * Gets the shadows Exposure value.
  85293. * 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.
  85294. */
  85295. /**
  85296. * Sets the shadows Exposure value.
  85297. * 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.
  85298. */
  85299. shadowsExposure: number;
  85300. /**
  85301. * Returns the class name
  85302. * @returns The class name
  85303. */
  85304. getClassName(): string;
  85305. /**
  85306. * Binds the color curves to the shader.
  85307. * @param colorCurves The color curve to bind
  85308. * @param effect The effect to bind to
  85309. * @param positiveUniform The positive uniform shader parameter
  85310. * @param neutralUniform The neutral uniform shader parameter
  85311. * @param negativeUniform The negative uniform shader parameter
  85312. */
  85313. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85314. /**
  85315. * Prepare the list of uniforms associated with the ColorCurves effects.
  85316. * @param uniformsList The list of uniforms used in the effect
  85317. */
  85318. static PrepareUniforms(uniformsList: string[]): void;
  85319. /**
  85320. * Returns color grading data based on a hue, density, saturation and exposure value.
  85321. * @param filterHue The hue of the color filter.
  85322. * @param filterDensity The density of the color filter.
  85323. * @param saturation The saturation.
  85324. * @param exposure The exposure.
  85325. * @param result The result data container.
  85326. */
  85327. private getColorGradingDataToRef;
  85328. /**
  85329. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85330. * @param value The input slider value in range [-100,100].
  85331. * @returns Adjusted value.
  85332. */
  85333. private static applyColorGradingSliderNonlinear;
  85334. /**
  85335. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85336. * @param hue The hue (H) input.
  85337. * @param saturation The saturation (S) input.
  85338. * @param brightness The brightness (B) input.
  85339. * @result An RGBA color represented as Vector4.
  85340. */
  85341. private static fromHSBToRef;
  85342. /**
  85343. * Returns a value clamped between min and max
  85344. * @param value The value to clamp
  85345. * @param min The minimum of value
  85346. * @param max The maximum of value
  85347. * @returns The clamped value.
  85348. */
  85349. private static clamp;
  85350. /**
  85351. * Clones the current color curve instance.
  85352. * @return The cloned curves
  85353. */
  85354. clone(): ColorCurves;
  85355. /**
  85356. * Serializes the current color curve instance to a json representation.
  85357. * @return a JSON representation
  85358. */
  85359. serialize(): any;
  85360. /**
  85361. * Parses the color curve from a json representation.
  85362. * @param source the JSON source to parse
  85363. * @return The parsed curves
  85364. */
  85365. static Parse(source: any): ColorCurves;
  85366. }
  85367. }
  85368. declare module BABYLON {
  85369. /**
  85370. * Interface to follow in your material defines to integrate easily the
  85371. * Image proccessing functions.
  85372. * @hidden
  85373. */
  85374. export interface IImageProcessingConfigurationDefines {
  85375. IMAGEPROCESSING: boolean;
  85376. VIGNETTE: boolean;
  85377. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85378. VIGNETTEBLENDMODEOPAQUE: boolean;
  85379. TONEMAPPING: boolean;
  85380. TONEMAPPING_ACES: boolean;
  85381. CONTRAST: boolean;
  85382. EXPOSURE: boolean;
  85383. COLORCURVES: boolean;
  85384. COLORGRADING: boolean;
  85385. COLORGRADING3D: boolean;
  85386. SAMPLER3DGREENDEPTH: boolean;
  85387. SAMPLER3DBGRMAP: boolean;
  85388. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85389. }
  85390. /**
  85391. * @hidden
  85392. */
  85393. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85394. IMAGEPROCESSING: boolean;
  85395. VIGNETTE: boolean;
  85396. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85397. VIGNETTEBLENDMODEOPAQUE: boolean;
  85398. TONEMAPPING: boolean;
  85399. TONEMAPPING_ACES: boolean;
  85400. CONTRAST: boolean;
  85401. COLORCURVES: boolean;
  85402. COLORGRADING: boolean;
  85403. COLORGRADING3D: boolean;
  85404. SAMPLER3DGREENDEPTH: boolean;
  85405. SAMPLER3DBGRMAP: boolean;
  85406. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85407. EXPOSURE: boolean;
  85408. constructor();
  85409. }
  85410. /**
  85411. * This groups together the common properties used for image processing either in direct forward pass
  85412. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85413. * or not.
  85414. */
  85415. export class ImageProcessingConfiguration {
  85416. /**
  85417. * Default tone mapping applied in BabylonJS.
  85418. */
  85419. static readonly TONEMAPPING_STANDARD: number;
  85420. /**
  85421. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85422. * to other engines rendering to increase portability.
  85423. */
  85424. static readonly TONEMAPPING_ACES: number;
  85425. /**
  85426. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85427. */
  85428. colorCurves: Nullable<ColorCurves>;
  85429. private _colorCurvesEnabled;
  85430. /**
  85431. * Gets wether the color curves effect is enabled.
  85432. */
  85433. /**
  85434. * Sets wether the color curves effect is enabled.
  85435. */
  85436. colorCurvesEnabled: boolean;
  85437. private _colorGradingTexture;
  85438. /**
  85439. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85440. */
  85441. /**
  85442. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85443. */
  85444. colorGradingTexture: Nullable<BaseTexture>;
  85445. private _colorGradingEnabled;
  85446. /**
  85447. * Gets wether the color grading effect is enabled.
  85448. */
  85449. /**
  85450. * Sets wether the color grading effect is enabled.
  85451. */
  85452. colorGradingEnabled: boolean;
  85453. private _colorGradingWithGreenDepth;
  85454. /**
  85455. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85456. */
  85457. /**
  85458. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85459. */
  85460. colorGradingWithGreenDepth: boolean;
  85461. private _colorGradingBGR;
  85462. /**
  85463. * Gets wether the color grading texture contains BGR values.
  85464. */
  85465. /**
  85466. * Sets wether the color grading texture contains BGR values.
  85467. */
  85468. colorGradingBGR: boolean;
  85469. /** @hidden */
  85470. _exposure: number;
  85471. /**
  85472. * Gets the Exposure used in the effect.
  85473. */
  85474. /**
  85475. * Sets the Exposure used in the effect.
  85476. */
  85477. exposure: number;
  85478. private _toneMappingEnabled;
  85479. /**
  85480. * Gets wether the tone mapping effect is enabled.
  85481. */
  85482. /**
  85483. * Sets wether the tone mapping effect is enabled.
  85484. */
  85485. toneMappingEnabled: boolean;
  85486. private _toneMappingType;
  85487. /**
  85488. * Gets the type of tone mapping effect.
  85489. */
  85490. /**
  85491. * Sets the type of tone mapping effect used in BabylonJS.
  85492. */
  85493. toneMappingType: number;
  85494. protected _contrast: number;
  85495. /**
  85496. * Gets the contrast used in the effect.
  85497. */
  85498. /**
  85499. * Sets the contrast used in the effect.
  85500. */
  85501. contrast: number;
  85502. /**
  85503. * Vignette stretch size.
  85504. */
  85505. vignetteStretch: number;
  85506. /**
  85507. * Vignette centre X Offset.
  85508. */
  85509. vignetteCentreX: number;
  85510. /**
  85511. * Vignette centre Y Offset.
  85512. */
  85513. vignetteCentreY: number;
  85514. /**
  85515. * Vignette weight or intensity of the vignette effect.
  85516. */
  85517. vignetteWeight: number;
  85518. /**
  85519. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85520. * if vignetteEnabled is set to true.
  85521. */
  85522. vignetteColor: Color4;
  85523. /**
  85524. * Camera field of view used by the Vignette effect.
  85525. */
  85526. vignetteCameraFov: number;
  85527. private _vignetteBlendMode;
  85528. /**
  85529. * Gets the vignette blend mode allowing different kind of effect.
  85530. */
  85531. /**
  85532. * Sets the vignette blend mode allowing different kind of effect.
  85533. */
  85534. vignetteBlendMode: number;
  85535. private _vignetteEnabled;
  85536. /**
  85537. * Gets wether the vignette effect is enabled.
  85538. */
  85539. /**
  85540. * Sets wether the vignette effect is enabled.
  85541. */
  85542. vignetteEnabled: boolean;
  85543. private _applyByPostProcess;
  85544. /**
  85545. * Gets wether the image processing is applied through a post process or not.
  85546. */
  85547. /**
  85548. * Sets wether the image processing is applied through a post process or not.
  85549. */
  85550. applyByPostProcess: boolean;
  85551. private _isEnabled;
  85552. /**
  85553. * Gets wether the image processing is enabled or not.
  85554. */
  85555. /**
  85556. * Sets wether the image processing is enabled or not.
  85557. */
  85558. isEnabled: boolean;
  85559. /**
  85560. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85561. */
  85562. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85563. /**
  85564. * Method called each time the image processing information changes requires to recompile the effect.
  85565. */
  85566. protected _updateParameters(): void;
  85567. /**
  85568. * Gets the current class name.
  85569. * @return "ImageProcessingConfiguration"
  85570. */
  85571. getClassName(): string;
  85572. /**
  85573. * Prepare the list of uniforms associated with the Image Processing effects.
  85574. * @param uniforms The list of uniforms used in the effect
  85575. * @param defines the list of defines currently in use
  85576. */
  85577. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85578. /**
  85579. * Prepare the list of samplers associated with the Image Processing effects.
  85580. * @param samplersList The list of uniforms used in the effect
  85581. * @param defines the list of defines currently in use
  85582. */
  85583. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85584. /**
  85585. * Prepare the list of defines associated to the shader.
  85586. * @param defines the list of defines to complete
  85587. * @param forPostProcess Define if we are currently in post process mode or not
  85588. */
  85589. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85590. /**
  85591. * Returns true if all the image processing information are ready.
  85592. * @returns True if ready, otherwise, false
  85593. */
  85594. isReady(): boolean;
  85595. /**
  85596. * Binds the image processing to the shader.
  85597. * @param effect The effect to bind to
  85598. * @param aspectRatio Define the current aspect ratio of the effect
  85599. */
  85600. bind(effect: Effect, aspectRatio?: number): void;
  85601. /**
  85602. * Clones the current image processing instance.
  85603. * @return The cloned image processing
  85604. */
  85605. clone(): ImageProcessingConfiguration;
  85606. /**
  85607. * Serializes the current image processing instance to a json representation.
  85608. * @return a JSON representation
  85609. */
  85610. serialize(): any;
  85611. /**
  85612. * Parses the image processing from a json representation.
  85613. * @param source the JSON source to parse
  85614. * @return The parsed image processing
  85615. */
  85616. static Parse(source: any): ImageProcessingConfiguration;
  85617. private static _VIGNETTEMODE_MULTIPLY;
  85618. private static _VIGNETTEMODE_OPAQUE;
  85619. /**
  85620. * Used to apply the vignette as a mix with the pixel color.
  85621. */
  85622. static readonly VIGNETTEMODE_MULTIPLY: number;
  85623. /**
  85624. * Used to apply the vignette as a replacement of the pixel color.
  85625. */
  85626. static readonly VIGNETTEMODE_OPAQUE: number;
  85627. }
  85628. }
  85629. declare module BABYLON {
  85630. /**
  85631. * This represents all the required information to add a fresnel effect on a material:
  85632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85633. */
  85634. export class FresnelParameters {
  85635. private _isEnabled;
  85636. /**
  85637. * Define if the fresnel effect is enable or not.
  85638. */
  85639. isEnabled: boolean;
  85640. /**
  85641. * Define the color used on edges (grazing angle)
  85642. */
  85643. leftColor: Color3;
  85644. /**
  85645. * Define the color used on center
  85646. */
  85647. rightColor: Color3;
  85648. /**
  85649. * Define bias applied to computed fresnel term
  85650. */
  85651. bias: number;
  85652. /**
  85653. * Defined the power exponent applied to fresnel term
  85654. */
  85655. power: number;
  85656. /**
  85657. * Clones the current fresnel and its valuues
  85658. * @returns a clone fresnel configuration
  85659. */
  85660. clone(): FresnelParameters;
  85661. /**
  85662. * Serializes the current fresnel parameters to a JSON representation.
  85663. * @return the JSON serialization
  85664. */
  85665. serialize(): any;
  85666. /**
  85667. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85668. * @param parsedFresnelParameters Define the JSON representation
  85669. * @returns the parsed parameters
  85670. */
  85671. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85672. }
  85673. }
  85674. declare module BABYLON {
  85675. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85676. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85677. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85678. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85679. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85680. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85681. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85682. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85683. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85684. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85685. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85686. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85687. /**
  85688. * Decorator used to define property that can be serialized as reference to a camera
  85689. * @param sourceName defines the name of the property to decorate
  85690. */
  85691. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85692. /**
  85693. * Class used to help serialization objects
  85694. */
  85695. export class SerializationHelper {
  85696. /** hidden */
  85697. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85698. /** hidden */
  85699. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85700. /** hidden */
  85701. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85702. /** hidden */
  85703. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85704. /**
  85705. * Appends the serialized animations from the source animations
  85706. * @param source Source containing the animations
  85707. * @param destination Target to store the animations
  85708. */
  85709. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85710. /**
  85711. * Static function used to serialized a specific entity
  85712. * @param entity defines the entity to serialize
  85713. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85714. * @returns a JSON compatible object representing the serialization of the entity
  85715. */
  85716. static Serialize<T>(entity: T, serializationObject?: any): any;
  85717. /**
  85718. * Creates a new entity from a serialization data object
  85719. * @param creationFunction defines a function used to instanciated the new entity
  85720. * @param source defines the source serialization data
  85721. * @param scene defines the hosting scene
  85722. * @param rootUrl defines the root url for resources
  85723. * @returns a new entity
  85724. */
  85725. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85726. /**
  85727. * Clones an object
  85728. * @param creationFunction defines the function used to instanciate the new object
  85729. * @param source defines the source object
  85730. * @returns the cloned object
  85731. */
  85732. static Clone<T>(creationFunction: () => T, source: T): T;
  85733. /**
  85734. * Instanciates a new object based on a source one (some data will be shared between both object)
  85735. * @param creationFunction defines the function used to instanciate the new object
  85736. * @param source defines the source object
  85737. * @returns the new object
  85738. */
  85739. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85740. }
  85741. }
  85742. declare module BABYLON {
  85743. /**
  85744. * This is the base class of all the camera used in the application.
  85745. * @see http://doc.babylonjs.com/features/cameras
  85746. */
  85747. export class Camera extends Node {
  85748. /** @hidden */
  85749. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85750. /**
  85751. * This is the default projection mode used by the cameras.
  85752. * It helps recreating a feeling of perspective and better appreciate depth.
  85753. * This is the best way to simulate real life cameras.
  85754. */
  85755. static readonly PERSPECTIVE_CAMERA: number;
  85756. /**
  85757. * This helps creating camera with an orthographic mode.
  85758. * 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.
  85759. */
  85760. static readonly ORTHOGRAPHIC_CAMERA: number;
  85761. /**
  85762. * This is the default FOV mode for perspective cameras.
  85763. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85764. */
  85765. static readonly FOVMODE_VERTICAL_FIXED: number;
  85766. /**
  85767. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85768. */
  85769. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85770. /**
  85771. * This specifies ther is no need for a camera rig.
  85772. * Basically only one eye is rendered corresponding to the camera.
  85773. */
  85774. static readonly RIG_MODE_NONE: number;
  85775. /**
  85776. * Simulates a camera Rig with one blue eye and one red eye.
  85777. * This can be use with 3d blue and red glasses.
  85778. */
  85779. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85780. /**
  85781. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85782. */
  85783. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85784. /**
  85785. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85786. */
  85787. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85788. /**
  85789. * Defines that both eyes of the camera will be rendered over under each other.
  85790. */
  85791. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85792. /**
  85793. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85794. */
  85795. static readonly RIG_MODE_VR: number;
  85796. /**
  85797. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85798. */
  85799. static readonly RIG_MODE_WEBVR: number;
  85800. /**
  85801. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85802. */
  85803. static readonly RIG_MODE_CUSTOM: number;
  85804. /**
  85805. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85806. */
  85807. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85808. /**
  85809. * @hidden
  85810. * Might be removed once multiview will be a thing
  85811. */
  85812. static UseAlternateWebVRRendering: boolean;
  85813. /**
  85814. * Define the input manager associated with the camera.
  85815. */
  85816. inputs: CameraInputsManager<Camera>;
  85817. /**
  85818. * Define the current local position of the camera in the scene
  85819. */
  85820. position: Vector3;
  85821. /**
  85822. * The vector the camera should consider as up.
  85823. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85824. */
  85825. upVector: Vector3;
  85826. /**
  85827. * Define the current limit on the left side for an orthographic camera
  85828. * In scene unit
  85829. */
  85830. orthoLeft: Nullable<number>;
  85831. /**
  85832. * Define the current limit on the right side for an orthographic camera
  85833. * In scene unit
  85834. */
  85835. orthoRight: Nullable<number>;
  85836. /**
  85837. * Define the current limit on the bottom side for an orthographic camera
  85838. * In scene unit
  85839. */
  85840. orthoBottom: Nullable<number>;
  85841. /**
  85842. * Define the current limit on the top side for an orthographic camera
  85843. * In scene unit
  85844. */
  85845. orthoTop: Nullable<number>;
  85846. /**
  85847. * Field Of View is set in Radians. (default is 0.8)
  85848. */
  85849. fov: number;
  85850. /**
  85851. * Define the minimum distance the camera can see from.
  85852. * This is important to note that the depth buffer are not infinite and the closer it starts
  85853. * the more your scene might encounter depth fighting issue.
  85854. */
  85855. minZ: number;
  85856. /**
  85857. * Define the maximum distance the camera can see to.
  85858. * This is important to note that the depth buffer are not infinite and the further it end
  85859. * the more your scene might encounter depth fighting issue.
  85860. */
  85861. maxZ: number;
  85862. /**
  85863. * Define the default inertia of the camera.
  85864. * This helps giving a smooth feeling to the camera movement.
  85865. */
  85866. inertia: number;
  85867. /**
  85868. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85869. */
  85870. mode: number;
  85871. /**
  85872. * Define wether the camera is intermediate.
  85873. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85874. */
  85875. isIntermediate: boolean;
  85876. /**
  85877. * Define the viewport of the camera.
  85878. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85879. */
  85880. viewport: Viewport;
  85881. /**
  85882. * Restricts the camera to viewing objects with the same layerMask.
  85883. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85884. */
  85885. layerMask: number;
  85886. /**
  85887. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85888. */
  85889. fovMode: number;
  85890. /**
  85891. * Rig mode of the camera.
  85892. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85893. * This is normally controlled byt the camera themselves as internal use.
  85894. */
  85895. cameraRigMode: number;
  85896. /**
  85897. * Defines the distance between both "eyes" in case of a RIG
  85898. */
  85899. interaxialDistance: number;
  85900. /**
  85901. * Defines if stereoscopic rendering is done side by side or over under.
  85902. */
  85903. isStereoscopicSideBySide: boolean;
  85904. /**
  85905. * 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
  85906. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85907. * else in the scene.
  85908. */
  85909. customRenderTargets: RenderTargetTexture[];
  85910. /**
  85911. * When set, the camera will render to this render target instead of the default canvas
  85912. */
  85913. outputRenderTarget: Nullable<RenderTargetTexture>;
  85914. /**
  85915. * Observable triggered when the camera view matrix has changed.
  85916. */
  85917. onViewMatrixChangedObservable: Observable<Camera>;
  85918. /**
  85919. * Observable triggered when the camera Projection matrix has changed.
  85920. */
  85921. onProjectionMatrixChangedObservable: Observable<Camera>;
  85922. /**
  85923. * Observable triggered when the inputs have been processed.
  85924. */
  85925. onAfterCheckInputsObservable: Observable<Camera>;
  85926. /**
  85927. * Observable triggered when reset has been called and applied to the camera.
  85928. */
  85929. onRestoreStateObservable: Observable<Camera>;
  85930. /** @hidden */
  85931. _cameraRigParams: any;
  85932. /** @hidden */
  85933. _rigCameras: Camera[];
  85934. /** @hidden */
  85935. _rigPostProcess: Nullable<PostProcess>;
  85936. protected _webvrViewMatrix: Matrix;
  85937. /** @hidden */
  85938. _skipRendering: boolean;
  85939. /** @hidden */
  85940. _alternateCamera: Camera;
  85941. /** @hidden */
  85942. _projectionMatrix: Matrix;
  85943. /** @hidden */
  85944. _postProcesses: Nullable<PostProcess>[];
  85945. /** @hidden */
  85946. _activeMeshes: SmartArray<AbstractMesh>;
  85947. protected _globalPosition: Vector3;
  85948. /** hidden */
  85949. _computedViewMatrix: Matrix;
  85950. private _doNotComputeProjectionMatrix;
  85951. private _transformMatrix;
  85952. private _frustumPlanes;
  85953. private _refreshFrustumPlanes;
  85954. private _storedFov;
  85955. private _stateStored;
  85956. /**
  85957. * Instantiates a new camera object.
  85958. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  85959. * @see http://doc.babylonjs.com/features/cameras
  85960. * @param name Defines the name of the camera in the scene
  85961. * @param position Defines the position of the camera
  85962. * @param scene Defines the scene the camera belongs too
  85963. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  85964. */
  85965. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85966. /**
  85967. * Store current camera state (fov, position, etc..)
  85968. * @returns the camera
  85969. */
  85970. storeState(): Camera;
  85971. /**
  85972. * Restores the camera state values if it has been stored. You must call storeState() first
  85973. */
  85974. protected _restoreStateValues(): boolean;
  85975. /**
  85976. * Restored camera state. You must call storeState() first.
  85977. * @returns true if restored and false otherwise
  85978. */
  85979. restoreState(): boolean;
  85980. /**
  85981. * Gets the class name of the camera.
  85982. * @returns the class name
  85983. */
  85984. getClassName(): string;
  85985. /** @hidden */
  85986. readonly _isCamera: boolean;
  85987. /**
  85988. * Gets a string representation of the camera useful for debug purpose.
  85989. * @param fullDetails Defines that a more verboe level of logging is required
  85990. * @returns the string representation
  85991. */
  85992. toString(fullDetails?: boolean): string;
  85993. /**
  85994. * Gets the current world space position of the camera.
  85995. */
  85996. readonly globalPosition: Vector3;
  85997. /**
  85998. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  85999. * @returns the active meshe list
  86000. */
  86001. getActiveMeshes(): SmartArray<AbstractMesh>;
  86002. /**
  86003. * Check wether a mesh is part of the current active mesh list of the camera
  86004. * @param mesh Defines the mesh to check
  86005. * @returns true if active, false otherwise
  86006. */
  86007. isActiveMesh(mesh: Mesh): boolean;
  86008. /**
  86009. * Is this camera ready to be used/rendered
  86010. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86011. * @return true if the camera is ready
  86012. */
  86013. isReady(completeCheck?: boolean): boolean;
  86014. /** @hidden */
  86015. _initCache(): void;
  86016. /** @hidden */
  86017. _updateCache(ignoreParentClass?: boolean): void;
  86018. /** @hidden */
  86019. _isSynchronized(): boolean;
  86020. /** @hidden */
  86021. _isSynchronizedViewMatrix(): boolean;
  86022. /** @hidden */
  86023. _isSynchronizedProjectionMatrix(): boolean;
  86024. /**
  86025. * Attach the input controls to a specific dom element to get the input from.
  86026. * @param element Defines the element the controls should be listened from
  86027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86028. */
  86029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86030. /**
  86031. * Detach the current controls from the specified dom element.
  86032. * @param element Defines the element to stop listening the inputs from
  86033. */
  86034. detachControl(element: HTMLElement): void;
  86035. /**
  86036. * Update the camera state according to the different inputs gathered during the frame.
  86037. */
  86038. update(): void;
  86039. /** @hidden */
  86040. _checkInputs(): void;
  86041. /** @hidden */
  86042. readonly rigCameras: Camera[];
  86043. /**
  86044. * Gets the post process used by the rig cameras
  86045. */
  86046. readonly rigPostProcess: Nullable<PostProcess>;
  86047. /**
  86048. * Internal, gets the first post proces.
  86049. * @returns the first post process to be run on this camera.
  86050. */
  86051. _getFirstPostProcess(): Nullable<PostProcess>;
  86052. private _cascadePostProcessesToRigCams;
  86053. /**
  86054. * Attach a post process to the camera.
  86055. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86056. * @param postProcess The post process to attach to the camera
  86057. * @param insertAt The position of the post process in case several of them are in use in the scene
  86058. * @returns the position the post process has been inserted at
  86059. */
  86060. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86061. /**
  86062. * Detach a post process to the camera.
  86063. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86064. * @param postProcess The post process to detach from the camera
  86065. */
  86066. detachPostProcess(postProcess: PostProcess): void;
  86067. /**
  86068. * Gets the current world matrix of the camera
  86069. */
  86070. getWorldMatrix(): Matrix;
  86071. /** @hidden */
  86072. _getViewMatrix(): Matrix;
  86073. /**
  86074. * Gets the current view matrix of the camera.
  86075. * @param force forces the camera to recompute the matrix without looking at the cached state
  86076. * @returns the view matrix
  86077. */
  86078. getViewMatrix(force?: boolean): Matrix;
  86079. /**
  86080. * Freeze the projection matrix.
  86081. * It will prevent the cache check of the camera projection compute and can speed up perf
  86082. * if no parameter of the camera are meant to change
  86083. * @param projection Defines manually a projection if necessary
  86084. */
  86085. freezeProjectionMatrix(projection?: Matrix): void;
  86086. /**
  86087. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86088. */
  86089. unfreezeProjectionMatrix(): void;
  86090. /**
  86091. * Gets the current projection matrix of the camera.
  86092. * @param force forces the camera to recompute the matrix without looking at the cached state
  86093. * @returns the projection matrix
  86094. */
  86095. getProjectionMatrix(force?: boolean): Matrix;
  86096. /**
  86097. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86098. * @returns a Matrix
  86099. */
  86100. getTransformationMatrix(): Matrix;
  86101. private _updateFrustumPlanes;
  86102. /**
  86103. * Checks if a cullable object (mesh...) is in the camera frustum
  86104. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86105. * @param target The object to check
  86106. * @returns true if the object is in frustum otherwise false
  86107. */
  86108. isInFrustum(target: ICullable): boolean;
  86109. /**
  86110. * Checks if a cullable object (mesh...) is in the camera frustum
  86111. * Unlike isInFrustum this cheks the full bounding box
  86112. * @param target The object to check
  86113. * @returns true if the object is in frustum otherwise false
  86114. */
  86115. isCompletelyInFrustum(target: ICullable): boolean;
  86116. /**
  86117. * Gets a ray in the forward direction from the camera.
  86118. * @param length Defines the length of the ray to create
  86119. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86120. * @param origin Defines the start point of the ray which defaults to the camera position
  86121. * @returns the forward ray
  86122. */
  86123. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86124. /**
  86125. * Releases resources associated with this node.
  86126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86128. */
  86129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86130. /**
  86131. * Gets the left camera of a rig setup in case of Rigged Camera
  86132. */
  86133. readonly leftCamera: Nullable<FreeCamera>;
  86134. /**
  86135. * Gets the right camera of a rig setup in case of Rigged Camera
  86136. */
  86137. readonly rightCamera: Nullable<FreeCamera>;
  86138. /**
  86139. * Gets the left camera target of a rig setup in case of Rigged Camera
  86140. * @returns the target position
  86141. */
  86142. getLeftTarget(): Nullable<Vector3>;
  86143. /**
  86144. * Gets the right camera target of a rig setup in case of Rigged Camera
  86145. * @returns the target position
  86146. */
  86147. getRightTarget(): Nullable<Vector3>;
  86148. /**
  86149. * @hidden
  86150. */
  86151. setCameraRigMode(mode: number, rigParams: any): void;
  86152. /** @hidden */
  86153. static _setStereoscopicRigMode(camera: Camera): void;
  86154. /** @hidden */
  86155. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86156. /** @hidden */
  86157. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86158. /** @hidden */
  86159. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86160. /** @hidden */
  86161. _getVRProjectionMatrix(): Matrix;
  86162. protected _updateCameraRotationMatrix(): void;
  86163. protected _updateWebVRCameraRotationMatrix(): void;
  86164. /**
  86165. * This function MUST be overwritten by the different WebVR cameras available.
  86166. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86167. * @hidden
  86168. */
  86169. _getWebVRProjectionMatrix(): Matrix;
  86170. /**
  86171. * This function MUST be overwritten by the different WebVR cameras available.
  86172. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86173. * @hidden
  86174. */
  86175. _getWebVRViewMatrix(): Matrix;
  86176. /** @hidden */
  86177. setCameraRigParameter(name: string, value: any): void;
  86178. /**
  86179. * needs to be overridden by children so sub has required properties to be copied
  86180. * @hidden
  86181. */
  86182. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86183. /**
  86184. * May need to be overridden by children
  86185. * @hidden
  86186. */
  86187. _updateRigCameras(): void;
  86188. /** @hidden */
  86189. _setupInputs(): void;
  86190. /**
  86191. * Serialiaze the camera setup to a json represention
  86192. * @returns the JSON representation
  86193. */
  86194. serialize(): any;
  86195. /**
  86196. * Clones the current camera.
  86197. * @param name The cloned camera name
  86198. * @returns the cloned camera
  86199. */
  86200. clone(name: string): Camera;
  86201. /**
  86202. * Gets the direction of the camera relative to a given local axis.
  86203. * @param localAxis Defines the reference axis to provide a relative direction.
  86204. * @return the direction
  86205. */
  86206. getDirection(localAxis: Vector3): Vector3;
  86207. /**
  86208. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86209. * @param localAxis Defines the reference axis to provide a relative direction.
  86210. * @param result Defines the vector to store the result in
  86211. */
  86212. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86213. /**
  86214. * Gets a camera constructor for a given camera type
  86215. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86216. * @param name The name of the camera the result will be able to instantiate
  86217. * @param scene The scene the result will construct the camera in
  86218. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86219. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86220. * @returns a factory method to construc the camera
  86221. */
  86222. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86223. /**
  86224. * Compute the world matrix of the camera.
  86225. * @returns the camera workd matrix
  86226. */
  86227. computeWorldMatrix(): Matrix;
  86228. /**
  86229. * Parse a JSON and creates the camera from the parsed information
  86230. * @param parsedCamera The JSON to parse
  86231. * @param scene The scene to instantiate the camera in
  86232. * @returns the newly constructed camera
  86233. */
  86234. static Parse(parsedCamera: any, scene: Scene): Camera;
  86235. }
  86236. }
  86237. declare module BABYLON {
  86238. /**
  86239. * Interface for any object that can request an animation frame
  86240. */
  86241. export interface ICustomAnimationFrameRequester {
  86242. /**
  86243. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86244. */
  86245. renderFunction?: Function;
  86246. /**
  86247. * Called to request the next frame to render to
  86248. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86249. */
  86250. requestAnimationFrame: Function;
  86251. /**
  86252. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86253. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86254. */
  86255. requestID?: number;
  86256. }
  86257. /**
  86258. * Interface containing an array of animations
  86259. */
  86260. export interface IAnimatable {
  86261. /**
  86262. * Array of animations
  86263. */
  86264. animations: Array<Animation>;
  86265. }
  86266. /** Interface used by value gradients (color, factor, ...) */
  86267. export interface IValueGradient {
  86268. /**
  86269. * Gets or sets the gradient value (between 0 and 1)
  86270. */
  86271. gradient: number;
  86272. }
  86273. /** Class used to store color4 gradient */
  86274. export class ColorGradient implements IValueGradient {
  86275. /**
  86276. * Gets or sets the gradient value (between 0 and 1)
  86277. */
  86278. gradient: number;
  86279. /**
  86280. * Gets or sets first associated color
  86281. */
  86282. color1: Color4;
  86283. /**
  86284. * Gets or sets second associated color
  86285. */
  86286. color2?: Color4;
  86287. /**
  86288. * Will get a color picked randomly between color1 and color2.
  86289. * If color2 is undefined then color1 will be used
  86290. * @param result defines the target Color4 to store the result in
  86291. */
  86292. getColorToRef(result: Color4): void;
  86293. }
  86294. /** Class used to store color 3 gradient */
  86295. export class Color3Gradient implements IValueGradient {
  86296. /**
  86297. * Gets or sets the gradient value (between 0 and 1)
  86298. */
  86299. gradient: number;
  86300. /**
  86301. * Gets or sets the associated color
  86302. */
  86303. color: Color3;
  86304. }
  86305. /** Class used to store factor gradient */
  86306. export class FactorGradient implements IValueGradient {
  86307. /**
  86308. * Gets or sets the gradient value (between 0 and 1)
  86309. */
  86310. gradient: number;
  86311. /**
  86312. * Gets or sets first associated factor
  86313. */
  86314. factor1: number;
  86315. /**
  86316. * Gets or sets second associated factor
  86317. */
  86318. factor2?: number;
  86319. /**
  86320. * Will get a number picked randomly between factor1 and factor2.
  86321. * If factor2 is undefined then factor1 will be used
  86322. * @returns the picked number
  86323. */
  86324. getFactor(): number;
  86325. }
  86326. /**
  86327. * @ignore
  86328. * Application error to support additional information when loading a file
  86329. */
  86330. export class LoadFileError extends Error {
  86331. /** defines the optional XHR request */
  86332. request?: XMLHttpRequest | undefined;
  86333. private static _setPrototypeOf;
  86334. /**
  86335. * Creates a new LoadFileError
  86336. * @param message defines the message of the error
  86337. * @param request defines the optional XHR request
  86338. */
  86339. constructor(message: string,
  86340. /** defines the optional XHR request */
  86341. request?: XMLHttpRequest | undefined);
  86342. }
  86343. /**
  86344. * Class used to define a retry strategy when error happens while loading assets
  86345. */
  86346. export class RetryStrategy {
  86347. /**
  86348. * Function used to defines an exponential back off strategy
  86349. * @param maxRetries defines the maximum number of retries (3 by default)
  86350. * @param baseInterval defines the interval between retries
  86351. * @returns the strategy function to use
  86352. */
  86353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86354. }
  86355. /**
  86356. * File request interface
  86357. */
  86358. export interface IFileRequest {
  86359. /**
  86360. * Raised when the request is complete (success or error).
  86361. */
  86362. onCompleteObservable: Observable<IFileRequest>;
  86363. /**
  86364. * Aborts the request for a file.
  86365. */
  86366. abort: () => void;
  86367. }
  86368. /**
  86369. * Class containing a set of static utilities functions
  86370. */
  86371. export class Tools {
  86372. /**
  86373. * Gets or sets the base URL to use to load assets
  86374. */
  86375. static BaseUrl: string;
  86376. /**
  86377. * Enable/Disable Custom HTTP Request Headers globally.
  86378. * default = false
  86379. * @see CustomRequestHeaders
  86380. */
  86381. static UseCustomRequestHeaders: boolean;
  86382. /**
  86383. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86384. * i.e. when loading files, where the server/service expects an Authorization header.
  86385. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86386. */
  86387. static CustomRequestHeaders: {
  86388. [key: string]: string;
  86389. };
  86390. /**
  86391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86392. */
  86393. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86394. /**
  86395. * Default behaviour for cors in the application.
  86396. * It can be a string if the expected behavior is identical in the entire app.
  86397. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86398. */
  86399. static CorsBehavior: string | ((url: string | string[]) => string);
  86400. /**
  86401. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86402. * @ignorenaming
  86403. */
  86404. static UseFallbackTexture: boolean;
  86405. /**
  86406. * Use this object to register external classes like custom textures or material
  86407. * to allow the laoders to instantiate them
  86408. */
  86409. static RegisteredExternalClasses: {
  86410. [key: string]: Object;
  86411. };
  86412. /**
  86413. * Texture content used if a texture cannot loaded
  86414. * @ignorenaming
  86415. */
  86416. static fallbackTexture: string;
  86417. /**
  86418. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86419. * @param u defines the coordinate on X axis
  86420. * @param v defines the coordinate on Y axis
  86421. * @param width defines the width of the source data
  86422. * @param height defines the height of the source data
  86423. * @param pixels defines the source byte array
  86424. * @param color defines the output color
  86425. */
  86426. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86427. /**
  86428. * Interpolates between a and b via alpha
  86429. * @param a The lower value (returned when alpha = 0)
  86430. * @param b The upper value (returned when alpha = 1)
  86431. * @param alpha The interpolation-factor
  86432. * @return The mixed value
  86433. */
  86434. static Mix(a: number, b: number, alpha: number): number;
  86435. /**
  86436. * Tries to instantiate a new object from a given class name
  86437. * @param className defines the class name to instantiate
  86438. * @returns the new object or null if the system was not able to do the instantiation
  86439. */
  86440. static Instantiate(className: string): any;
  86441. /**
  86442. * Provides a slice function that will work even on IE
  86443. * @param data defines the array to slice
  86444. * @param start defines the start of the data (optional)
  86445. * @param end defines the end of the data (optional)
  86446. * @returns the new sliced array
  86447. */
  86448. static Slice<T>(data: T, start?: number, end?: number): T;
  86449. /**
  86450. * Polyfill for setImmediate
  86451. * @param action defines the action to execute after the current execution block
  86452. */
  86453. static SetImmediate(action: () => void): void;
  86454. /**
  86455. * Function indicating if a number is an exponent of 2
  86456. * @param value defines the value to test
  86457. * @returns true if the value is an exponent of 2
  86458. */
  86459. static IsExponentOfTwo(value: number): boolean;
  86460. private static _tmpFloatArray;
  86461. /**
  86462. * Returns the nearest 32-bit single precision float representation of a Number
  86463. * @param value A Number. If the parameter is of a different type, it will get converted
  86464. * to a number or to NaN if it cannot be converted
  86465. * @returns number
  86466. */
  86467. static FloatRound(value: number): number;
  86468. /**
  86469. * Find the next highest power of two.
  86470. * @param x Number to start search from.
  86471. * @return Next highest power of two.
  86472. */
  86473. static CeilingPOT(x: number): number;
  86474. /**
  86475. * Find the next lowest power of two.
  86476. * @param x Number to start search from.
  86477. * @return Next lowest power of two.
  86478. */
  86479. static FloorPOT(x: number): number;
  86480. /**
  86481. * Find the nearest power of two.
  86482. * @param x Number to start search from.
  86483. * @return Next nearest power of two.
  86484. */
  86485. static NearestPOT(x: number): number;
  86486. /**
  86487. * Get the closest exponent of two
  86488. * @param value defines the value to approximate
  86489. * @param max defines the maximum value to return
  86490. * @param mode defines how to define the closest value
  86491. * @returns closest exponent of two of the given value
  86492. */
  86493. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86494. /**
  86495. * Extracts the filename from a path
  86496. * @param path defines the path to use
  86497. * @returns the filename
  86498. */
  86499. static GetFilename(path: string): string;
  86500. /**
  86501. * Extracts the "folder" part of a path (everything before the filename).
  86502. * @param uri The URI to extract the info from
  86503. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86504. * @returns The "folder" part of the path
  86505. */
  86506. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86507. /**
  86508. * Extracts text content from a DOM element hierarchy
  86509. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86510. */
  86511. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86512. /**
  86513. * Convert an angle in radians to degrees
  86514. * @param angle defines the angle to convert
  86515. * @returns the angle in degrees
  86516. */
  86517. static ToDegrees(angle: number): number;
  86518. /**
  86519. * Convert an angle in degrees to radians
  86520. * @param angle defines the angle to convert
  86521. * @returns the angle in radians
  86522. */
  86523. static ToRadians(angle: number): number;
  86524. /**
  86525. * Encode a buffer to a base64 string
  86526. * @param buffer defines the buffer to encode
  86527. * @returns the encoded string
  86528. */
  86529. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86530. /**
  86531. * Extracts minimum and maximum values from a list of indexed positions
  86532. * @param positions defines the positions to use
  86533. * @param indices defines the indices to the positions
  86534. * @param indexStart defines the start index
  86535. * @param indexCount defines the end index
  86536. * @param bias defines bias value to add to the result
  86537. * @return minimum and maximum values
  86538. */
  86539. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86540. minimum: Vector3;
  86541. maximum: Vector3;
  86542. };
  86543. /**
  86544. * Extracts minimum and maximum values from a list of positions
  86545. * @param positions defines the positions to use
  86546. * @param start defines the start index in the positions array
  86547. * @param count defines the number of positions to handle
  86548. * @param bias defines bias value to add to the result
  86549. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86550. * @return minimum and maximum values
  86551. */
  86552. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86553. minimum: Vector3;
  86554. maximum: Vector3;
  86555. };
  86556. /**
  86557. * Returns an array if obj is not an array
  86558. * @param obj defines the object to evaluate as an array
  86559. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86560. * @returns either obj directly if obj is an array or a new array containing obj
  86561. */
  86562. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86563. /**
  86564. * Gets the pointer prefix to use
  86565. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86566. */
  86567. static GetPointerPrefix(): string;
  86568. /**
  86569. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86570. * @param func - the function to be called
  86571. * @param requester - the object that will request the next frame. Falls back to window.
  86572. * @returns frame number
  86573. */
  86574. static QueueNewFrame(func: () => void, requester?: any): number;
  86575. /**
  86576. * Ask the browser to promote the current element to fullscreen rendering mode
  86577. * @param element defines the DOM element to promote
  86578. */
  86579. static RequestFullscreen(element: HTMLElement): void;
  86580. /**
  86581. * Asks the browser to exit fullscreen mode
  86582. */
  86583. static ExitFullscreen(): void;
  86584. /**
  86585. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86586. * @param url define the url we are trying
  86587. * @param element define the dom element where to configure the cors policy
  86588. */
  86589. static SetCorsBehavior(url: string | string[], element: {
  86590. crossOrigin: string | null;
  86591. }): void;
  86592. /**
  86593. * Removes unwanted characters from an url
  86594. * @param url defines the url to clean
  86595. * @returns the cleaned url
  86596. */
  86597. static CleanUrl(url: string): string;
  86598. /**
  86599. * Gets or sets a function used to pre-process url before using them to load assets
  86600. */
  86601. static PreprocessUrl: (url: string) => string;
  86602. /**
  86603. * Loads an image as an HTMLImageElement.
  86604. * @param input url string, ArrayBuffer, or Blob to load
  86605. * @param onLoad callback called when the image successfully loads
  86606. * @param onError callback called when the image fails to load
  86607. * @param offlineProvider offline provider for caching
  86608. * @returns the HTMLImageElement of the loaded image
  86609. */
  86610. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86611. /**
  86612. * Loads a file
  86613. * @param url url string, ArrayBuffer, or Blob to load
  86614. * @param onSuccess callback called when the file successfully loads
  86615. * @param onProgress callback called while file is loading (if the server supports this mode)
  86616. * @param offlineProvider defines the offline provider for caching
  86617. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86618. * @param onError callback called when the file fails to load
  86619. * @returns a file request object
  86620. */
  86621. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  86622. /**
  86623. * Load a script (identified by an url). When the url returns, the
  86624. * content of this file is added into a new script element, attached to the DOM (body element)
  86625. * @param scriptUrl defines the url of the script to laod
  86626. * @param onSuccess defines the callback called when the script is loaded
  86627. * @param onError defines the callback to call if an error occurs
  86628. */
  86629. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86630. /**
  86631. * Loads a file from a blob
  86632. * @param fileToLoad defines the blob to use
  86633. * @param callback defines the callback to call when data is loaded
  86634. * @param progressCallback defines the callback to call during loading process
  86635. * @returns a file request object
  86636. */
  86637. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86638. /**
  86639. * Loads a file
  86640. * @param fileToLoad defines the file to load
  86641. * @param callback defines the callback to call when data is loaded
  86642. * @param progressCallBack defines the callback to call during loading process
  86643. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86644. * @returns a file request object
  86645. */
  86646. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86647. /**
  86648. * Creates a data url from a given string content
  86649. * @param content defines the content to convert
  86650. * @returns the new data url link
  86651. */
  86652. static FileAsURL(content: string): string;
  86653. /**
  86654. * Format the given number to a specific decimal format
  86655. * @param value defines the number to format
  86656. * @param decimals defines the number of decimals to use
  86657. * @returns the formatted string
  86658. */
  86659. static Format(value: number, decimals?: number): string;
  86660. /**
  86661. * Checks if a given vector is inside a specific range
  86662. * @param v defines the vector to test
  86663. * @param min defines the minimum range
  86664. * @param max defines the maximum range
  86665. */
  86666. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86667. /**
  86668. * Tries to copy an object by duplicating every property
  86669. * @param source defines the source object
  86670. * @param destination defines the target object
  86671. * @param doNotCopyList defines a list of properties to avoid
  86672. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86673. */
  86674. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86675. /**
  86676. * Gets a boolean indicating if the given object has no own property
  86677. * @param obj defines the object to test
  86678. * @returns true if object has no own property
  86679. */
  86680. static IsEmpty(obj: any): boolean;
  86681. /**
  86682. * Function used to register events at window level
  86683. * @param events defines the events to register
  86684. */
  86685. static RegisterTopRootEvents(events: {
  86686. name: string;
  86687. handler: Nullable<(e: FocusEvent) => any>;
  86688. }[]): void;
  86689. /**
  86690. * Function used to unregister events from window level
  86691. * @param events defines the events to unregister
  86692. */
  86693. static UnregisterTopRootEvents(events: {
  86694. name: string;
  86695. handler: Nullable<(e: FocusEvent) => any>;
  86696. }[]): void;
  86697. /**
  86698. * Dumps the current bound framebuffer
  86699. * @param width defines the rendering width
  86700. * @param height defines the rendering height
  86701. * @param engine defines the hosting engine
  86702. * @param successCallback defines the callback triggered once the data are available
  86703. * @param mimeType defines the mime type of the result
  86704. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86705. */
  86706. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86707. /**
  86708. * Converts the canvas data to blob.
  86709. * This acts as a polyfill for browsers not supporting the to blob function.
  86710. * @param canvas Defines the canvas to extract the data from
  86711. * @param successCallback Defines the callback triggered once the data are available
  86712. * @param mimeType Defines the mime type of the result
  86713. */
  86714. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86715. /**
  86716. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86717. * @param successCallback defines the callback triggered once the data are available
  86718. * @param mimeType defines the mime type of the result
  86719. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86720. */
  86721. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86722. /**
  86723. * Downloads a blob in the browser
  86724. * @param blob defines the blob to download
  86725. * @param fileName defines the name of the downloaded file
  86726. */
  86727. static Download(blob: Blob, fileName: string): void;
  86728. /**
  86729. * Captures a screenshot of the current rendering
  86730. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86731. * @param engine defines the rendering engine
  86732. * @param camera defines the source camera
  86733. * @param size This parameter can be set to a single number or to an object with the
  86734. * following (optional) properties: precision, width, height. If a single number is passed,
  86735. * it will be used for both width and height. If an object is passed, the screenshot size
  86736. * will be derived from the parameters. The precision property is a multiplier allowing
  86737. * rendering at a higher or lower resolution
  86738. * @param successCallback defines the callback receives a single parameter which contains the
  86739. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86740. * src parameter of an <img> to display it
  86741. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86742. * Check your browser for supported MIME types
  86743. */
  86744. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86745. /**
  86746. * Generates an image screenshot from the specified camera.
  86747. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86748. * @param engine The engine to use for rendering
  86749. * @param camera The camera to use for rendering
  86750. * @param size This parameter can be set to a single number or to an object with the
  86751. * following (optional) properties: precision, width, height. If a single number is passed,
  86752. * it will be used for both width and height. If an object is passed, the screenshot size
  86753. * will be derived from the parameters. The precision property is a multiplier allowing
  86754. * rendering at a higher or lower resolution
  86755. * @param successCallback The callback receives a single parameter which contains the
  86756. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86757. * src parameter of an <img> to display it
  86758. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86759. * Check your browser for supported MIME types
  86760. * @param samples Texture samples (default: 1)
  86761. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86762. * @param fileName A name for for the downloaded file.
  86763. */
  86764. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86765. /**
  86766. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86767. * Be aware Math.random() could cause collisions, but:
  86768. * "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"
  86769. * @returns a pseudo random id
  86770. */
  86771. static RandomId(): string;
  86772. /**
  86773. * Test if the given uri is a base64 string
  86774. * @param uri The uri to test
  86775. * @return True if the uri is a base64 string or false otherwise
  86776. */
  86777. static IsBase64(uri: string): boolean;
  86778. /**
  86779. * Decode the given base64 uri.
  86780. * @param uri The uri to decode
  86781. * @return The decoded base64 data.
  86782. */
  86783. static DecodeBase64(uri: string): ArrayBuffer;
  86784. /**
  86785. * No log
  86786. */
  86787. static readonly NoneLogLevel: number;
  86788. /**
  86789. * Only message logs
  86790. */
  86791. static readonly MessageLogLevel: number;
  86792. /**
  86793. * Only warning logs
  86794. */
  86795. static readonly WarningLogLevel: number;
  86796. /**
  86797. * Only error logs
  86798. */
  86799. static readonly ErrorLogLevel: number;
  86800. /**
  86801. * All logs
  86802. */
  86803. static readonly AllLogLevel: number;
  86804. /**
  86805. * Gets a value indicating the number of loading errors
  86806. * @ignorenaming
  86807. */
  86808. static readonly errorsCount: number;
  86809. /**
  86810. * Callback called when a new log is added
  86811. */
  86812. static OnNewCacheEntry: (entry: string) => void;
  86813. /**
  86814. * Log a message to the console
  86815. * @param message defines the message to log
  86816. */
  86817. static Log(message: string): void;
  86818. /**
  86819. * Write a warning message to the console
  86820. * @param message defines the message to log
  86821. */
  86822. static Warn(message: string): void;
  86823. /**
  86824. * Write an error message to the console
  86825. * @param message defines the message to log
  86826. */
  86827. static Error(message: string): void;
  86828. /**
  86829. * Gets current log cache (list of logs)
  86830. */
  86831. static readonly LogCache: string;
  86832. /**
  86833. * Clears the log cache
  86834. */
  86835. static ClearLogCache(): void;
  86836. /**
  86837. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86838. */
  86839. static LogLevels: number;
  86840. /**
  86841. * Checks if the loaded document was accessed via `file:`-Protocol.
  86842. * @returns boolean
  86843. */
  86844. static IsFileURL(): boolean;
  86845. /**
  86846. * Checks if the window object exists
  86847. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86848. */
  86849. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86850. /**
  86851. * No performance log
  86852. */
  86853. static readonly PerformanceNoneLogLevel: number;
  86854. /**
  86855. * Use user marks to log performance
  86856. */
  86857. static readonly PerformanceUserMarkLogLevel: number;
  86858. /**
  86859. * Log performance to the console
  86860. */
  86861. static readonly PerformanceConsoleLogLevel: number;
  86862. private static _performance;
  86863. /**
  86864. * Sets the current performance log level
  86865. */
  86866. static PerformanceLogLevel: number;
  86867. private static _StartPerformanceCounterDisabled;
  86868. private static _EndPerformanceCounterDisabled;
  86869. private static _StartUserMark;
  86870. private static _EndUserMark;
  86871. private static _StartPerformanceConsole;
  86872. private static _EndPerformanceConsole;
  86873. /**
  86874. * Injects the @see CustomRequestHeaders into the given request
  86875. * @param request the request that should be used for injection
  86876. */
  86877. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86878. /**
  86879. * Starts a performance counter
  86880. */
  86881. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86882. /**
  86883. * Ends a specific performance coutner
  86884. */
  86885. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86886. /**
  86887. * Gets either window.performance.now() if supported or Date.now() else
  86888. */
  86889. static readonly Now: number;
  86890. /**
  86891. * This method will return the name of the class used to create the instance of the given object.
  86892. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86893. * @param object the object to get the class name from
  86894. * @param isType defines if the object is actually a type
  86895. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86896. */
  86897. static GetClassName(object: any, isType?: boolean): string;
  86898. /**
  86899. * Gets the first element of an array satisfying a given predicate
  86900. * @param array defines the array to browse
  86901. * @param predicate defines the predicate to use
  86902. * @returns null if not found or the element
  86903. */
  86904. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86905. /**
  86906. * This method will return the name of the full name of the class, including its owning module (if any).
  86907. * 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).
  86908. * @param object the object to get the class name from
  86909. * @param isType defines if the object is actually a type
  86910. * @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.
  86911. * @ignorenaming
  86912. */
  86913. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86914. /**
  86915. * Returns a promise that resolves after the given amount of time.
  86916. * @param delay Number of milliseconds to delay
  86917. * @returns Promise that resolves after the given amount of time
  86918. */
  86919. static DelayAsync(delay: number): Promise<void>;
  86920. /**
  86921. * Gets the current gradient from an array of IValueGradient
  86922. * @param ratio defines the current ratio to get
  86923. * @param gradients defines the array of IValueGradient
  86924. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86925. */
  86926. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86927. }
  86928. /**
  86929. * This class is used to track a performance counter which is number based.
  86930. * The user has access to many properties which give statistics of different nature.
  86931. *
  86932. * The implementer can track two kinds of Performance Counter: time and count.
  86933. * 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.
  86934. * 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.
  86935. */
  86936. export class PerfCounter {
  86937. /**
  86938. * Gets or sets a global boolean to turn on and off all the counters
  86939. */
  86940. static Enabled: boolean;
  86941. /**
  86942. * Returns the smallest value ever
  86943. */
  86944. readonly min: number;
  86945. /**
  86946. * Returns the biggest value ever
  86947. */
  86948. readonly max: number;
  86949. /**
  86950. * Returns the average value since the performance counter is running
  86951. */
  86952. readonly average: number;
  86953. /**
  86954. * Returns the average value of the last second the counter was monitored
  86955. */
  86956. readonly lastSecAverage: number;
  86957. /**
  86958. * Returns the current value
  86959. */
  86960. readonly current: number;
  86961. /**
  86962. * Gets the accumulated total
  86963. */
  86964. readonly total: number;
  86965. /**
  86966. * Gets the total value count
  86967. */
  86968. readonly count: number;
  86969. /**
  86970. * Creates a new counter
  86971. */
  86972. constructor();
  86973. /**
  86974. * Call this method to start monitoring a new frame.
  86975. * 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.
  86976. */
  86977. fetchNewFrame(): void;
  86978. /**
  86979. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  86980. * @param newCount the count value to add to the monitored count
  86981. * @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.
  86982. */
  86983. addCount(newCount: number, fetchResult: boolean): void;
  86984. /**
  86985. * Start monitoring this performance counter
  86986. */
  86987. beginMonitoring(): void;
  86988. /**
  86989. * Compute the time lapsed since the previous beginMonitoring() call.
  86990. * @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
  86991. */
  86992. endMonitoring(newFrame?: boolean): void;
  86993. private _fetchResult;
  86994. private _startMonitoringTime;
  86995. private _min;
  86996. private _max;
  86997. private _average;
  86998. private _current;
  86999. private _totalValueCount;
  87000. private _totalAccumulated;
  87001. private _lastSecAverage;
  87002. private _lastSecAccumulated;
  87003. private _lastSecTime;
  87004. private _lastSecValueCount;
  87005. }
  87006. /**
  87007. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87008. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87009. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87010. * @param name The name of the class, case should be preserved
  87011. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87012. */
  87013. export function className(name: string, module?: string): (target: Object) => void;
  87014. /**
  87015. * An implementation of a loop for asynchronous functions.
  87016. */
  87017. export class AsyncLoop {
  87018. /**
  87019. * Defines the number of iterations for the loop
  87020. */
  87021. iterations: number;
  87022. /**
  87023. * Defines the current index of the loop.
  87024. */
  87025. index: number;
  87026. private _done;
  87027. private _fn;
  87028. private _successCallback;
  87029. /**
  87030. * Constructor.
  87031. * @param iterations the number of iterations.
  87032. * @param func the function to run each iteration
  87033. * @param successCallback the callback that will be called upon succesful execution
  87034. * @param offset starting offset.
  87035. */
  87036. constructor(
  87037. /**
  87038. * Defines the number of iterations for the loop
  87039. */
  87040. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87041. /**
  87042. * Execute the next iteration. Must be called after the last iteration was finished.
  87043. */
  87044. executeNext(): void;
  87045. /**
  87046. * Break the loop and run the success callback.
  87047. */
  87048. breakLoop(): void;
  87049. /**
  87050. * Create and run an async loop.
  87051. * @param iterations the number of iterations.
  87052. * @param fn the function to run each iteration
  87053. * @param successCallback the callback that will be called upon succesful execution
  87054. * @param offset starting offset.
  87055. * @returns the created async loop object
  87056. */
  87057. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87058. /**
  87059. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87060. * @param iterations total number of iterations
  87061. * @param syncedIterations number of synchronous iterations in each async iteration.
  87062. * @param fn the function to call each iteration.
  87063. * @param callback a success call back that will be called when iterating stops.
  87064. * @param breakFunction a break condition (optional)
  87065. * @param timeout timeout settings for the setTimeout function. default - 0.
  87066. * @returns the created async loop object
  87067. */
  87068. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. /** @hidden */
  87073. export interface ICollisionCoordinator {
  87074. createCollider(): Collider;
  87075. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87076. init(scene: Scene): void;
  87077. }
  87078. /** @hidden */
  87079. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87080. private _scene;
  87081. private _scaledPosition;
  87082. private _scaledVelocity;
  87083. private _finalPosition;
  87084. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87085. createCollider(): Collider;
  87086. init(scene: Scene): void;
  87087. private _collideWithWorld;
  87088. }
  87089. }
  87090. declare module BABYLON {
  87091. /**
  87092. * This class defines the direct association between an animation and a target
  87093. */
  87094. export class TargetedAnimation {
  87095. /**
  87096. * Animation to perform
  87097. */
  87098. animation: Animation;
  87099. /**
  87100. * Target to animate
  87101. */
  87102. target: any;
  87103. }
  87104. /**
  87105. * Use this class to create coordinated animations on multiple targets
  87106. */
  87107. export class AnimationGroup implements IDisposable {
  87108. /** The name of the animation group */
  87109. name: string;
  87110. private _scene;
  87111. private _targetedAnimations;
  87112. private _animatables;
  87113. private _from;
  87114. private _to;
  87115. private _isStarted;
  87116. private _isPaused;
  87117. private _speedRatio;
  87118. /**
  87119. * Gets or sets the unique id of the node
  87120. */
  87121. uniqueId: number;
  87122. /**
  87123. * This observable will notify when one animation have ended
  87124. */
  87125. onAnimationEndObservable: Observable<TargetedAnimation>;
  87126. /**
  87127. * Observer raised when one animation loops
  87128. */
  87129. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87130. /**
  87131. * This observable will notify when all animations have ended.
  87132. */
  87133. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87134. /**
  87135. * This observable will notify when all animations have paused.
  87136. */
  87137. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87138. /**
  87139. * This observable will notify when all animations are playing.
  87140. */
  87141. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87142. /**
  87143. * Gets the first frame
  87144. */
  87145. readonly from: number;
  87146. /**
  87147. * Gets the last frame
  87148. */
  87149. readonly to: number;
  87150. /**
  87151. * Define if the animations are started
  87152. */
  87153. readonly isStarted: boolean;
  87154. /**
  87155. * Gets a value indicating that the current group is playing
  87156. */
  87157. readonly isPlaying: boolean;
  87158. /**
  87159. * Gets or sets the speed ratio to use for all animations
  87160. */
  87161. /**
  87162. * Gets or sets the speed ratio to use for all animations
  87163. */
  87164. speedRatio: number;
  87165. /**
  87166. * Gets the targeted animations for this animation group
  87167. */
  87168. readonly targetedAnimations: Array<TargetedAnimation>;
  87169. /**
  87170. * returning the list of animatables controlled by this animation group.
  87171. */
  87172. readonly animatables: Array<Animatable>;
  87173. /**
  87174. * Instantiates a new Animation Group.
  87175. * This helps managing several animations at once.
  87176. * @see http://doc.babylonjs.com/how_to/group
  87177. * @param name Defines the name of the group
  87178. * @param scene Defines the scene the group belongs to
  87179. */
  87180. constructor(
  87181. /** The name of the animation group */
  87182. name: string, scene?: Nullable<Scene>);
  87183. /**
  87184. * Add an animation (with its target) in the group
  87185. * @param animation defines the animation we want to add
  87186. * @param target defines the target of the animation
  87187. * @returns the TargetedAnimation object
  87188. */
  87189. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87190. /**
  87191. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87192. * It can add constant keys at begin or end
  87193. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87194. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87195. * @returns the animation group
  87196. */
  87197. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87198. /**
  87199. * Start all animations on given targets
  87200. * @param loop defines if animations must loop
  87201. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87202. * @param from defines the from key (optional)
  87203. * @param to defines the to key (optional)
  87204. * @returns the current animation group
  87205. */
  87206. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87207. /**
  87208. * Pause all animations
  87209. * @returns the animation group
  87210. */
  87211. pause(): AnimationGroup;
  87212. /**
  87213. * Play all animations to initial state
  87214. * This function will start() the animations if they were not started or will restart() them if they were paused
  87215. * @param loop defines if animations must loop
  87216. * @returns the animation group
  87217. */
  87218. play(loop?: boolean): AnimationGroup;
  87219. /**
  87220. * Reset all animations to initial state
  87221. * @returns the animation group
  87222. */
  87223. reset(): AnimationGroup;
  87224. /**
  87225. * Restart animations from key 0
  87226. * @returns the animation group
  87227. */
  87228. restart(): AnimationGroup;
  87229. /**
  87230. * Stop all animations
  87231. * @returns the animation group
  87232. */
  87233. stop(): AnimationGroup;
  87234. /**
  87235. * Set animation weight for all animatables
  87236. * @param weight defines the weight to use
  87237. * @return the animationGroup
  87238. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87239. */
  87240. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87241. /**
  87242. * Synchronize and normalize all animatables with a source animatable
  87243. * @param root defines the root animatable to synchronize with
  87244. * @return the animationGroup
  87245. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87246. */
  87247. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87248. /**
  87249. * Goes to a specific frame in this animation group
  87250. * @param frame the frame number to go to
  87251. * @return the animationGroup
  87252. */
  87253. goToFrame(frame: number): AnimationGroup;
  87254. /**
  87255. * Dispose all associated resources
  87256. */
  87257. dispose(): void;
  87258. private _checkAnimationGroupEnded;
  87259. /**
  87260. * Returns a new AnimationGroup object parsed from the source provided.
  87261. * @param parsedAnimationGroup defines the source
  87262. * @param scene defines the scene that will receive the animationGroup
  87263. * @returns a new AnimationGroup
  87264. */
  87265. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87266. /**
  87267. * Returns the string "AnimationGroup"
  87268. * @returns "AnimationGroup"
  87269. */
  87270. getClassName(): string;
  87271. /**
  87272. * Creates a detailled string about the object
  87273. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87274. * @returns a string representing the object
  87275. */
  87276. toString(fullDetails?: boolean): string;
  87277. }
  87278. }
  87279. declare module BABYLON {
  87280. /**
  87281. * Define an interface for all classes that will hold resources
  87282. */
  87283. export interface IDisposable {
  87284. /**
  87285. * Releases all held resources
  87286. */
  87287. dispose(): void;
  87288. }
  87289. /** Interface defining initialization parameters for Scene class */
  87290. export interface SceneOptions {
  87291. /**
  87292. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87293. * It will improve performance when the number of geometries becomes important.
  87294. */
  87295. useGeometryUniqueIdsMap?: boolean;
  87296. /**
  87297. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87298. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87299. */
  87300. useMaterialMeshMap?: boolean;
  87301. /**
  87302. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87303. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87304. */
  87305. useClonedMeshhMap?: boolean;
  87306. }
  87307. /**
  87308. * Represents a scene to be rendered by the engine.
  87309. * @see http://doc.babylonjs.com/features/scene
  87310. */
  87311. export class Scene extends AbstractScene implements IAnimatable {
  87312. private static _uniqueIdCounter;
  87313. /** The fog is deactivated */
  87314. static readonly FOGMODE_NONE: number;
  87315. /** The fog density is following an exponential function */
  87316. static readonly FOGMODE_EXP: number;
  87317. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87318. static readonly FOGMODE_EXP2: number;
  87319. /** The fog density is following a linear function. */
  87320. static readonly FOGMODE_LINEAR: number;
  87321. /**
  87322. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87323. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87324. */
  87325. static MinDeltaTime: number;
  87326. /**
  87327. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87329. */
  87330. static MaxDeltaTime: number;
  87331. /**
  87332. * Factory used to create the default material.
  87333. * @param name The name of the material to create
  87334. * @param scene The scene to create the material for
  87335. * @returns The default material
  87336. */
  87337. static DefaultMaterialFactory(scene: Scene): Material;
  87338. /**
  87339. * Factory used to create the a collision coordinator.
  87340. * @returns The collision coordinator
  87341. */
  87342. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87343. /** @hidden */
  87344. readonly _isScene: boolean;
  87345. /**
  87346. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87347. */
  87348. autoClear: boolean;
  87349. /**
  87350. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87351. */
  87352. autoClearDepthAndStencil: boolean;
  87353. /**
  87354. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87355. */
  87356. clearColor: Color4;
  87357. /**
  87358. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87359. */
  87360. ambientColor: Color3;
  87361. /** @hidden */
  87362. _environmentBRDFTexture: BaseTexture;
  87363. /** @hidden */
  87364. protected _environmentTexture: Nullable<BaseTexture>;
  87365. /**
  87366. * Texture used in all pbr material as the reflection texture.
  87367. * As in the majority of the scene they are the same (exception for multi room and so on),
  87368. * this is easier to reference from here than from all the materials.
  87369. */
  87370. /**
  87371. * Texture used in all pbr material as the reflection texture.
  87372. * As in the majority of the scene they are the same (exception for multi room and so on),
  87373. * this is easier to set here than in all the materials.
  87374. */
  87375. environmentTexture: Nullable<BaseTexture>;
  87376. /** @hidden */
  87377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87378. /**
  87379. * Default image processing configuration used either in the rendering
  87380. * Forward main pass or through the imageProcessingPostProcess if present.
  87381. * As in the majority of the scene they are the same (exception for multi camera),
  87382. * this is easier to reference from here than from all the materials and post process.
  87383. *
  87384. * No setter as we it is a shared configuration, you can set the values instead.
  87385. */
  87386. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87387. private _forceWireframe;
  87388. /**
  87389. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87390. */
  87391. forceWireframe: boolean;
  87392. private _forcePointsCloud;
  87393. /**
  87394. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87395. */
  87396. forcePointsCloud: boolean;
  87397. /**
  87398. * Gets or sets the active clipplane 1
  87399. */
  87400. clipPlane: Nullable<Plane>;
  87401. /**
  87402. * Gets or sets the active clipplane 2
  87403. */
  87404. clipPlane2: Nullable<Plane>;
  87405. /**
  87406. * Gets or sets the active clipplane 3
  87407. */
  87408. clipPlane3: Nullable<Plane>;
  87409. /**
  87410. * Gets or sets the active clipplane 4
  87411. */
  87412. clipPlane4: Nullable<Plane>;
  87413. /**
  87414. * Gets or sets a boolean indicating if animations are enabled
  87415. */
  87416. animationsEnabled: boolean;
  87417. private _animationPropertiesOverride;
  87418. /**
  87419. * Gets or sets the animation properties override
  87420. */
  87421. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87422. /**
  87423. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87424. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87425. */
  87426. useConstantAnimationDeltaTime: boolean;
  87427. /**
  87428. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87429. * Please note that it requires to run a ray cast through the scene on every frame
  87430. */
  87431. constantlyUpdateMeshUnderPointer: boolean;
  87432. /**
  87433. * Defines the HTML cursor to use when hovering over interactive elements
  87434. */
  87435. hoverCursor: string;
  87436. /**
  87437. * Defines the HTML default cursor to use (empty by default)
  87438. */
  87439. defaultCursor: string;
  87440. /**
  87441. * This is used to call preventDefault() on pointer down
  87442. * in order to block unwanted artifacts like system double clicks
  87443. */
  87444. preventDefaultOnPointerDown: boolean;
  87445. /**
  87446. * This is used to call preventDefault() on pointer up
  87447. * in order to block unwanted artifacts like system double clicks
  87448. */
  87449. preventDefaultOnPointerUp: boolean;
  87450. /**
  87451. * Gets or sets user defined metadata
  87452. */
  87453. metadata: any;
  87454. /**
  87455. * For internal use only. Please do not use.
  87456. */
  87457. reservedDataStore: any;
  87458. /**
  87459. * Gets the name of the plugin used to load this scene (null by default)
  87460. */
  87461. loadingPluginName: string;
  87462. /**
  87463. * Use this array to add regular expressions used to disable offline support for specific urls
  87464. */
  87465. disableOfflineSupportExceptionRules: RegExp[];
  87466. /**
  87467. * An event triggered when the scene is disposed.
  87468. */
  87469. onDisposeObservable: Observable<Scene>;
  87470. private _onDisposeObserver;
  87471. /** Sets a function to be executed when this scene is disposed. */
  87472. onDispose: () => void;
  87473. /**
  87474. * An event triggered before rendering the scene (right after animations and physics)
  87475. */
  87476. onBeforeRenderObservable: Observable<Scene>;
  87477. private _onBeforeRenderObserver;
  87478. /** Sets a function to be executed before rendering this scene */
  87479. beforeRender: Nullable<() => void>;
  87480. /**
  87481. * An event triggered after rendering the scene
  87482. */
  87483. onAfterRenderObservable: Observable<Scene>;
  87484. private _onAfterRenderObserver;
  87485. /** Sets a function to be executed after rendering this scene */
  87486. afterRender: Nullable<() => void>;
  87487. /**
  87488. * An event triggered before animating the scene
  87489. */
  87490. onBeforeAnimationsObservable: Observable<Scene>;
  87491. /**
  87492. * An event triggered after animations processing
  87493. */
  87494. onAfterAnimationsObservable: Observable<Scene>;
  87495. /**
  87496. * An event triggered before draw calls are ready to be sent
  87497. */
  87498. onBeforeDrawPhaseObservable: Observable<Scene>;
  87499. /**
  87500. * An event triggered after draw calls have been sent
  87501. */
  87502. onAfterDrawPhaseObservable: Observable<Scene>;
  87503. /**
  87504. * An event triggered when the scene is ready
  87505. */
  87506. onReadyObservable: Observable<Scene>;
  87507. /**
  87508. * An event triggered before rendering a camera
  87509. */
  87510. onBeforeCameraRenderObservable: Observable<Camera>;
  87511. private _onBeforeCameraRenderObserver;
  87512. /** Sets a function to be executed before rendering a camera*/
  87513. beforeCameraRender: () => void;
  87514. /**
  87515. * An event triggered after rendering a camera
  87516. */
  87517. onAfterCameraRenderObservable: Observable<Camera>;
  87518. private _onAfterCameraRenderObserver;
  87519. /** Sets a function to be executed after rendering a camera*/
  87520. afterCameraRender: () => void;
  87521. /**
  87522. * An event triggered when active meshes evaluation is about to start
  87523. */
  87524. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87525. /**
  87526. * An event triggered when active meshes evaluation is done
  87527. */
  87528. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87529. /**
  87530. * An event triggered when particles rendering is about to start
  87531. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87532. */
  87533. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87534. /**
  87535. * An event triggered when particles rendering is done
  87536. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87537. */
  87538. onAfterParticlesRenderingObservable: Observable<Scene>;
  87539. /**
  87540. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87541. */
  87542. onDataLoadedObservable: Observable<Scene>;
  87543. /**
  87544. * An event triggered when a camera is created
  87545. */
  87546. onNewCameraAddedObservable: Observable<Camera>;
  87547. /**
  87548. * An event triggered when a camera is removed
  87549. */
  87550. onCameraRemovedObservable: Observable<Camera>;
  87551. /**
  87552. * An event triggered when a light is created
  87553. */
  87554. onNewLightAddedObservable: Observable<Light>;
  87555. /**
  87556. * An event triggered when a light is removed
  87557. */
  87558. onLightRemovedObservable: Observable<Light>;
  87559. /**
  87560. * An event triggered when a geometry is created
  87561. */
  87562. onNewGeometryAddedObservable: Observable<Geometry>;
  87563. /**
  87564. * An event triggered when a geometry is removed
  87565. */
  87566. onGeometryRemovedObservable: Observable<Geometry>;
  87567. /**
  87568. * An event triggered when a transform node is created
  87569. */
  87570. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87571. /**
  87572. * An event triggered when a transform node is removed
  87573. */
  87574. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87575. /**
  87576. * An event triggered when a mesh is created
  87577. */
  87578. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87579. /**
  87580. * An event triggered when a mesh is removed
  87581. */
  87582. onMeshRemovedObservable: Observable<AbstractMesh>;
  87583. /**
  87584. * An event triggered when a material is created
  87585. */
  87586. onNewMaterialAddedObservable: Observable<Material>;
  87587. /**
  87588. * An event triggered when a material is removed
  87589. */
  87590. onMaterialRemovedObservable: Observable<Material>;
  87591. /**
  87592. * An event triggered when a texture is created
  87593. */
  87594. onNewTextureAddedObservable: Observable<BaseTexture>;
  87595. /**
  87596. * An event triggered when a texture is removed
  87597. */
  87598. onTextureRemovedObservable: Observable<BaseTexture>;
  87599. /**
  87600. * An event triggered when render targets are about to be rendered
  87601. * Can happen multiple times per frame.
  87602. */
  87603. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87604. /**
  87605. * An event triggered when render targets were rendered.
  87606. * Can happen multiple times per frame.
  87607. */
  87608. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87609. /**
  87610. * An event triggered before calculating deterministic simulation step
  87611. */
  87612. onBeforeStepObservable: Observable<Scene>;
  87613. /**
  87614. * An event triggered after calculating deterministic simulation step
  87615. */
  87616. onAfterStepObservable: Observable<Scene>;
  87617. /**
  87618. * An event triggered when the activeCamera property is updated
  87619. */
  87620. onActiveCameraChanged: Observable<Scene>;
  87621. /**
  87622. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87623. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87624. * 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)
  87625. */
  87626. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87627. /**
  87628. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87629. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87630. * 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)
  87631. */
  87632. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87633. /**
  87634. * This Observable will when a mesh has been imported into the scene.
  87635. */
  87636. onMeshImportedObservable: Observable<AbstractMesh>;
  87637. /** @hidden */
  87638. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  87639. /**
  87640. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87641. */
  87642. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87643. /**
  87644. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87645. */
  87646. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87647. /**
  87648. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87649. */
  87650. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87651. private _onPointerMove;
  87652. private _onPointerDown;
  87653. private _onPointerUp;
  87654. /** Callback called when a pointer move is detected */
  87655. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87656. /** Callback called when a pointer down is detected */
  87657. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87658. /** Callback called when a pointer up is detected */
  87659. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87660. /** Callback called when a pointer pick is detected */
  87661. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87662. /**
  87663. * 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).
  87664. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87665. */
  87666. onPrePointerObservable: Observable<PointerInfoPre>;
  87667. /**
  87668. * Observable event triggered each time an input event is received from the rendering canvas
  87669. */
  87670. onPointerObservable: Observable<PointerInfo>;
  87671. /**
  87672. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87673. */
  87674. readonly unTranslatedPointer: Vector2;
  87675. /** The distance in pixel that you have to move to prevent some events */
  87676. static DragMovementThreshold: number;
  87677. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87678. static LongPressDelay: number;
  87679. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87680. static DoubleClickDelay: number;
  87681. /** If you need to check double click without raising a single click at first click, enable this flag */
  87682. static ExclusiveDoubleClickMode: boolean;
  87683. private _initClickEvent;
  87684. private _initActionManager;
  87685. private _delayedSimpleClick;
  87686. private _delayedSimpleClickTimeout;
  87687. private _previousDelayedSimpleClickTimeout;
  87688. private _meshPickProceed;
  87689. private _previousButtonPressed;
  87690. private _currentPickResult;
  87691. private _previousPickResult;
  87692. private _totalPointersPressed;
  87693. private _doubleClickOccured;
  87694. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87695. cameraToUseForPointers: Nullable<Camera>;
  87696. private _pointerX;
  87697. private _pointerY;
  87698. private _unTranslatedPointerX;
  87699. private _unTranslatedPointerY;
  87700. private _startingPointerPosition;
  87701. private _previousStartingPointerPosition;
  87702. private _startingPointerTime;
  87703. private _previousStartingPointerTime;
  87704. private _pointerCaptures;
  87705. private _timeAccumulator;
  87706. private _currentStepId;
  87707. private _currentInternalStep;
  87708. /** @hidden */
  87709. _mirroredCameraPosition: Nullable<Vector3>;
  87710. /**
  87711. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87712. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87713. */
  87714. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87715. /**
  87716. * Observable event triggered each time an keyboard event is received from the hosting window
  87717. */
  87718. onKeyboardObservable: Observable<KeyboardInfo>;
  87719. private _onKeyDown;
  87720. private _onKeyUp;
  87721. private _onCanvasFocusObserver;
  87722. private _onCanvasBlurObserver;
  87723. private _useRightHandedSystem;
  87724. /**
  87725. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87726. */
  87727. useRightHandedSystem: boolean;
  87728. /**
  87729. * Sets the step Id used by deterministic lock step
  87730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87731. * @param newStepId defines the step Id
  87732. */
  87733. setStepId(newStepId: number): void;
  87734. /**
  87735. * Gets the step Id used by deterministic lock step
  87736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87737. * @returns the step Id
  87738. */
  87739. getStepId(): number;
  87740. /**
  87741. * Gets the internal step used by deterministic lock step
  87742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87743. * @returns the internal step
  87744. */
  87745. getInternalStep(): number;
  87746. private _fogEnabled;
  87747. /**
  87748. * Gets or sets a boolean indicating if fog is enabled on this scene
  87749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87750. * (Default is true)
  87751. */
  87752. fogEnabled: boolean;
  87753. private _fogMode;
  87754. /**
  87755. * Gets or sets the fog mode to use
  87756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87757. * | mode | value |
  87758. * | --- | --- |
  87759. * | FOGMODE_NONE | 0 |
  87760. * | FOGMODE_EXP | 1 |
  87761. * | FOGMODE_EXP2 | 2 |
  87762. * | FOGMODE_LINEAR | 3 |
  87763. */
  87764. fogMode: number;
  87765. /**
  87766. * Gets or sets the fog color to use
  87767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87768. * (Default is Color3(0.2, 0.2, 0.3))
  87769. */
  87770. fogColor: Color3;
  87771. /**
  87772. * Gets or sets the fog density to use
  87773. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87774. * (Default is 0.1)
  87775. */
  87776. fogDensity: number;
  87777. /**
  87778. * Gets or sets the fog start distance to use
  87779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87780. * (Default is 0)
  87781. */
  87782. fogStart: number;
  87783. /**
  87784. * Gets or sets the fog end distance to use
  87785. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87786. * (Default is 1000)
  87787. */
  87788. fogEnd: number;
  87789. private _shadowsEnabled;
  87790. /**
  87791. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87792. */
  87793. shadowsEnabled: boolean;
  87794. private _lightsEnabled;
  87795. /**
  87796. * Gets or sets a boolean indicating if lights are enabled on this scene
  87797. */
  87798. lightsEnabled: boolean;
  87799. /** All of the active cameras added to this scene. */
  87800. activeCameras: Camera[];
  87801. private _activeCamera;
  87802. /** Gets or sets the current active camera */
  87803. activeCamera: Nullable<Camera>;
  87804. private _defaultMaterial;
  87805. /** The default material used on meshes when no material is affected */
  87806. /** The default material used on meshes when no material is affected */
  87807. defaultMaterial: Material;
  87808. private _texturesEnabled;
  87809. /**
  87810. * Gets or sets a boolean indicating if textures are enabled on this scene
  87811. */
  87812. texturesEnabled: boolean;
  87813. /**
  87814. * Gets or sets a boolean indicating if particles are enabled on this scene
  87815. */
  87816. particlesEnabled: boolean;
  87817. /**
  87818. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87819. */
  87820. spritesEnabled: boolean;
  87821. private _skeletonsEnabled;
  87822. /**
  87823. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87824. */
  87825. skeletonsEnabled: boolean;
  87826. /**
  87827. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87828. */
  87829. lensFlaresEnabled: boolean;
  87830. /**
  87831. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87832. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87833. */
  87834. collisionsEnabled: boolean;
  87835. private _collisionCoordinator;
  87836. /** @hidden */
  87837. readonly collisionCoordinator: ICollisionCoordinator;
  87838. /**
  87839. * Defines the gravity applied to this scene (used only for collisions)
  87840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87841. */
  87842. gravity: Vector3;
  87843. /**
  87844. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87845. */
  87846. postProcessesEnabled: boolean;
  87847. /**
  87848. * The list of postprocesses added to the scene
  87849. */
  87850. postProcesses: PostProcess[];
  87851. /**
  87852. * Gets the current postprocess manager
  87853. */
  87854. postProcessManager: PostProcessManager;
  87855. /**
  87856. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87857. */
  87858. renderTargetsEnabled: boolean;
  87859. /**
  87860. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87861. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87862. */
  87863. dumpNextRenderTargets: boolean;
  87864. /**
  87865. * The list of user defined render targets added to the scene
  87866. */
  87867. customRenderTargets: RenderTargetTexture[];
  87868. /**
  87869. * Defines if texture loading must be delayed
  87870. * If true, textures will only be loaded when they need to be rendered
  87871. */
  87872. useDelayedTextureLoading: boolean;
  87873. /**
  87874. * Gets the list of meshes imported to the scene through SceneLoader
  87875. */
  87876. importedMeshesFiles: String[];
  87877. /**
  87878. * Gets or sets a boolean indicating if probes are enabled on this scene
  87879. */
  87880. probesEnabled: boolean;
  87881. /**
  87882. * Gets or sets the current offline provider to use to store scene data
  87883. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87884. */
  87885. offlineProvider: IOfflineProvider;
  87886. /**
  87887. * Gets or sets the action manager associated with the scene
  87888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87889. */
  87890. actionManager: AbstractActionManager;
  87891. private _meshesForIntersections;
  87892. /**
  87893. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87894. */
  87895. proceduralTexturesEnabled: boolean;
  87896. private _engine;
  87897. private _totalVertices;
  87898. /** @hidden */
  87899. _activeIndices: PerfCounter;
  87900. /** @hidden */
  87901. _activeParticles: PerfCounter;
  87902. /** @hidden */
  87903. _activeBones: PerfCounter;
  87904. private _animationRatio;
  87905. /** @hidden */
  87906. _animationTimeLast: number;
  87907. /** @hidden */
  87908. _animationTime: number;
  87909. /**
  87910. * Gets or sets a general scale for animation speed
  87911. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87912. */
  87913. animationTimeScale: number;
  87914. /** @hidden */
  87915. _cachedMaterial: Nullable<Material>;
  87916. /** @hidden */
  87917. _cachedEffect: Nullable<Effect>;
  87918. /** @hidden */
  87919. _cachedVisibility: Nullable<number>;
  87920. private _renderId;
  87921. private _frameId;
  87922. private _executeWhenReadyTimeoutId;
  87923. private _intermediateRendering;
  87924. private _viewUpdateFlag;
  87925. private _projectionUpdateFlag;
  87926. private _alternateViewUpdateFlag;
  87927. private _alternateProjectionUpdateFlag;
  87928. /** @hidden */
  87929. _toBeDisposed: Nullable<IDisposable>[];
  87930. private _activeRequests;
  87931. /** @hidden */
  87932. _pendingData: any[];
  87933. private _isDisposed;
  87934. /**
  87935. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  87936. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  87937. */
  87938. dispatchAllSubMeshesOfActiveMeshes: boolean;
  87939. private _activeMeshes;
  87940. private _processedMaterials;
  87941. private _renderTargets;
  87942. /** @hidden */
  87943. _activeParticleSystems: SmartArray<IParticleSystem>;
  87944. private _activeSkeletons;
  87945. private _softwareSkinnedMeshes;
  87946. private _renderingManager;
  87947. /** @hidden */
  87948. _activeAnimatables: Animatable[];
  87949. private _transformMatrix;
  87950. private _sceneUbo;
  87951. private _alternateSceneUbo;
  87952. private _viewMatrix;
  87953. private _projectionMatrix;
  87954. private _alternateViewMatrix;
  87955. private _alternateProjectionMatrix;
  87956. private _alternateTransformMatrix;
  87957. private _useAlternateCameraConfiguration;
  87958. private _alternateRendering;
  87959. private _wheelEventName;
  87960. /** @hidden */
  87961. _forcedViewPosition: Nullable<Vector3>;
  87962. /** @hidden */
  87963. readonly _isAlternateRenderingEnabled: boolean;
  87964. private _frustumPlanes;
  87965. /**
  87966. * Gets the list of frustum planes (built from the active camera)
  87967. */
  87968. readonly frustumPlanes: Plane[];
  87969. /**
  87970. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  87971. * This is useful if there are more lights that the maximum simulteanous authorized
  87972. */
  87973. requireLightSorting: boolean;
  87974. /** @hidden */
  87975. readonly useMaterialMeshMap: boolean;
  87976. /** @hidden */
  87977. readonly useClonedMeshhMap: boolean;
  87978. private _pointerOverMesh;
  87979. private _pickedDownMesh;
  87980. private _pickedUpMesh;
  87981. private _externalData;
  87982. private _uid;
  87983. /**
  87984. * @hidden
  87985. * Backing store of defined scene components.
  87986. */
  87987. _components: ISceneComponent[];
  87988. /**
  87989. * @hidden
  87990. * Backing store of defined scene components.
  87991. */
  87992. _serializableComponents: ISceneSerializableComponent[];
  87993. /**
  87994. * List of components to register on the next registration step.
  87995. */
  87996. private _transientComponents;
  87997. /**
  87998. * Registers the transient components if needed.
  87999. */
  88000. private _registerTransientComponents;
  88001. /**
  88002. * @hidden
  88003. * Add a component to the scene.
  88004. * Note that the ccomponent could be registered on th next frame if this is called after
  88005. * the register component stage.
  88006. * @param component Defines the component to add to the scene
  88007. */
  88008. _addComponent(component: ISceneComponent): void;
  88009. /**
  88010. * @hidden
  88011. * Gets a component from the scene.
  88012. * @param name defines the name of the component to retrieve
  88013. * @returns the component or null if not present
  88014. */
  88015. _getComponent(name: string): Nullable<ISceneComponent>;
  88016. /**
  88017. * @hidden
  88018. * Defines the actions happening before camera updates.
  88019. */
  88020. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88021. /**
  88022. * @hidden
  88023. * Defines the actions happening before clear the canvas.
  88024. */
  88025. _beforeClearStage: Stage<SimpleStageAction>;
  88026. /**
  88027. * @hidden
  88028. * Defines the actions when collecting render targets for the frame.
  88029. */
  88030. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88031. /**
  88032. * @hidden
  88033. * Defines the actions happening for one camera in the frame.
  88034. */
  88035. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88036. /**
  88037. * @hidden
  88038. * Defines the actions happening during the per mesh ready checks.
  88039. */
  88040. _isReadyForMeshStage: Stage<MeshStageAction>;
  88041. /**
  88042. * @hidden
  88043. * Defines the actions happening before evaluate active mesh checks.
  88044. */
  88045. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88046. /**
  88047. * @hidden
  88048. * Defines the actions happening during the evaluate sub mesh checks.
  88049. */
  88050. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88051. /**
  88052. * @hidden
  88053. * Defines the actions happening during the active mesh stage.
  88054. */
  88055. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88056. /**
  88057. * @hidden
  88058. * Defines the actions happening during the per camera render target step.
  88059. */
  88060. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88061. /**
  88062. * @hidden
  88063. * Defines the actions happening just before the active camera is drawing.
  88064. */
  88065. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88066. /**
  88067. * @hidden
  88068. * Defines the actions happening just before a render target is drawing.
  88069. */
  88070. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88071. /**
  88072. * @hidden
  88073. * Defines the actions happening just before a rendering group is drawing.
  88074. */
  88075. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88076. /**
  88077. * @hidden
  88078. * Defines the actions happening just before a mesh is drawing.
  88079. */
  88080. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88081. /**
  88082. * @hidden
  88083. * Defines the actions happening just after a mesh has been drawn.
  88084. */
  88085. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88086. /**
  88087. * @hidden
  88088. * Defines the actions happening just after a rendering group has been drawn.
  88089. */
  88090. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88091. /**
  88092. * @hidden
  88093. * Defines the actions happening just after the active camera has been drawn.
  88094. */
  88095. _afterCameraDrawStage: Stage<CameraStageAction>;
  88096. /**
  88097. * @hidden
  88098. * Defines the actions happening just after a render target has been drawn.
  88099. */
  88100. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88101. /**
  88102. * @hidden
  88103. * Defines the actions happening just after rendering all cameras and computing intersections.
  88104. */
  88105. _afterRenderStage: Stage<SimpleStageAction>;
  88106. /**
  88107. * @hidden
  88108. * Defines the actions happening when a pointer move event happens.
  88109. */
  88110. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88111. /**
  88112. * @hidden
  88113. * Defines the actions happening when a pointer down event happens.
  88114. */
  88115. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88116. /**
  88117. * @hidden
  88118. * Defines the actions happening when a pointer up event happens.
  88119. */
  88120. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88121. /**
  88122. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88123. */
  88124. private geometriesByUniqueId;
  88125. /**
  88126. * Creates a new Scene
  88127. * @param engine defines the engine to use to render this scene
  88128. * @param options defines the scene options
  88129. */
  88130. constructor(engine: Engine, options?: SceneOptions);
  88131. private _defaultMeshCandidates;
  88132. /**
  88133. * @hidden
  88134. */
  88135. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88136. private _defaultSubMeshCandidates;
  88137. /**
  88138. * @hidden
  88139. */
  88140. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88141. /**
  88142. * Sets the default candidate providers for the scene.
  88143. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88144. * and getCollidingSubMeshCandidates to their default function
  88145. */
  88146. setDefaultCandidateProviders(): void;
  88147. /**
  88148. * Gets the mesh that is currently under the pointer
  88149. */
  88150. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88151. /**
  88152. * Gets or sets the current on-screen X position of the pointer
  88153. */
  88154. pointerX: number;
  88155. /**
  88156. * Gets or sets the current on-screen Y position of the pointer
  88157. */
  88158. pointerY: number;
  88159. /**
  88160. * Gets the cached material (ie. the latest rendered one)
  88161. * @returns the cached material
  88162. */
  88163. getCachedMaterial(): Nullable<Material>;
  88164. /**
  88165. * Gets the cached effect (ie. the latest rendered one)
  88166. * @returns the cached effect
  88167. */
  88168. getCachedEffect(): Nullable<Effect>;
  88169. /**
  88170. * Gets the cached visibility state (ie. the latest rendered one)
  88171. * @returns the cached visibility state
  88172. */
  88173. getCachedVisibility(): Nullable<number>;
  88174. /**
  88175. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88176. * @param material defines the current material
  88177. * @param effect defines the current effect
  88178. * @param visibility defines the current visibility state
  88179. * @returns true if one parameter is not cached
  88180. */
  88181. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88182. /**
  88183. * Gets the engine associated with the scene
  88184. * @returns an Engine
  88185. */
  88186. getEngine(): Engine;
  88187. /**
  88188. * Gets the total number of vertices rendered per frame
  88189. * @returns the total number of vertices rendered per frame
  88190. */
  88191. getTotalVertices(): number;
  88192. /**
  88193. * Gets the performance counter for total vertices
  88194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88195. */
  88196. readonly totalVerticesPerfCounter: PerfCounter;
  88197. /**
  88198. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88199. * @returns the total number of active indices rendered per frame
  88200. */
  88201. getActiveIndices(): number;
  88202. /**
  88203. * Gets the performance counter for active indices
  88204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88205. */
  88206. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88207. /**
  88208. * Gets the total number of active particles rendered per frame
  88209. * @returns the total number of active particles rendered per frame
  88210. */
  88211. getActiveParticles(): number;
  88212. /**
  88213. * Gets the performance counter for active particles
  88214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88215. */
  88216. readonly activeParticlesPerfCounter: PerfCounter;
  88217. /**
  88218. * Gets the total number of active bones rendered per frame
  88219. * @returns the total number of active bones rendered per frame
  88220. */
  88221. getActiveBones(): number;
  88222. /**
  88223. * Gets the performance counter for active bones
  88224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88225. */
  88226. readonly activeBonesPerfCounter: PerfCounter;
  88227. /**
  88228. * Gets the array of active meshes
  88229. * @returns an array of AbstractMesh
  88230. */
  88231. getActiveMeshes(): SmartArray<AbstractMesh>;
  88232. /**
  88233. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88234. * @returns a number
  88235. */
  88236. getAnimationRatio(): number;
  88237. /**
  88238. * Gets an unique Id for the current render phase
  88239. * @returns a number
  88240. */
  88241. getRenderId(): number;
  88242. /**
  88243. * Gets an unique Id for the current frame
  88244. * @returns a number
  88245. */
  88246. getFrameId(): number;
  88247. /** Call this function if you want to manually increment the render Id*/
  88248. incrementRenderId(): void;
  88249. private _updatePointerPosition;
  88250. private _createUbo;
  88251. private _createAlternateUbo;
  88252. private _setRayOnPointerInfo;
  88253. /**
  88254. * Use this method to simulate a pointer move on a mesh
  88255. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88256. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88257. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88258. * @returns the current scene
  88259. */
  88260. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88261. private _processPointerMove;
  88262. private _checkPrePointerObservable;
  88263. /**
  88264. * Use this method to simulate a pointer down on a mesh
  88265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88268. * @returns the current scene
  88269. */
  88270. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88271. private _processPointerDown;
  88272. /**
  88273. * Use this method to simulate a pointer up on a mesh
  88274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88277. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88278. * @returns the current scene
  88279. */
  88280. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88281. private _processPointerUp;
  88282. /**
  88283. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88284. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88285. * @returns true if the pointer was captured
  88286. */
  88287. isPointerCaptured(pointerId?: number): boolean;
  88288. /** @hidden */
  88289. _isPointerSwiping(): boolean;
  88290. /**
  88291. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88292. * @param attachUp defines if you want to attach events to pointerup
  88293. * @param attachDown defines if you want to attach events to pointerdown
  88294. * @param attachMove defines if you want to attach events to pointermove
  88295. */
  88296. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88297. /** Detaches all event handlers*/
  88298. detachControl(): void;
  88299. /**
  88300. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88301. * Delay loaded resources are not taking in account
  88302. * @return true if all required resources are ready
  88303. */
  88304. isReady(): boolean;
  88305. /** Resets all cached information relative to material (including effect and visibility) */
  88306. resetCachedMaterial(): void;
  88307. /**
  88308. * Registers a function to be called before every frame render
  88309. * @param func defines the function to register
  88310. */
  88311. registerBeforeRender(func: () => void): void;
  88312. /**
  88313. * Unregisters a function called before every frame render
  88314. * @param func defines the function to unregister
  88315. */
  88316. unregisterBeforeRender(func: () => void): void;
  88317. /**
  88318. * Registers a function to be called after every frame render
  88319. * @param func defines the function to register
  88320. */
  88321. registerAfterRender(func: () => void): void;
  88322. /**
  88323. * Unregisters a function called after every frame render
  88324. * @param func defines the function to unregister
  88325. */
  88326. unregisterAfterRender(func: () => void): void;
  88327. private _executeOnceBeforeRender;
  88328. /**
  88329. * The provided function will run before render once and will be disposed afterwards.
  88330. * A timeout delay can be provided so that the function will be executed in N ms.
  88331. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88332. * @param func The function to be executed.
  88333. * @param timeout optional delay in ms
  88334. */
  88335. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88336. /** @hidden */
  88337. _addPendingData(data: any): void;
  88338. /** @hidden */
  88339. _removePendingData(data: any): void;
  88340. /**
  88341. * Returns the number of items waiting to be loaded
  88342. * @returns the number of items waiting to be loaded
  88343. */
  88344. getWaitingItemsCount(): number;
  88345. /**
  88346. * Returns a boolean indicating if the scene is still loading data
  88347. */
  88348. readonly isLoading: boolean;
  88349. /**
  88350. * Registers a function to be executed when the scene is ready
  88351. * @param {Function} func - the function to be executed
  88352. */
  88353. executeWhenReady(func: () => void): void;
  88354. /**
  88355. * Returns a promise that resolves when the scene is ready
  88356. * @returns A promise that resolves when the scene is ready
  88357. */
  88358. whenReadyAsync(): Promise<void>;
  88359. /** @hidden */
  88360. _checkIsReady(): void;
  88361. /**
  88362. * Gets all animatable attached to the scene
  88363. */
  88364. readonly animatables: Animatable[];
  88365. /**
  88366. * Resets the last animation time frame.
  88367. * Useful to override when animations start running when loading a scene for the first time.
  88368. */
  88369. resetLastAnimationTimeFrame(): void;
  88370. /** @hidden */
  88371. _switchToAlternateCameraConfiguration(active: boolean): void;
  88372. /**
  88373. * Gets the current view matrix
  88374. * @returns a Matrix
  88375. */
  88376. getViewMatrix(): Matrix;
  88377. /**
  88378. * Gets the current projection matrix
  88379. * @returns a Matrix
  88380. */
  88381. getProjectionMatrix(): Matrix;
  88382. /**
  88383. * Gets the current transform matrix
  88384. * @returns a Matrix made of View * Projection
  88385. */
  88386. getTransformMatrix(): Matrix;
  88387. /**
  88388. * Sets the current transform matrix
  88389. * @param view defines the View matrix to use
  88390. * @param projection defines the Projection matrix to use
  88391. */
  88392. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88393. /** @hidden */
  88394. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88395. /**
  88396. * Gets the uniform buffer used to store scene data
  88397. * @returns a UniformBuffer
  88398. */
  88399. getSceneUniformBuffer(): UniformBuffer;
  88400. /**
  88401. * Gets an unique (relatively to the current scene) Id
  88402. * @returns an unique number for the scene
  88403. */
  88404. getUniqueId(): number;
  88405. /**
  88406. * Add a mesh to the list of scene's meshes
  88407. * @param newMesh defines the mesh to add
  88408. * @param recursive if all child meshes should also be added to the scene
  88409. */
  88410. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88411. /**
  88412. * Remove a mesh for the list of scene's meshes
  88413. * @param toRemove defines the mesh to remove
  88414. * @param recursive if all child meshes should also be removed from the scene
  88415. * @returns the index where the mesh was in the mesh list
  88416. */
  88417. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88418. /**
  88419. * Add a transform node to the list of scene's transform nodes
  88420. * @param newTransformNode defines the transform node to add
  88421. */
  88422. addTransformNode(newTransformNode: TransformNode): void;
  88423. /**
  88424. * Remove a transform node for the list of scene's transform nodes
  88425. * @param toRemove defines the transform node to remove
  88426. * @returns the index where the transform node was in the transform node list
  88427. */
  88428. removeTransformNode(toRemove: TransformNode): number;
  88429. /**
  88430. * Remove a skeleton for the list of scene's skeletons
  88431. * @param toRemove defines the skeleton to remove
  88432. * @returns the index where the skeleton was in the skeleton list
  88433. */
  88434. removeSkeleton(toRemove: Skeleton): number;
  88435. /**
  88436. * Remove a morph target for the list of scene's morph targets
  88437. * @param toRemove defines the morph target to remove
  88438. * @returns the index where the morph target was in the morph target list
  88439. */
  88440. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88441. /**
  88442. * Remove a light for the list of scene's lights
  88443. * @param toRemove defines the light to remove
  88444. * @returns the index where the light was in the light list
  88445. */
  88446. removeLight(toRemove: Light): number;
  88447. /**
  88448. * Remove a camera for the list of scene's cameras
  88449. * @param toRemove defines the camera to remove
  88450. * @returns the index where the camera was in the camera list
  88451. */
  88452. removeCamera(toRemove: Camera): number;
  88453. /**
  88454. * Remove a particle system for the list of scene's particle systems
  88455. * @param toRemove defines the particle system to remove
  88456. * @returns the index where the particle system was in the particle system list
  88457. */
  88458. removeParticleSystem(toRemove: IParticleSystem): number;
  88459. /**
  88460. * Remove a animation for the list of scene's animations
  88461. * @param toRemove defines the animation to remove
  88462. * @returns the index where the animation was in the animation list
  88463. */
  88464. removeAnimation(toRemove: Animation): number;
  88465. /**
  88466. * Removes the given animation group from this scene.
  88467. * @param toRemove The animation group to remove
  88468. * @returns The index of the removed animation group
  88469. */
  88470. removeAnimationGroup(toRemove: AnimationGroup): number;
  88471. /**
  88472. * Removes the given multi-material from this scene.
  88473. * @param toRemove The multi-material to remove
  88474. * @returns The index of the removed multi-material
  88475. */
  88476. removeMultiMaterial(toRemove: MultiMaterial): number;
  88477. /**
  88478. * Removes the given material from this scene.
  88479. * @param toRemove The material to remove
  88480. * @returns The index of the removed material
  88481. */
  88482. removeMaterial(toRemove: Material): number;
  88483. /**
  88484. * Removes the given action manager from this scene.
  88485. * @param toRemove The action manager to remove
  88486. * @returns The index of the removed action manager
  88487. */
  88488. removeActionManager(toRemove: AbstractActionManager): number;
  88489. /**
  88490. * Removes the given texture from this scene.
  88491. * @param toRemove The texture to remove
  88492. * @returns The index of the removed texture
  88493. */
  88494. removeTexture(toRemove: BaseTexture): number;
  88495. /**
  88496. * Adds the given light to this scene
  88497. * @param newLight The light to add
  88498. */
  88499. addLight(newLight: Light): void;
  88500. /**
  88501. * Sorts the list list based on light priorities
  88502. */
  88503. sortLightsByPriority(): void;
  88504. /**
  88505. * Adds the given camera to this scene
  88506. * @param newCamera The camera to add
  88507. */
  88508. addCamera(newCamera: Camera): void;
  88509. /**
  88510. * Adds the given skeleton to this scene
  88511. * @param newSkeleton The skeleton to add
  88512. */
  88513. addSkeleton(newSkeleton: Skeleton): void;
  88514. /**
  88515. * Adds the given particle system to this scene
  88516. * @param newParticleSystem The particle system to add
  88517. */
  88518. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88519. /**
  88520. * Adds the given animation to this scene
  88521. * @param newAnimation The animation to add
  88522. */
  88523. addAnimation(newAnimation: Animation): void;
  88524. /**
  88525. * Adds the given animation group to this scene.
  88526. * @param newAnimationGroup The animation group to add
  88527. */
  88528. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88529. /**
  88530. * Adds the given multi-material to this scene
  88531. * @param newMultiMaterial The multi-material to add
  88532. */
  88533. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88534. /**
  88535. * Adds the given material to this scene
  88536. * @param newMaterial The material to add
  88537. */
  88538. addMaterial(newMaterial: Material): void;
  88539. /**
  88540. * Adds the given morph target to this scene
  88541. * @param newMorphTargetManager The morph target to add
  88542. */
  88543. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88544. /**
  88545. * Adds the given geometry to this scene
  88546. * @param newGeometry The geometry to add
  88547. */
  88548. addGeometry(newGeometry: Geometry): void;
  88549. /**
  88550. * Adds the given action manager to this scene
  88551. * @param newActionManager The action manager to add
  88552. */
  88553. addActionManager(newActionManager: AbstractActionManager): void;
  88554. /**
  88555. * Adds the given texture to this scene.
  88556. * @param newTexture The texture to add
  88557. */
  88558. addTexture(newTexture: BaseTexture): void;
  88559. /**
  88560. * Switch active camera
  88561. * @param newCamera defines the new active camera
  88562. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88563. */
  88564. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88565. /**
  88566. * sets the active camera of the scene using its ID
  88567. * @param id defines the camera's ID
  88568. * @return the new active camera or null if none found.
  88569. */
  88570. setActiveCameraByID(id: string): Nullable<Camera>;
  88571. /**
  88572. * sets the active camera of the scene using its name
  88573. * @param name defines the camera's name
  88574. * @returns the new active camera or null if none found.
  88575. */
  88576. setActiveCameraByName(name: string): Nullable<Camera>;
  88577. /**
  88578. * get an animation group using its name
  88579. * @param name defines the material's name
  88580. * @return the animation group or null if none found.
  88581. */
  88582. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88583. /**
  88584. * get a material using its id
  88585. * @param id defines the material's ID
  88586. * @return the material or null if none found.
  88587. */
  88588. getMaterialByID(id: string): Nullable<Material>;
  88589. /**
  88590. * Gets a material using its name
  88591. * @param name defines the material's name
  88592. * @return the material or null if none found.
  88593. */
  88594. getMaterialByName(name: string): Nullable<Material>;
  88595. /**
  88596. * Gets a camera using its id
  88597. * @param id defines the id to look for
  88598. * @returns the camera or null if not found
  88599. */
  88600. getCameraByID(id: string): Nullable<Camera>;
  88601. /**
  88602. * Gets a camera using its unique id
  88603. * @param uniqueId defines the unique id to look for
  88604. * @returns the camera or null if not found
  88605. */
  88606. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88607. /**
  88608. * Gets a camera using its name
  88609. * @param name defines the camera's name
  88610. * @return the camera or null if none found.
  88611. */
  88612. getCameraByName(name: string): Nullable<Camera>;
  88613. /**
  88614. * Gets a bone using its id
  88615. * @param id defines the bone's id
  88616. * @return the bone or null if not found
  88617. */
  88618. getBoneByID(id: string): Nullable<Bone>;
  88619. /**
  88620. * Gets a bone using its id
  88621. * @param name defines the bone's name
  88622. * @return the bone or null if not found
  88623. */
  88624. getBoneByName(name: string): Nullable<Bone>;
  88625. /**
  88626. * Gets a light node using its name
  88627. * @param name defines the the light's name
  88628. * @return the light or null if none found.
  88629. */
  88630. getLightByName(name: string): Nullable<Light>;
  88631. /**
  88632. * Gets a light node using its id
  88633. * @param id defines the light's id
  88634. * @return the light or null if none found.
  88635. */
  88636. getLightByID(id: string): Nullable<Light>;
  88637. /**
  88638. * Gets a light node using its scene-generated unique ID
  88639. * @param uniqueId defines the light's unique id
  88640. * @return the light or null if none found.
  88641. */
  88642. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88643. /**
  88644. * Gets a particle system by id
  88645. * @param id defines the particle system id
  88646. * @return the corresponding system or null if none found
  88647. */
  88648. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88649. /**
  88650. * Gets a geometry using its ID
  88651. * @param id defines the geometry's id
  88652. * @return the geometry or null if none found.
  88653. */
  88654. getGeometryByID(id: string): Nullable<Geometry>;
  88655. private _getGeometryByUniqueID;
  88656. /**
  88657. * Add a new geometry to this scene
  88658. * @param geometry defines the geometry to be added to the scene.
  88659. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88660. * @return a boolean defining if the geometry was added or not
  88661. */
  88662. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88663. /**
  88664. * Removes an existing geometry
  88665. * @param geometry defines the geometry to be removed from the scene
  88666. * @return a boolean defining if the geometry was removed or not
  88667. */
  88668. removeGeometry(geometry: Geometry): boolean;
  88669. /**
  88670. * Gets the list of geometries attached to the scene
  88671. * @returns an array of Geometry
  88672. */
  88673. getGeometries(): Geometry[];
  88674. /**
  88675. * Gets the first added mesh found of a given ID
  88676. * @param id defines the id to search for
  88677. * @return the mesh found or null if not found at all
  88678. */
  88679. getMeshByID(id: string): Nullable<AbstractMesh>;
  88680. /**
  88681. * Gets a list of meshes using their id
  88682. * @param id defines the id to search for
  88683. * @returns a list of meshes
  88684. */
  88685. getMeshesByID(id: string): Array<AbstractMesh>;
  88686. /**
  88687. * Gets the first added transform node found of a given ID
  88688. * @param id defines the id to search for
  88689. * @return the found transform node or null if not found at all.
  88690. */
  88691. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88692. /**
  88693. * Gets a list of transform nodes using their id
  88694. * @param id defines the id to search for
  88695. * @returns a list of transform nodes
  88696. */
  88697. getTransformNodesByID(id: string): Array<TransformNode>;
  88698. /**
  88699. * Gets a mesh with its auto-generated unique id
  88700. * @param uniqueId defines the unique id to search for
  88701. * @return the found mesh or null if not found at all.
  88702. */
  88703. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88704. /**
  88705. * Gets a the last added mesh using a given id
  88706. * @param id defines the id to search for
  88707. * @return the found mesh or null if not found at all.
  88708. */
  88709. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88710. /**
  88711. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88712. * @param id defines the id to search for
  88713. * @return the found node or null if not found at all
  88714. */
  88715. getLastEntryByID(id: string): Nullable<Node>;
  88716. /**
  88717. * Gets a node (Mesh, Camera, Light) using a given id
  88718. * @param id defines the id to search for
  88719. * @return the found node or null if not found at all
  88720. */
  88721. getNodeByID(id: string): Nullable<Node>;
  88722. /**
  88723. * Gets a node (Mesh, Camera, Light) using a given name
  88724. * @param name defines the name to search for
  88725. * @return the found node or null if not found at all.
  88726. */
  88727. getNodeByName(name: string): Nullable<Node>;
  88728. /**
  88729. * Gets a mesh using a given name
  88730. * @param name defines the name to search for
  88731. * @return the found mesh or null if not found at all.
  88732. */
  88733. getMeshByName(name: string): Nullable<AbstractMesh>;
  88734. /**
  88735. * Gets a transform node using a given name
  88736. * @param name defines the name to search for
  88737. * @return the found transform node or null if not found at all.
  88738. */
  88739. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88740. /**
  88741. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88742. * @param id defines the id to search for
  88743. * @return the found skeleton or null if not found at all.
  88744. */
  88745. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88746. /**
  88747. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88748. * @param id defines the id to search for
  88749. * @return the found skeleton or null if not found at all.
  88750. */
  88751. getSkeletonById(id: string): Nullable<Skeleton>;
  88752. /**
  88753. * Gets a skeleton using a given name
  88754. * @param name defines the name to search for
  88755. * @return the found skeleton or null if not found at all.
  88756. */
  88757. getSkeletonByName(name: string): Nullable<Skeleton>;
  88758. /**
  88759. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88760. * @param id defines the id to search for
  88761. * @return the found morph target manager or null if not found at all.
  88762. */
  88763. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88764. /**
  88765. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88766. * @param id defines the id to search for
  88767. * @return the found morph target or null if not found at all.
  88768. */
  88769. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88770. /**
  88771. * Gets a boolean indicating if the given mesh is active
  88772. * @param mesh defines the mesh to look for
  88773. * @returns true if the mesh is in the active list
  88774. */
  88775. isActiveMesh(mesh: AbstractMesh): boolean;
  88776. /**
  88777. * Return a unique id as a string which can serve as an identifier for the scene
  88778. */
  88779. readonly uid: string;
  88780. /**
  88781. * Add an externaly attached data from its key.
  88782. * This method call will fail and return false, if such key already exists.
  88783. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88784. * @param key the unique key that identifies the data
  88785. * @param data the data object to associate to the key for this Engine instance
  88786. * @return true if no such key were already present and the data was added successfully, false otherwise
  88787. */
  88788. addExternalData<T>(key: string, data: T): boolean;
  88789. /**
  88790. * Get an externaly attached data from its key
  88791. * @param key the unique key that identifies the data
  88792. * @return the associated data, if present (can be null), or undefined if not present
  88793. */
  88794. getExternalData<T>(key: string): Nullable<T>;
  88795. /**
  88796. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88797. * @param key the unique key that identifies the data
  88798. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88799. * @return the associated data, can be null if the factory returned null.
  88800. */
  88801. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88802. /**
  88803. * Remove an externaly attached data from the Engine instance
  88804. * @param key the unique key that identifies the data
  88805. * @return true if the data was successfully removed, false if it doesn't exist
  88806. */
  88807. removeExternalData(key: string): boolean;
  88808. private _evaluateSubMesh;
  88809. /**
  88810. * Clear the processed materials smart array preventing retention point in material dispose.
  88811. */
  88812. freeProcessedMaterials(): void;
  88813. private _preventFreeActiveMeshesAndRenderingGroups;
  88814. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88815. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88816. * when disposing several meshes in a row or a hierarchy of meshes.
  88817. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88818. */
  88819. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88820. /**
  88821. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88822. */
  88823. freeActiveMeshes(): void;
  88824. /**
  88825. * Clear the info related to rendering groups preventing retention points during dispose.
  88826. */
  88827. freeRenderingGroups(): void;
  88828. /** @hidden */
  88829. _isInIntermediateRendering(): boolean;
  88830. /**
  88831. * Lambda returning the list of potentially active meshes.
  88832. */
  88833. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88834. /**
  88835. * Lambda returning the list of potentially active sub meshes.
  88836. */
  88837. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88838. /**
  88839. * Lambda returning the list of potentially intersecting sub meshes.
  88840. */
  88841. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88842. /**
  88843. * Lambda returning the list of potentially colliding sub meshes.
  88844. */
  88845. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88846. private _activeMeshesFrozen;
  88847. /**
  88848. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88849. * @returns the current scene
  88850. */
  88851. freezeActiveMeshes(): Scene;
  88852. /**
  88853. * Use this function to restart evaluating active meshes on every frame
  88854. * @returns the current scene
  88855. */
  88856. unfreezeActiveMeshes(): Scene;
  88857. private _evaluateActiveMeshes;
  88858. private _activeMesh;
  88859. /**
  88860. * Update the transform matrix to update from the current active camera
  88861. * @param force defines a boolean used to force the update even if cache is up to date
  88862. */
  88863. updateTransformMatrix(force?: boolean): void;
  88864. /**
  88865. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  88866. * @param alternateCamera defines the camera to use
  88867. */
  88868. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88869. /** @hidden */
  88870. _allowPostProcessClearColor: boolean;
  88871. private _renderForCamera;
  88872. private _processSubCameras;
  88873. private _checkIntersections;
  88874. /** @hidden */
  88875. _advancePhysicsEngineStep(step: number): void;
  88876. /**
  88877. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88878. */
  88879. getDeterministicFrameTime: () => number;
  88880. /** @hidden */
  88881. _animate(): void;
  88882. /**
  88883. * Render the scene
  88884. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88885. */
  88886. render(updateCameras?: boolean): void;
  88887. /**
  88888. * Freeze all materials
  88889. * A frozen material will not be updatable but should be faster to render
  88890. */
  88891. freezeMaterials(): void;
  88892. /**
  88893. * Unfreeze all materials
  88894. * A frozen material will not be updatable but should be faster to render
  88895. */
  88896. unfreezeMaterials(): void;
  88897. /**
  88898. * Releases all held ressources
  88899. */
  88900. dispose(): void;
  88901. /**
  88902. * Gets if the scene is already disposed
  88903. */
  88904. readonly isDisposed: boolean;
  88905. /**
  88906. * Call this function to reduce memory footprint of the scene.
  88907. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88908. */
  88909. clearCachedVertexData(): void;
  88910. /**
  88911. * This function will remove the local cached buffer data from texture.
  88912. * It will save memory but will prevent the texture from being rebuilt
  88913. */
  88914. cleanCachedTextureBuffer(): void;
  88915. /**
  88916. * Get the world extend vectors with an optional filter
  88917. *
  88918. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88919. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88920. */
  88921. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  88922. min: Vector3;
  88923. max: Vector3;
  88924. };
  88925. /**
  88926. * Creates a ray that can be used to pick in the scene
  88927. * @param x defines the x coordinate of the origin (on-screen)
  88928. * @param y defines the y coordinate of the origin (on-screen)
  88929. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88930. * @param camera defines the camera to use for the picking
  88931. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88932. * @returns a Ray
  88933. */
  88934. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  88935. /**
  88936. * Creates a ray that can be used to pick in the scene
  88937. * @param x defines the x coordinate of the origin (on-screen)
  88938. * @param y defines the y coordinate of the origin (on-screen)
  88939. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88940. * @param result defines the ray where to store the picking ray
  88941. * @param camera defines the camera to use for the picking
  88942. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88943. * @returns the current scene
  88944. */
  88945. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  88946. /**
  88947. * Creates a ray that can be used to pick in the scene
  88948. * @param x defines the x coordinate of the origin (on-screen)
  88949. * @param y defines the y coordinate of the origin (on-screen)
  88950. * @param camera defines the camera to use for the picking
  88951. * @returns a Ray
  88952. */
  88953. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  88954. /**
  88955. * Creates a ray that can be used to pick in the scene
  88956. * @param x defines the x coordinate of the origin (on-screen)
  88957. * @param y defines the y coordinate of the origin (on-screen)
  88958. * @param result defines the ray where to store the picking ray
  88959. * @param camera defines the camera to use for the picking
  88960. * @returns the current scene
  88961. */
  88962. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  88963. /** Launch a ray to try to pick a mesh in the scene
  88964. * @param x position on screen
  88965. * @param y position on screen
  88966. * @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
  88967. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  88968. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88969. * @returns a PickingInfo
  88970. */
  88971. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  88972. /** Use the given ray to pick a mesh in the scene
  88973. * @param ray The ray to use to pick meshes
  88974. * @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
  88975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  88976. * @returns a PickingInfo
  88977. */
  88978. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88979. /**
  88980. * Launch a ray to try to pick a mesh in the scene
  88981. * @param x X position on screen
  88982. * @param y Y position on screen
  88983. * @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
  88984. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88985. * @returns an array of PickingInfo
  88986. */
  88987. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88988. /**
  88989. * Launch a ray to try to pick a mesh in the scene
  88990. * @param ray Ray to use
  88991. * @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
  88992. * @returns an array of PickingInfo
  88993. */
  88994. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  88995. /**
  88996. * Force the value of meshUnderPointer
  88997. * @param mesh defines the mesh to use
  88998. */
  88999. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89000. /**
  89001. * Gets the mesh under the pointer
  89002. * @returns a Mesh or null if no mesh is under the pointer
  89003. */
  89004. getPointerOverMesh(): Nullable<AbstractMesh>;
  89005. /** @hidden */
  89006. _rebuildGeometries(): void;
  89007. /** @hidden */
  89008. _rebuildTextures(): void;
  89009. private _getByTags;
  89010. /**
  89011. * Get a list of meshes by tags
  89012. * @param tagsQuery defines the tags query to use
  89013. * @param forEach defines a predicate used to filter results
  89014. * @returns an array of Mesh
  89015. */
  89016. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89017. /**
  89018. * Get a list of cameras by tags
  89019. * @param tagsQuery defines the tags query to use
  89020. * @param forEach defines a predicate used to filter results
  89021. * @returns an array of Camera
  89022. */
  89023. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89024. /**
  89025. * Get a list of lights by tags
  89026. * @param tagsQuery defines the tags query to use
  89027. * @param forEach defines a predicate used to filter results
  89028. * @returns an array of Light
  89029. */
  89030. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89031. /**
  89032. * Get a list of materials by tags
  89033. * @param tagsQuery defines the tags query to use
  89034. * @param forEach defines a predicate used to filter results
  89035. * @returns an array of Material
  89036. */
  89037. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89038. /**
  89039. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89040. * This allowed control for front to back rendering or reversly depending of the special needs.
  89041. *
  89042. * @param renderingGroupId The rendering group id corresponding to its index
  89043. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89044. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89045. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89046. */
  89047. 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;
  89048. /**
  89049. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89050. *
  89051. * @param renderingGroupId The rendering group id corresponding to its index
  89052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89053. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89054. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89055. */
  89056. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89057. /**
  89058. * Gets the current auto clear configuration for one rendering group of the rendering
  89059. * manager.
  89060. * @param index the rendering group index to get the information for
  89061. * @returns The auto clear setup for the requested rendering group
  89062. */
  89063. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89064. private _blockMaterialDirtyMechanism;
  89065. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89066. blockMaterialDirtyMechanism: boolean;
  89067. /**
  89068. * Will flag all materials as dirty to trigger new shader compilation
  89069. * @param flag defines the flag used to specify which material part must be marked as dirty
  89070. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89071. */
  89072. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89073. /** @hidden */
  89074. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  89075. /** @hidden */
  89076. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89077. }
  89078. }
  89079. declare module BABYLON {
  89080. /**
  89081. * Set of assets to keep when moving a scene into an asset container.
  89082. */
  89083. export class KeepAssets extends AbstractScene {
  89084. }
  89085. /**
  89086. * Container with a set of assets that can be added or removed from a scene.
  89087. */
  89088. export class AssetContainer extends AbstractScene {
  89089. /**
  89090. * The scene the AssetContainer belongs to.
  89091. */
  89092. scene: Scene;
  89093. /**
  89094. * Instantiates an AssetContainer.
  89095. * @param scene The scene the AssetContainer belongs to.
  89096. */
  89097. constructor(scene: Scene);
  89098. /**
  89099. * Adds all the assets from the container to the scene.
  89100. */
  89101. addAllToScene(): void;
  89102. /**
  89103. * Removes all the assets in the container from the scene
  89104. */
  89105. removeAllFromScene(): void;
  89106. /**
  89107. * Disposes all the assets in the container
  89108. */
  89109. dispose(): void;
  89110. private _moveAssets;
  89111. /**
  89112. * Removes all the assets contained in the scene and adds them to the container.
  89113. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89114. */
  89115. moveAllFromScene(keepAssets?: KeepAssets): void;
  89116. /**
  89117. * 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.
  89118. * @returns the root mesh
  89119. */
  89120. createRootMesh(): Mesh;
  89121. }
  89122. }
  89123. declare module BABYLON {
  89124. /**
  89125. * Defines how the parser contract is defined.
  89126. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89127. */
  89128. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89129. /**
  89130. * Defines how the individual parser contract is defined.
  89131. * These parser can parse an individual asset
  89132. */
  89133. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89134. /**
  89135. * Base class of the scene acting as a container for the different elements composing a scene.
  89136. * This class is dynamically extended by the different components of the scene increasing
  89137. * flexibility and reducing coupling
  89138. */
  89139. export abstract class AbstractScene {
  89140. /**
  89141. * Stores the list of available parsers in the application.
  89142. */
  89143. private static _BabylonFileParsers;
  89144. /**
  89145. * Stores the list of available individual parsers in the application.
  89146. */
  89147. private static _IndividualBabylonFileParsers;
  89148. /**
  89149. * Adds a parser in the list of available ones
  89150. * @param name Defines the name of the parser
  89151. * @param parser Defines the parser to add
  89152. */
  89153. static AddParser(name: string, parser: BabylonFileParser): void;
  89154. /**
  89155. * Gets a general parser from the list of avaialble ones
  89156. * @param name Defines the name of the parser
  89157. * @returns the requested parser or null
  89158. */
  89159. static GetParser(name: string): Nullable<BabylonFileParser>;
  89160. /**
  89161. * Adds n individual parser in the list of available ones
  89162. * @param name Defines the name of the parser
  89163. * @param parser Defines the parser to add
  89164. */
  89165. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89166. /**
  89167. * Gets an individual parser from the list of avaialble ones
  89168. * @param name Defines the name of the parser
  89169. * @returns the requested parser or null
  89170. */
  89171. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89172. /**
  89173. * Parser json data and populate both a scene and its associated container object
  89174. * @param jsonData Defines the data to parse
  89175. * @param scene Defines the scene to parse the data for
  89176. * @param container Defines the container attached to the parsing sequence
  89177. * @param rootUrl Defines the root url of the data
  89178. */
  89179. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89180. /**
  89181. * Gets the list of root nodes (ie. nodes with no parent)
  89182. */
  89183. rootNodes: Node[];
  89184. /** All of the cameras added to this scene
  89185. * @see http://doc.babylonjs.com/babylon101/cameras
  89186. */
  89187. cameras: Camera[];
  89188. /**
  89189. * All of the lights added to this scene
  89190. * @see http://doc.babylonjs.com/babylon101/lights
  89191. */
  89192. lights: Light[];
  89193. /**
  89194. * All of the (abstract) meshes added to this scene
  89195. */
  89196. meshes: AbstractMesh[];
  89197. /**
  89198. * The list of skeletons added to the scene
  89199. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89200. */
  89201. skeletons: Skeleton[];
  89202. /**
  89203. * All of the particle systems added to this scene
  89204. * @see http://doc.babylonjs.com/babylon101/particles
  89205. */
  89206. particleSystems: IParticleSystem[];
  89207. /**
  89208. * Gets a list of Animations associated with the scene
  89209. */
  89210. animations: Animation[];
  89211. /**
  89212. * All of the animation groups added to this scene
  89213. * @see http://doc.babylonjs.com/how_to/group
  89214. */
  89215. animationGroups: AnimationGroup[];
  89216. /**
  89217. * All of the multi-materials added to this scene
  89218. * @see http://doc.babylonjs.com/how_to/multi_materials
  89219. */
  89220. multiMaterials: MultiMaterial[];
  89221. /**
  89222. * All of the materials added to this scene
  89223. * In the context of a Scene, it is not supposed to be modified manually.
  89224. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89225. * Note also that the order of the Material wihin the array is not significant and might change.
  89226. * @see http://doc.babylonjs.com/babylon101/materials
  89227. */
  89228. materials: Material[];
  89229. /**
  89230. * The list of morph target managers added to the scene
  89231. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89232. */
  89233. morphTargetManagers: MorphTargetManager[];
  89234. /**
  89235. * The list of geometries used in the scene.
  89236. */
  89237. geometries: Geometry[];
  89238. /**
  89239. * All of the tranform nodes added to this scene
  89240. * In the context of a Scene, it is not supposed to be modified manually.
  89241. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89242. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89243. * @see http://doc.babylonjs.com/how_to/transformnode
  89244. */
  89245. transformNodes: TransformNode[];
  89246. /**
  89247. * ActionManagers available on the scene.
  89248. */
  89249. actionManagers: AbstractActionManager[];
  89250. /**
  89251. * Textures to keep.
  89252. */
  89253. textures: BaseTexture[];
  89254. }
  89255. }
  89256. declare module BABYLON {
  89257. /**
  89258. * Defines a sound that can be played in the application.
  89259. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89261. */
  89262. export class Sound {
  89263. /**
  89264. * The name of the sound in the scene.
  89265. */
  89266. name: string;
  89267. /**
  89268. * Does the sound autoplay once loaded.
  89269. */
  89270. autoplay: boolean;
  89271. /**
  89272. * Does the sound loop after it finishes playing once.
  89273. */
  89274. loop: boolean;
  89275. /**
  89276. * Does the sound use a custom attenuation curve to simulate the falloff
  89277. * happening when the source gets further away from the camera.
  89278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89279. */
  89280. useCustomAttenuation: boolean;
  89281. /**
  89282. * The sound track id this sound belongs to.
  89283. */
  89284. soundTrackId: number;
  89285. /**
  89286. * Is this sound currently played.
  89287. */
  89288. isPlaying: boolean;
  89289. /**
  89290. * Is this sound currently paused.
  89291. */
  89292. isPaused: boolean;
  89293. /**
  89294. * Does this sound enables spatial sound.
  89295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89296. */
  89297. spatialSound: boolean;
  89298. /**
  89299. * Define the reference distance the sound should be heard perfectly.
  89300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89301. */
  89302. refDistance: number;
  89303. /**
  89304. * Define the roll off factor of spatial sounds.
  89305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89306. */
  89307. rolloffFactor: number;
  89308. /**
  89309. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89311. */
  89312. maxDistance: number;
  89313. /**
  89314. * Define the distance attenuation model the sound will follow.
  89315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89316. */
  89317. distanceModel: string;
  89318. /**
  89319. * @hidden
  89320. * Back Compat
  89321. **/
  89322. onended: () => any;
  89323. /**
  89324. * Observable event when the current playing sound finishes.
  89325. */
  89326. onEndedObservable: Observable<Sound>;
  89327. private _panningModel;
  89328. private _playbackRate;
  89329. private _streaming;
  89330. private _startTime;
  89331. private _startOffset;
  89332. private _position;
  89333. /** @hidden */
  89334. _positionInEmitterSpace: boolean;
  89335. private _localDirection;
  89336. private _volume;
  89337. private _isReadyToPlay;
  89338. private _isDirectional;
  89339. private _readyToPlayCallback;
  89340. private _audioBuffer;
  89341. private _soundSource;
  89342. private _streamingSource;
  89343. private _soundPanner;
  89344. private _soundGain;
  89345. private _inputAudioNode;
  89346. private _outputAudioNode;
  89347. private _coneInnerAngle;
  89348. private _coneOuterAngle;
  89349. private _coneOuterGain;
  89350. private _scene;
  89351. private _connectedTransformNode;
  89352. private _customAttenuationFunction;
  89353. private _registerFunc;
  89354. private _isOutputConnected;
  89355. private _htmlAudioElement;
  89356. private _urlType;
  89357. /** @hidden */
  89358. static _SceneComponentInitialization: (scene: Scene) => void;
  89359. /**
  89360. * Create a sound and attach it to a scene
  89361. * @param name Name of your sound
  89362. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89363. * @param scene defines the scene the sound belongs to
  89364. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89365. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89366. */
  89367. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89368. /**
  89369. * Release the sound and its associated resources
  89370. */
  89371. dispose(): void;
  89372. /**
  89373. * Gets if the sounds is ready to be played or not.
  89374. * @returns true if ready, otherwise false
  89375. */
  89376. isReady(): boolean;
  89377. private _soundLoaded;
  89378. /**
  89379. * Sets the data of the sound from an audiobuffer
  89380. * @param audioBuffer The audioBuffer containing the data
  89381. */
  89382. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89383. /**
  89384. * Updates the current sounds options such as maxdistance, loop...
  89385. * @param options A JSON object containing values named as the object properties
  89386. */
  89387. updateOptions(options: any): void;
  89388. private _createSpatialParameters;
  89389. private _updateSpatialParameters;
  89390. /**
  89391. * Switch the panning model to HRTF:
  89392. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89394. */
  89395. switchPanningModelToHRTF(): void;
  89396. /**
  89397. * Switch the panning model to Equal Power:
  89398. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89400. */
  89401. switchPanningModelToEqualPower(): void;
  89402. private _switchPanningModel;
  89403. /**
  89404. * Connect this sound to a sound track audio node like gain...
  89405. * @param soundTrackAudioNode the sound track audio node to connect to
  89406. */
  89407. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89408. /**
  89409. * Transform this sound into a directional source
  89410. * @param coneInnerAngle Size of the inner cone in degree
  89411. * @param coneOuterAngle Size of the outer cone in degree
  89412. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89413. */
  89414. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89415. /**
  89416. * Gets or sets the inner angle for the directional cone.
  89417. */
  89418. /**
  89419. * Gets or sets the inner angle for the directional cone.
  89420. */
  89421. directionalConeInnerAngle: number;
  89422. /**
  89423. * Gets or sets the outer angle for the directional cone.
  89424. */
  89425. /**
  89426. * Gets or sets the outer angle for the directional cone.
  89427. */
  89428. directionalConeOuterAngle: number;
  89429. /**
  89430. * Sets the position of the emitter if spatial sound is enabled
  89431. * @param newPosition Defines the new posisiton
  89432. */
  89433. setPosition(newPosition: Vector3): void;
  89434. /**
  89435. * Sets the local direction of the emitter if spatial sound is enabled
  89436. * @param newLocalDirection Defines the new local direction
  89437. */
  89438. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89439. private _updateDirection;
  89440. /** @hidden */
  89441. updateDistanceFromListener(): void;
  89442. /**
  89443. * Sets a new custom attenuation function for the sound.
  89444. * @param callback Defines the function used for the attenuation
  89445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89446. */
  89447. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89448. /**
  89449. * Play the sound
  89450. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89451. * @param offset (optional) Start the sound setting it at a specific time
  89452. */
  89453. play(time?: number, offset?: number): void;
  89454. private _onended;
  89455. /**
  89456. * Stop the sound
  89457. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89458. */
  89459. stop(time?: number): void;
  89460. /**
  89461. * Put the sound in pause
  89462. */
  89463. pause(): void;
  89464. /**
  89465. * Sets a dedicated volume for this sounds
  89466. * @param newVolume Define the new volume of the sound
  89467. * @param time Define in how long the sound should be at this value
  89468. */
  89469. setVolume(newVolume: number, time?: number): void;
  89470. /**
  89471. * Set the sound play back rate
  89472. * @param newPlaybackRate Define the playback rate the sound should be played at
  89473. */
  89474. setPlaybackRate(newPlaybackRate: number): void;
  89475. /**
  89476. * Gets the volume of the sound.
  89477. * @returns the volume of the sound
  89478. */
  89479. getVolume(): number;
  89480. /**
  89481. * Attach the sound to a dedicated mesh
  89482. * @param transformNode The transform node to connect the sound with
  89483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89484. */
  89485. attachToMesh(transformNode: TransformNode): void;
  89486. /**
  89487. * Detach the sound from the previously attached mesh
  89488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89489. */
  89490. detachFromMesh(): void;
  89491. private _onRegisterAfterWorldMatrixUpdate;
  89492. /**
  89493. * Clone the current sound in the scene.
  89494. * @returns the new sound clone
  89495. */
  89496. clone(): Nullable<Sound>;
  89497. /**
  89498. * Gets the current underlying audio buffer containing the data
  89499. * @returns the audio buffer
  89500. */
  89501. getAudioBuffer(): Nullable<AudioBuffer>;
  89502. /**
  89503. * Serializes the Sound in a JSON representation
  89504. * @returns the JSON representation of the sound
  89505. */
  89506. serialize(): any;
  89507. /**
  89508. * Parse a JSON representation of a sound to innstantiate in a given scene
  89509. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89510. * @param scene Define the scene the new parsed sound should be created in
  89511. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89512. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89513. * @returns the newly parsed sound
  89514. */
  89515. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89516. }
  89517. }
  89518. declare module BABYLON {
  89519. /**
  89520. * This defines an action helpful to play a defined sound on a triggered action.
  89521. */
  89522. export class PlaySoundAction extends Action {
  89523. private _sound;
  89524. /**
  89525. * Instantiate the action
  89526. * @param triggerOptions defines the trigger options
  89527. * @param sound defines the sound to play
  89528. * @param condition defines the trigger related conditions
  89529. */
  89530. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89531. /** @hidden */
  89532. _prepare(): void;
  89533. /**
  89534. * Execute the action and play the sound.
  89535. */
  89536. execute(): void;
  89537. /**
  89538. * Serializes the actions and its related information.
  89539. * @param parent defines the object to serialize in
  89540. * @returns the serialized object
  89541. */
  89542. serialize(parent: any): any;
  89543. }
  89544. /**
  89545. * This defines an action helpful to stop a defined sound on a triggered action.
  89546. */
  89547. export class StopSoundAction extends Action {
  89548. private _sound;
  89549. /**
  89550. * Instantiate the action
  89551. * @param triggerOptions defines the trigger options
  89552. * @param sound defines the sound to stop
  89553. * @param condition defines the trigger related conditions
  89554. */
  89555. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89556. /** @hidden */
  89557. _prepare(): void;
  89558. /**
  89559. * Execute the action and stop the sound.
  89560. */
  89561. execute(): void;
  89562. /**
  89563. * Serializes the actions and its related information.
  89564. * @param parent defines the object to serialize in
  89565. * @returns the serialized object
  89566. */
  89567. serialize(parent: any): any;
  89568. }
  89569. }
  89570. declare module BABYLON {
  89571. /**
  89572. * This defines an action responsible to change the value of a property
  89573. * by interpolating between its current value and the newly set one once triggered.
  89574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89575. */
  89576. export class InterpolateValueAction extends Action {
  89577. /**
  89578. * Defines the path of the property where the value should be interpolated
  89579. */
  89580. propertyPath: string;
  89581. /**
  89582. * Defines the target value at the end of the interpolation.
  89583. */
  89584. value: any;
  89585. /**
  89586. * Defines the time it will take for the property to interpolate to the value.
  89587. */
  89588. duration: number;
  89589. /**
  89590. * Defines if the other scene animations should be stopped when the action has been triggered
  89591. */
  89592. stopOtherAnimations?: boolean;
  89593. /**
  89594. * Defines a callback raised once the interpolation animation has been done.
  89595. */
  89596. onInterpolationDone?: () => void;
  89597. /**
  89598. * Observable triggered once the interpolation animation has been done.
  89599. */
  89600. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89601. private _target;
  89602. private _effectiveTarget;
  89603. private _property;
  89604. /**
  89605. * Instantiate the action
  89606. * @param triggerOptions defines the trigger options
  89607. * @param target defines the object containing the value to interpolate
  89608. * @param propertyPath defines the path to the property in the target object
  89609. * @param value defines the target value at the end of the interpolation
  89610. * @param duration deines the time it will take for the property to interpolate to the value.
  89611. * @param condition defines the trigger related conditions
  89612. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89613. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89614. */
  89615. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89616. /** @hidden */
  89617. _prepare(): void;
  89618. /**
  89619. * Execute the action starts the value interpolation.
  89620. */
  89621. execute(): void;
  89622. /**
  89623. * Serializes the actions and its related information.
  89624. * @param parent defines the object to serialize in
  89625. * @returns the serialized object
  89626. */
  89627. serialize(parent: any): any;
  89628. }
  89629. }
  89630. declare module BABYLON {
  89631. /**
  89632. * Options allowed during the creation of a sound track.
  89633. */
  89634. export interface ISoundTrackOptions {
  89635. /**
  89636. * The volume the sound track should take during creation
  89637. */
  89638. volume?: number;
  89639. /**
  89640. * Define if the sound track is the main sound track of the scene
  89641. */
  89642. mainTrack?: boolean;
  89643. }
  89644. /**
  89645. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89646. * It will be also used in a future release to apply effects on a specific track.
  89647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89648. */
  89649. export class SoundTrack {
  89650. /**
  89651. * The unique identifier of the sound track in the scene.
  89652. */
  89653. id: number;
  89654. /**
  89655. * The list of sounds included in the sound track.
  89656. */
  89657. soundCollection: Array<Sound>;
  89658. private _outputAudioNode;
  89659. private _scene;
  89660. private _isMainTrack;
  89661. private _connectedAnalyser;
  89662. private _options;
  89663. private _isInitialized;
  89664. /**
  89665. * Creates a new sound track.
  89666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89667. * @param scene Define the scene the sound track belongs to
  89668. * @param options
  89669. */
  89670. constructor(scene: Scene, options?: ISoundTrackOptions);
  89671. private _initializeSoundTrackAudioGraph;
  89672. /**
  89673. * Release the sound track and its associated resources
  89674. */
  89675. dispose(): void;
  89676. /**
  89677. * Adds a sound to this sound track
  89678. * @param sound define the cound to add
  89679. * @ignoreNaming
  89680. */
  89681. AddSound(sound: Sound): void;
  89682. /**
  89683. * Removes a sound to this sound track
  89684. * @param sound define the cound to remove
  89685. * @ignoreNaming
  89686. */
  89687. RemoveSound(sound: Sound): void;
  89688. /**
  89689. * Set a global volume for the full sound track.
  89690. * @param newVolume Define the new volume of the sound track
  89691. */
  89692. setVolume(newVolume: number): void;
  89693. /**
  89694. * Switch the panning model to HRTF:
  89695. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89697. */
  89698. switchPanningModelToHRTF(): void;
  89699. /**
  89700. * Switch the panning model to Equal Power:
  89701. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89703. */
  89704. switchPanningModelToEqualPower(): void;
  89705. /**
  89706. * Connect the sound track to an audio analyser allowing some amazing
  89707. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89709. * @param analyser The analyser to connect to the engine
  89710. */
  89711. connectToAnalyser(analyser: Analyser): void;
  89712. }
  89713. }
  89714. declare module BABYLON {
  89715. interface AbstractScene {
  89716. /**
  89717. * The list of sounds used in the scene.
  89718. */
  89719. sounds: Nullable<Array<Sound>>;
  89720. }
  89721. interface Scene {
  89722. /**
  89723. * @hidden
  89724. * Backing field
  89725. */
  89726. _mainSoundTrack: SoundTrack;
  89727. /**
  89728. * The main sound track played by the scene.
  89729. * It cotains your primary collection of sounds.
  89730. */
  89731. mainSoundTrack: SoundTrack;
  89732. /**
  89733. * The list of sound tracks added to the scene
  89734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89735. */
  89736. soundTracks: Nullable<Array<SoundTrack>>;
  89737. /**
  89738. * Gets a sound using a given name
  89739. * @param name defines the name to search for
  89740. * @return the found sound or null if not found at all.
  89741. */
  89742. getSoundByName(name: string): Nullable<Sound>;
  89743. /**
  89744. * Gets or sets if audio support is enabled
  89745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89746. */
  89747. audioEnabled: boolean;
  89748. /**
  89749. * Gets or sets if audio will be output to headphones
  89750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89751. */
  89752. headphone: boolean;
  89753. }
  89754. /**
  89755. * Defines the sound scene component responsible to manage any sounds
  89756. * in a given scene.
  89757. */
  89758. export class AudioSceneComponent implements ISceneSerializableComponent {
  89759. /**
  89760. * The component name helpfull to identify the component in the list of scene components.
  89761. */
  89762. readonly name: string;
  89763. /**
  89764. * The scene the component belongs to.
  89765. */
  89766. scene: Scene;
  89767. private _audioEnabled;
  89768. /**
  89769. * Gets whether audio is enabled or not.
  89770. * Please use related enable/disable method to switch state.
  89771. */
  89772. readonly audioEnabled: boolean;
  89773. private _headphone;
  89774. /**
  89775. * Gets whether audio is outputing to headphone or not.
  89776. * Please use the according Switch methods to change output.
  89777. */
  89778. readonly headphone: boolean;
  89779. /**
  89780. * Creates a new instance of the component for the given scene
  89781. * @param scene Defines the scene to register the component in
  89782. */
  89783. constructor(scene: Scene);
  89784. /**
  89785. * Registers the component in a given scene
  89786. */
  89787. register(): void;
  89788. /**
  89789. * Rebuilds the elements related to this component in case of
  89790. * context lost for instance.
  89791. */
  89792. rebuild(): void;
  89793. /**
  89794. * Serializes the component data to the specified json object
  89795. * @param serializationObject The object to serialize to
  89796. */
  89797. serialize(serializationObject: any): void;
  89798. /**
  89799. * Adds all the element from the container to the scene
  89800. * @param container the container holding the elements
  89801. */
  89802. addFromContainer(container: AbstractScene): void;
  89803. /**
  89804. * Removes all the elements in the container from the scene
  89805. * @param container contains the elements to remove
  89806. */
  89807. removeFromContainer(container: AbstractScene): void;
  89808. /**
  89809. * Disposes the component and the associated ressources.
  89810. */
  89811. dispose(): void;
  89812. /**
  89813. * Disables audio in the associated scene.
  89814. */
  89815. disableAudio(): void;
  89816. /**
  89817. * Enables audio in the associated scene.
  89818. */
  89819. enableAudio(): void;
  89820. /**
  89821. * Switch audio to headphone output.
  89822. */
  89823. switchAudioModeForHeadphones(): void;
  89824. /**
  89825. * Switch audio to normal speakers.
  89826. */
  89827. switchAudioModeForNormalSpeakers(): void;
  89828. private _afterRender;
  89829. }
  89830. }
  89831. declare module BABYLON {
  89832. /**
  89833. * Wraps one or more Sound objects and selects one with random weight for playback.
  89834. */
  89835. export class WeightedSound {
  89836. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89837. loop: boolean;
  89838. private _coneInnerAngle;
  89839. private _coneOuterAngle;
  89840. private _volume;
  89841. /** A Sound is currently playing. */
  89842. isPlaying: boolean;
  89843. /** A Sound is currently paused. */
  89844. isPaused: boolean;
  89845. private _sounds;
  89846. private _weights;
  89847. private _currentIndex?;
  89848. /**
  89849. * Creates a new WeightedSound from the list of sounds given.
  89850. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89851. * @param sounds Array of Sounds that will be selected from.
  89852. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89853. */
  89854. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89855. /**
  89856. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89857. */
  89858. /**
  89859. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89860. */
  89861. directionalConeInnerAngle: number;
  89862. /**
  89863. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89864. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89865. */
  89866. /**
  89867. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89868. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89869. */
  89870. directionalConeOuterAngle: number;
  89871. /**
  89872. * Playback volume.
  89873. */
  89874. /**
  89875. * Playback volume.
  89876. */
  89877. volume: number;
  89878. private _onended;
  89879. /**
  89880. * Suspend playback
  89881. */
  89882. pause(): void;
  89883. /**
  89884. * Stop playback
  89885. */
  89886. stop(): void;
  89887. /**
  89888. * Start playback.
  89889. * @param startOffset Position the clip head at a specific time in seconds.
  89890. */
  89891. play(startOffset?: number): void;
  89892. }
  89893. }
  89894. declare module BABYLON {
  89895. /**
  89896. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89897. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89898. */
  89899. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89900. /**
  89901. * Gets the name of the behavior.
  89902. */
  89903. readonly name: string;
  89904. /**
  89905. * The easing function used by animations
  89906. */
  89907. static EasingFunction: BackEase;
  89908. /**
  89909. * The easing mode used by animations
  89910. */
  89911. static EasingMode: number;
  89912. /**
  89913. * The duration of the animation, in milliseconds
  89914. */
  89915. transitionDuration: number;
  89916. /**
  89917. * Length of the distance animated by the transition when lower radius is reached
  89918. */
  89919. lowerRadiusTransitionRange: number;
  89920. /**
  89921. * Length of the distance animated by the transition when upper radius is reached
  89922. */
  89923. upperRadiusTransitionRange: number;
  89924. private _autoTransitionRange;
  89925. /**
  89926. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89927. */
  89928. /**
  89929. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89930. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  89931. */
  89932. autoTransitionRange: boolean;
  89933. private _attachedCamera;
  89934. private _onAfterCheckInputsObserver;
  89935. private _onMeshTargetChangedObserver;
  89936. /**
  89937. * Initializes the behavior.
  89938. */
  89939. init(): void;
  89940. /**
  89941. * Attaches the behavior to its arc rotate camera.
  89942. * @param camera Defines the camera to attach the behavior to
  89943. */
  89944. attach(camera: ArcRotateCamera): void;
  89945. /**
  89946. * Detaches the behavior from its current arc rotate camera.
  89947. */
  89948. detach(): void;
  89949. private _radiusIsAnimating;
  89950. private _radiusBounceTransition;
  89951. private _animatables;
  89952. private _cachedWheelPrecision;
  89953. /**
  89954. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  89955. * @param radiusLimit The limit to check against.
  89956. * @return Bool to indicate if at limit.
  89957. */
  89958. private _isRadiusAtLimit;
  89959. /**
  89960. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  89961. * @param radiusDelta The delta by which to animate to. Can be negative.
  89962. */
  89963. private _applyBoundRadiusAnimation;
  89964. /**
  89965. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  89966. */
  89967. protected _clearAnimationLocks(): void;
  89968. /**
  89969. * Stops and removes all animations that have been applied to the camera
  89970. */
  89971. stopAllAnimations(): void;
  89972. }
  89973. }
  89974. declare module BABYLON {
  89975. /**
  89976. * 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.
  89977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  89978. */
  89979. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  89980. /**
  89981. * Gets the name of the behavior.
  89982. */
  89983. readonly name: string;
  89984. private _mode;
  89985. private _radiusScale;
  89986. private _positionScale;
  89987. private _defaultElevation;
  89988. private _elevationReturnTime;
  89989. private _elevationReturnWaitTime;
  89990. private _zoomStopsAnimation;
  89991. private _framingTime;
  89992. /**
  89993. * The easing function used by animations
  89994. */
  89995. static EasingFunction: ExponentialEase;
  89996. /**
  89997. * The easing mode used by animations
  89998. */
  89999. static EasingMode: number;
  90000. /**
  90001. * Sets the current mode used by the behavior
  90002. */
  90003. /**
  90004. * Gets current mode used by the behavior.
  90005. */
  90006. mode: number;
  90007. /**
  90008. * Sets the scale applied to the radius (1 by default)
  90009. */
  90010. /**
  90011. * Gets the scale applied to the radius
  90012. */
  90013. radiusScale: number;
  90014. /**
  90015. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90016. */
  90017. /**
  90018. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90019. */
  90020. positionScale: number;
  90021. /**
  90022. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90023. * behaviour is triggered, in radians.
  90024. */
  90025. /**
  90026. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90027. * behaviour is triggered, in radians.
  90028. */
  90029. defaultElevation: number;
  90030. /**
  90031. * Sets the time (in milliseconds) taken to return to the default beta position.
  90032. * Negative value indicates camera should not return to default.
  90033. */
  90034. /**
  90035. * Gets the time (in milliseconds) taken to return to the default beta position.
  90036. * Negative value indicates camera should not return to default.
  90037. */
  90038. elevationReturnTime: number;
  90039. /**
  90040. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90041. */
  90042. /**
  90043. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90044. */
  90045. elevationReturnWaitTime: number;
  90046. /**
  90047. * Sets the flag that indicates if user zooming should stop animation.
  90048. */
  90049. /**
  90050. * Gets the flag that indicates if user zooming should stop animation.
  90051. */
  90052. zoomStopsAnimation: boolean;
  90053. /**
  90054. * Sets the transition time when framing the mesh, in milliseconds
  90055. */
  90056. /**
  90057. * Gets the transition time when framing the mesh, in milliseconds
  90058. */
  90059. framingTime: number;
  90060. /**
  90061. * Define if the behavior should automatically change the configured
  90062. * camera limits and sensibilities.
  90063. */
  90064. autoCorrectCameraLimitsAndSensibility: boolean;
  90065. private _onPrePointerObservableObserver;
  90066. private _onAfterCheckInputsObserver;
  90067. private _onMeshTargetChangedObserver;
  90068. private _attachedCamera;
  90069. private _isPointerDown;
  90070. private _lastInteractionTime;
  90071. /**
  90072. * Initializes the behavior.
  90073. */
  90074. init(): void;
  90075. /**
  90076. * Attaches the behavior to its arc rotate camera.
  90077. * @param camera Defines the camera to attach the behavior to
  90078. */
  90079. attach(camera: ArcRotateCamera): void;
  90080. /**
  90081. * Detaches the behavior from its current arc rotate camera.
  90082. */
  90083. detach(): void;
  90084. private _animatables;
  90085. private _betaIsAnimating;
  90086. private _betaTransition;
  90087. private _radiusTransition;
  90088. private _vectorTransition;
  90089. /**
  90090. * Targets the given mesh and updates zoom level accordingly.
  90091. * @param mesh The mesh to target.
  90092. * @param radius Optional. If a cached radius position already exists, overrides default.
  90093. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90096. */
  90097. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90098. /**
  90099. * Targets the given mesh with its children and updates zoom level accordingly.
  90100. * @param mesh The mesh to target.
  90101. * @param radius Optional. If a cached radius position already exists, overrides default.
  90102. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90103. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90104. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90105. */
  90106. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90107. /**
  90108. * Targets the given meshes with their children and updates zoom level accordingly.
  90109. * @param meshes The mesh to target.
  90110. * @param radius Optional. If a cached radius position already exists, overrides default.
  90111. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90112. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90113. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90114. */
  90115. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90116. /**
  90117. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90118. * @param minimumWorld Determines the smaller position of the bounding box extend
  90119. * @param maximumWorld Determines the bigger position of the bounding box extend
  90120. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90121. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90122. */
  90123. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90124. /**
  90125. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90126. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90127. * frustum width.
  90128. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90129. * to fully enclose the mesh in the viewing frustum.
  90130. */
  90131. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90132. /**
  90133. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90134. * is automatically returned to its default position (expected to be above ground plane).
  90135. */
  90136. private _maintainCameraAboveGround;
  90137. /**
  90138. * Returns the frustum slope based on the canvas ratio and camera FOV
  90139. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90140. */
  90141. private _getFrustumSlope;
  90142. /**
  90143. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90144. */
  90145. private _clearAnimationLocks;
  90146. /**
  90147. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90148. */
  90149. private _applyUserInteraction;
  90150. /**
  90151. * Stops and removes all animations that have been applied to the camera
  90152. */
  90153. stopAllAnimations(): void;
  90154. /**
  90155. * Gets a value indicating if the user is moving the camera
  90156. */
  90157. readonly isUserIsMoving: boolean;
  90158. /**
  90159. * The camera can move all the way towards the mesh.
  90160. */
  90161. static IgnoreBoundsSizeMode: number;
  90162. /**
  90163. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90164. */
  90165. static FitFrustumSidesMode: number;
  90166. }
  90167. }
  90168. declare module BABYLON {
  90169. /**
  90170. * Manage the pointers inputs to control an arc rotate camera.
  90171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90172. */
  90173. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90174. /**
  90175. * Defines the camera the input is attached to.
  90176. */
  90177. camera: ArcRotateCamera;
  90178. /**
  90179. * Defines the buttons associated with the input to handle camera move.
  90180. */
  90181. buttons: number[];
  90182. /**
  90183. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90184. */
  90185. angularSensibilityX: number;
  90186. /**
  90187. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90188. */
  90189. angularSensibilityY: number;
  90190. /**
  90191. * Defines the pointer pinch precision or how fast is the camera zooming.
  90192. */
  90193. pinchPrecision: number;
  90194. /**
  90195. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90196. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90197. */
  90198. pinchDeltaPercentage: number;
  90199. /**
  90200. * Defines the pointer panning sensibility or how fast is the camera moving.
  90201. */
  90202. panningSensibility: number;
  90203. /**
  90204. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90205. */
  90206. multiTouchPanning: boolean;
  90207. /**
  90208. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90209. */
  90210. multiTouchPanAndZoom: boolean;
  90211. /**
  90212. * Revers pinch action direction.
  90213. */
  90214. pinchInwards: boolean;
  90215. private _isPanClick;
  90216. private _pointerInput;
  90217. private _observer;
  90218. private _onMouseMove;
  90219. private _onGestureStart;
  90220. private _onGesture;
  90221. private _MSGestureHandler;
  90222. private _onLostFocus;
  90223. private _onContextMenu;
  90224. /**
  90225. * Attach the input controls to a specific dom element to get the input from.
  90226. * @param element Defines the element the controls should be listened from
  90227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90228. */
  90229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90230. /**
  90231. * Detach the current controls from the specified dom element.
  90232. * @param element Defines the element to stop listening the inputs from
  90233. */
  90234. detachControl(element: Nullable<HTMLElement>): void;
  90235. /**
  90236. * Gets the class name of the current intput.
  90237. * @returns the class name
  90238. */
  90239. getClassName(): string;
  90240. /**
  90241. * Get the friendly name associated with the input class.
  90242. * @returns the input friendly name
  90243. */
  90244. getSimpleName(): string;
  90245. }
  90246. }
  90247. declare module BABYLON {
  90248. /**
  90249. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90251. */
  90252. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90253. /**
  90254. * Defines the camera the input is attached to.
  90255. */
  90256. camera: ArcRotateCamera;
  90257. /**
  90258. * Defines the list of key codes associated with the up action (increase alpha)
  90259. */
  90260. keysUp: number[];
  90261. /**
  90262. * Defines the list of key codes associated with the down action (decrease alpha)
  90263. */
  90264. keysDown: number[];
  90265. /**
  90266. * Defines the list of key codes associated with the left action (increase beta)
  90267. */
  90268. keysLeft: number[];
  90269. /**
  90270. * Defines the list of key codes associated with the right action (decrease beta)
  90271. */
  90272. keysRight: number[];
  90273. /**
  90274. * Defines the list of key codes associated with the reset action.
  90275. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90276. */
  90277. keysReset: number[];
  90278. /**
  90279. * Defines the panning sensibility of the inputs.
  90280. * (How fast is the camera paning)
  90281. */
  90282. panningSensibility: number;
  90283. /**
  90284. * Defines the zooming sensibility of the inputs.
  90285. * (How fast is the camera zooming)
  90286. */
  90287. zoomingSensibility: number;
  90288. /**
  90289. * Defines wether maintaining the alt key down switch the movement mode from
  90290. * orientation to zoom.
  90291. */
  90292. useAltToZoom: boolean;
  90293. /**
  90294. * Rotation speed of the camera
  90295. */
  90296. angularSpeed: number;
  90297. private _keys;
  90298. private _ctrlPressed;
  90299. private _altPressed;
  90300. private _onCanvasBlurObserver;
  90301. private _onKeyboardObserver;
  90302. private _engine;
  90303. private _scene;
  90304. /**
  90305. * Attach the input controls to a specific dom element to get the input from.
  90306. * @param element Defines the element the controls should be listened from
  90307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90308. */
  90309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90310. /**
  90311. * Detach the current controls from the specified dom element.
  90312. * @param element Defines the element to stop listening the inputs from
  90313. */
  90314. detachControl(element: Nullable<HTMLElement>): void;
  90315. /**
  90316. * Update the current camera state depending on the inputs that have been used this frame.
  90317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90318. */
  90319. checkInputs(): void;
  90320. /**
  90321. * Gets the class name of the current intput.
  90322. * @returns the class name
  90323. */
  90324. getClassName(): string;
  90325. /**
  90326. * Get the friendly name associated with the input class.
  90327. * @returns the input friendly name
  90328. */
  90329. getSimpleName(): string;
  90330. }
  90331. }
  90332. declare module BABYLON {
  90333. /**
  90334. * Manage the mouse wheel inputs to control an arc rotate camera.
  90335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90336. */
  90337. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90338. /**
  90339. * Defines the camera the input is attached to.
  90340. */
  90341. camera: ArcRotateCamera;
  90342. /**
  90343. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90344. */
  90345. wheelPrecision: number;
  90346. /**
  90347. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90348. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90349. */
  90350. wheelDeltaPercentage: number;
  90351. private _wheel;
  90352. private _observer;
  90353. /**
  90354. * Attach the input controls to a specific dom element to get the input from.
  90355. * @param element Defines the element the controls should be listened from
  90356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90357. */
  90358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90359. /**
  90360. * Detach the current controls from the specified dom element.
  90361. * @param element Defines the element to stop listening the inputs from
  90362. */
  90363. detachControl(element: Nullable<HTMLElement>): void;
  90364. /**
  90365. * Gets the class name of the current intput.
  90366. * @returns the class name
  90367. */
  90368. getClassName(): string;
  90369. /**
  90370. * Get the friendly name associated with the input class.
  90371. * @returns the input friendly name
  90372. */
  90373. getSimpleName(): string;
  90374. }
  90375. }
  90376. declare module BABYLON {
  90377. /**
  90378. * Default Inputs manager for the ArcRotateCamera.
  90379. * It groups all the default supported inputs for ease of use.
  90380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90381. */
  90382. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90383. /**
  90384. * Instantiates a new ArcRotateCameraInputsManager.
  90385. * @param camera Defines the camera the inputs belong to
  90386. */
  90387. constructor(camera: ArcRotateCamera);
  90388. /**
  90389. * Add mouse wheel input support to the input manager.
  90390. * @returns the current input manager
  90391. */
  90392. addMouseWheel(): ArcRotateCameraInputsManager;
  90393. /**
  90394. * Add pointers input support to the input manager.
  90395. * @returns the current input manager
  90396. */
  90397. addPointers(): ArcRotateCameraInputsManager;
  90398. /**
  90399. * Add keyboard input support to the input manager.
  90400. * @returns the current input manager
  90401. */
  90402. addKeyboard(): ArcRotateCameraInputsManager;
  90403. }
  90404. }
  90405. declare module BABYLON {
  90406. /**
  90407. * This represents an orbital type of camera.
  90408. *
  90409. * 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.
  90410. * 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.
  90411. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90412. */
  90413. export class ArcRotateCamera extends TargetCamera {
  90414. /**
  90415. * Defines the rotation angle of the camera along the longitudinal axis.
  90416. */
  90417. alpha: number;
  90418. /**
  90419. * Defines the rotation angle of the camera along the latitudinal axis.
  90420. */
  90421. beta: number;
  90422. /**
  90423. * Defines the radius of the camera from it s target point.
  90424. */
  90425. radius: number;
  90426. protected _target: Vector3;
  90427. protected _targetHost: Nullable<AbstractMesh>;
  90428. /**
  90429. * Defines the target point of the camera.
  90430. * The camera looks towards it form the radius distance.
  90431. */
  90432. target: Vector3;
  90433. /**
  90434. * Current inertia value on the longitudinal axis.
  90435. * The bigger this number the longer it will take for the camera to stop.
  90436. */
  90437. inertialAlphaOffset: number;
  90438. /**
  90439. * Current inertia value on the latitudinal axis.
  90440. * The bigger this number the longer it will take for the camera to stop.
  90441. */
  90442. inertialBetaOffset: number;
  90443. /**
  90444. * Current inertia value on the radius axis.
  90445. * The bigger this number the longer it will take for the camera to stop.
  90446. */
  90447. inertialRadiusOffset: number;
  90448. /**
  90449. * Minimum allowed angle on the longitudinal axis.
  90450. * This can help limiting how the Camera is able to move in the scene.
  90451. */
  90452. lowerAlphaLimit: Nullable<number>;
  90453. /**
  90454. * Maximum allowed angle on the longitudinal axis.
  90455. * This can help limiting how the Camera is able to move in the scene.
  90456. */
  90457. upperAlphaLimit: Nullable<number>;
  90458. /**
  90459. * Minimum allowed angle on the latitudinal axis.
  90460. * This can help limiting how the Camera is able to move in the scene.
  90461. */
  90462. lowerBetaLimit: number;
  90463. /**
  90464. * Maximum allowed angle on the latitudinal axis.
  90465. * This can help limiting how the Camera is able to move in the scene.
  90466. */
  90467. upperBetaLimit: number;
  90468. /**
  90469. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90470. * This can help limiting how the Camera is able to move in the scene.
  90471. */
  90472. lowerRadiusLimit: Nullable<number>;
  90473. /**
  90474. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90475. * This can help limiting how the Camera is able to move in the scene.
  90476. */
  90477. upperRadiusLimit: Nullable<number>;
  90478. /**
  90479. * Defines the current inertia value used during panning of the camera along the X axis.
  90480. */
  90481. inertialPanningX: number;
  90482. /**
  90483. * Defines the current inertia value used during panning of the camera along the Y axis.
  90484. */
  90485. inertialPanningY: number;
  90486. /**
  90487. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90488. * Basically if your fingers moves away from more than this distance you will be considered
  90489. * in pinch mode.
  90490. */
  90491. pinchToPanMaxDistance: number;
  90492. /**
  90493. * Defines the maximum distance the camera can pan.
  90494. * This could help keeping the cammera always in your scene.
  90495. */
  90496. panningDistanceLimit: Nullable<number>;
  90497. /**
  90498. * Defines the target of the camera before paning.
  90499. */
  90500. panningOriginTarget: Vector3;
  90501. /**
  90502. * Defines the value of the inertia used during panning.
  90503. * 0 would mean stop inertia and one would mean no decelleration at all.
  90504. */
  90505. panningInertia: number;
  90506. /**
  90507. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90508. */
  90509. angularSensibilityX: number;
  90510. /**
  90511. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90512. */
  90513. angularSensibilityY: number;
  90514. /**
  90515. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90516. */
  90517. pinchPrecision: number;
  90518. /**
  90519. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90520. * It will be used instead of pinchDeltaPrecision if different from 0.
  90521. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90522. */
  90523. pinchDeltaPercentage: number;
  90524. /**
  90525. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90526. */
  90527. panningSensibility: number;
  90528. /**
  90529. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90530. */
  90531. keysUp: number[];
  90532. /**
  90533. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90534. */
  90535. keysDown: number[];
  90536. /**
  90537. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90538. */
  90539. keysLeft: number[];
  90540. /**
  90541. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90542. */
  90543. keysRight: number[];
  90544. /**
  90545. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90546. */
  90547. wheelPrecision: number;
  90548. /**
  90549. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90550. * It will be used instead of pinchDeltaPrecision if different from 0.
  90551. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90552. */
  90553. wheelDeltaPercentage: number;
  90554. /**
  90555. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90556. */
  90557. zoomOnFactor: number;
  90558. /**
  90559. * Defines a screen offset for the camera position.
  90560. */
  90561. targetScreenOffset: Vector2;
  90562. /**
  90563. * Allows the camera to be completely reversed.
  90564. * If false the camera can not arrive upside down.
  90565. */
  90566. allowUpsideDown: boolean;
  90567. /**
  90568. * Define if double tap/click is used to restore the previously saved state of the camera.
  90569. */
  90570. useInputToRestoreState: boolean;
  90571. /** @hidden */
  90572. _viewMatrix: Matrix;
  90573. /** @hidden */
  90574. _useCtrlForPanning: boolean;
  90575. /** @hidden */
  90576. _panningMouseButton: number;
  90577. /**
  90578. * Defines the input associated to the camera.
  90579. */
  90580. inputs: ArcRotateCameraInputsManager;
  90581. /** @hidden */
  90582. _reset: () => void;
  90583. /**
  90584. * Defines the allowed panning axis.
  90585. */
  90586. panningAxis: Vector3;
  90587. protected _localDirection: Vector3;
  90588. protected _transformedDirection: Vector3;
  90589. private _bouncingBehavior;
  90590. /**
  90591. * Gets the bouncing behavior of the camera if it has been enabled.
  90592. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90593. */
  90594. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90595. /**
  90596. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90597. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90598. */
  90599. useBouncingBehavior: boolean;
  90600. private _framingBehavior;
  90601. /**
  90602. * Gets the framing behavior of the camera if it has been enabled.
  90603. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90604. */
  90605. readonly framingBehavior: Nullable<FramingBehavior>;
  90606. /**
  90607. * Defines if the framing behavior of the camera is enabled on the camera.
  90608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90609. */
  90610. useFramingBehavior: boolean;
  90611. private _autoRotationBehavior;
  90612. /**
  90613. * Gets the auto rotation behavior of the camera if it has been enabled.
  90614. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90615. */
  90616. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90617. /**
  90618. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90619. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90620. */
  90621. useAutoRotationBehavior: boolean;
  90622. /**
  90623. * Observable triggered when the mesh target has been changed on the camera.
  90624. */
  90625. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90626. /**
  90627. * Event raised when the camera is colliding with a mesh.
  90628. */
  90629. onCollide: (collidedMesh: AbstractMesh) => void;
  90630. /**
  90631. * Defines whether the camera should check collision with the objects oh the scene.
  90632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90633. */
  90634. checkCollisions: boolean;
  90635. /**
  90636. * Defines the collision radius of the camera.
  90637. * This simulates a sphere around the camera.
  90638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90639. */
  90640. collisionRadius: Vector3;
  90641. protected _collider: Collider;
  90642. protected _previousPosition: Vector3;
  90643. protected _collisionVelocity: Vector3;
  90644. protected _newPosition: Vector3;
  90645. protected _previousAlpha: number;
  90646. protected _previousBeta: number;
  90647. protected _previousRadius: number;
  90648. protected _collisionTriggered: boolean;
  90649. protected _targetBoundingCenter: Nullable<Vector3>;
  90650. private _computationVector;
  90651. private _tempAxisVector;
  90652. private _tempAxisRotationMatrix;
  90653. /**
  90654. * Instantiates a new ArcRotateCamera in a given scene
  90655. * @param name Defines the name of the camera
  90656. * @param alpha Defines the camera rotation along the logitudinal axis
  90657. * @param beta Defines the camera rotation along the latitudinal axis
  90658. * @param radius Defines the camera distance from its target
  90659. * @param target Defines the camera target
  90660. * @param scene Defines the scene the camera belongs to
  90661. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90662. */
  90663. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90664. /** @hidden */
  90665. _initCache(): void;
  90666. /** @hidden */
  90667. _updateCache(ignoreParentClass?: boolean): void;
  90668. protected _getTargetPosition(): Vector3;
  90669. private _storedAlpha;
  90670. private _storedBeta;
  90671. private _storedRadius;
  90672. private _storedTarget;
  90673. /**
  90674. * Stores the current state of the camera (alpha, beta, radius and target)
  90675. * @returns the camera itself
  90676. */
  90677. storeState(): Camera;
  90678. /**
  90679. * @hidden
  90680. * Restored camera state. You must call storeState() first
  90681. */
  90682. _restoreStateValues(): boolean;
  90683. /** @hidden */
  90684. _isSynchronizedViewMatrix(): boolean;
  90685. /**
  90686. * Attached controls to the current camera.
  90687. * @param element Defines the element the controls should be listened from
  90688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90689. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90690. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90691. */
  90692. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90693. /**
  90694. * Detach the current controls from the camera.
  90695. * The camera will stop reacting to inputs.
  90696. * @param element Defines the element to stop listening the inputs from
  90697. */
  90698. detachControl(element: HTMLElement): void;
  90699. /** @hidden */
  90700. _checkInputs(): void;
  90701. protected _checkLimits(): void;
  90702. /**
  90703. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90704. */
  90705. rebuildAnglesAndRadius(): void;
  90706. /**
  90707. * Use a position to define the current camera related information like aplha, beta and radius
  90708. * @param position Defines the position to set the camera at
  90709. */
  90710. setPosition(position: Vector3): void;
  90711. /**
  90712. * Defines the target the camera should look at.
  90713. * This will automatically adapt alpha beta and radius to fit within the new target.
  90714. * @param target Defines the new target as a Vector or a mesh
  90715. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90716. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90717. */
  90718. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90719. /** @hidden */
  90720. _getViewMatrix(): Matrix;
  90721. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90722. /**
  90723. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90724. * @param meshes Defines the mesh to zoom on
  90725. * @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)
  90726. */
  90727. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90728. /**
  90729. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90730. * The target will be changed but the radius
  90731. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90732. * @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)
  90733. */
  90734. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90735. min: Vector3;
  90736. max: Vector3;
  90737. distance: number;
  90738. }, doNotUpdateMaxZ?: boolean): void;
  90739. /**
  90740. * @override
  90741. * Override Camera.createRigCamera
  90742. */
  90743. createRigCamera(name: string, cameraIndex: number): Camera;
  90744. /**
  90745. * @hidden
  90746. * @override
  90747. * Override Camera._updateRigCameras
  90748. */
  90749. _updateRigCameras(): void;
  90750. /**
  90751. * Destroy the camera and release the current resources hold by it.
  90752. */
  90753. dispose(): void;
  90754. /**
  90755. * Gets the current object class name.
  90756. * @return the class name
  90757. */
  90758. getClassName(): string;
  90759. }
  90760. }
  90761. declare module BABYLON {
  90762. /**
  90763. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90764. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90765. */
  90766. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90767. /**
  90768. * Gets the name of the behavior.
  90769. */
  90770. readonly name: string;
  90771. private _zoomStopsAnimation;
  90772. private _idleRotationSpeed;
  90773. private _idleRotationWaitTime;
  90774. private _idleRotationSpinupTime;
  90775. /**
  90776. * Sets the flag that indicates if user zooming should stop animation.
  90777. */
  90778. /**
  90779. * Gets the flag that indicates if user zooming should stop animation.
  90780. */
  90781. zoomStopsAnimation: boolean;
  90782. /**
  90783. * Sets the default speed at which the camera rotates around the model.
  90784. */
  90785. /**
  90786. * Gets the default speed at which the camera rotates around the model.
  90787. */
  90788. idleRotationSpeed: number;
  90789. /**
  90790. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90791. */
  90792. /**
  90793. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90794. */
  90795. idleRotationWaitTime: number;
  90796. /**
  90797. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90798. */
  90799. /**
  90800. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90801. */
  90802. idleRotationSpinupTime: number;
  90803. /**
  90804. * Gets a value indicating if the camera is currently rotating because of this behavior
  90805. */
  90806. readonly rotationInProgress: boolean;
  90807. private _onPrePointerObservableObserver;
  90808. private _onAfterCheckInputsObserver;
  90809. private _attachedCamera;
  90810. private _isPointerDown;
  90811. private _lastFrameTime;
  90812. private _lastInteractionTime;
  90813. private _cameraRotationSpeed;
  90814. /**
  90815. * Initializes the behavior.
  90816. */
  90817. init(): void;
  90818. /**
  90819. * Attaches the behavior to its arc rotate camera.
  90820. * @param camera Defines the camera to attach the behavior to
  90821. */
  90822. attach(camera: ArcRotateCamera): void;
  90823. /**
  90824. * Detaches the behavior from its current arc rotate camera.
  90825. */
  90826. detach(): void;
  90827. /**
  90828. * Returns true if user is scrolling.
  90829. * @return true if user is scrolling.
  90830. */
  90831. private _userIsZooming;
  90832. private _lastFrameRadius;
  90833. private _shouldAnimationStopForInteraction;
  90834. /**
  90835. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90836. */
  90837. private _applyUserInteraction;
  90838. private _userIsMoving;
  90839. }
  90840. }
  90841. declare module BABYLON {
  90842. /**
  90843. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90844. */
  90845. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90846. private ui;
  90847. /**
  90848. * The name of the behavior
  90849. */
  90850. name: string;
  90851. /**
  90852. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90853. */
  90854. distanceAwayFromFace: number;
  90855. /**
  90856. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90857. */
  90858. distanceAwayFromBottomOfFace: number;
  90859. private _faceVectors;
  90860. private _target;
  90861. private _scene;
  90862. private _onRenderObserver;
  90863. private _tmpMatrix;
  90864. private _tmpVector;
  90865. /**
  90866. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90867. * @param ui The transform node that should be attched to the mesh
  90868. */
  90869. constructor(ui: TransformNode);
  90870. /**
  90871. * Initializes the behavior
  90872. */
  90873. init(): void;
  90874. private _closestFace;
  90875. private _zeroVector;
  90876. private _lookAtTmpMatrix;
  90877. private _lookAtToRef;
  90878. /**
  90879. * Attaches the AttachToBoxBehavior to the passed in mesh
  90880. * @param target The mesh that the specified node will be attached to
  90881. */
  90882. attach(target: Mesh): void;
  90883. /**
  90884. * Detaches the behavior from the mesh
  90885. */
  90886. detach(): void;
  90887. }
  90888. }
  90889. declare module BABYLON {
  90890. /**
  90891. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90892. */
  90893. export class FadeInOutBehavior implements Behavior<Mesh> {
  90894. /**
  90895. * Time in milliseconds to delay before fading in (Default: 0)
  90896. */
  90897. delay: number;
  90898. /**
  90899. * Time in milliseconds for the mesh to fade in (Default: 300)
  90900. */
  90901. fadeInTime: number;
  90902. private _millisecondsPerFrame;
  90903. private _hovered;
  90904. private _hoverValue;
  90905. private _ownerNode;
  90906. /**
  90907. * Instatiates the FadeInOutBehavior
  90908. */
  90909. constructor();
  90910. /**
  90911. * The name of the behavior
  90912. */
  90913. readonly name: string;
  90914. /**
  90915. * Initializes the behavior
  90916. */
  90917. init(): void;
  90918. /**
  90919. * Attaches the fade behavior on the passed in mesh
  90920. * @param ownerNode The mesh that will be faded in/out once attached
  90921. */
  90922. attach(ownerNode: Mesh): void;
  90923. /**
  90924. * Detaches the behavior from the mesh
  90925. */
  90926. detach(): void;
  90927. /**
  90928. * Triggers the mesh to begin fading in or out
  90929. * @param value if the object should fade in or out (true to fade in)
  90930. */
  90931. fadeIn(value: boolean): void;
  90932. private _update;
  90933. private _setAllVisibility;
  90934. }
  90935. }
  90936. declare module BABYLON {
  90937. /**
  90938. * Class containing a set of static utilities functions for managing Pivots
  90939. * @hidden
  90940. */
  90941. export class PivotTools {
  90942. private static _PivotCached;
  90943. private static _OldPivotPoint;
  90944. private static _PivotTranslation;
  90945. private static _PivotTmpVector;
  90946. /** @hidden */
  90947. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  90948. /** @hidden */
  90949. static _RestorePivotPoint(mesh: AbstractMesh): void;
  90950. }
  90951. }
  90952. declare module BABYLON {
  90953. /**
  90954. * Class containing static functions to help procedurally build meshes
  90955. */
  90956. export class PlaneBuilder {
  90957. /**
  90958. * Creates a plane mesh
  90959. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90960. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90961. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90965. * @param name defines the name of the mesh
  90966. * @param options defines the options used to create the mesh
  90967. * @param scene defines the hosting scene
  90968. * @returns the plane mesh
  90969. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90970. */
  90971. static CreatePlane(name: string, options: {
  90972. size?: number;
  90973. width?: number;
  90974. height?: number;
  90975. sideOrientation?: number;
  90976. frontUVs?: Vector4;
  90977. backUVs?: Vector4;
  90978. updatable?: boolean;
  90979. sourcePlane?: Plane;
  90980. }, scene: Scene): Mesh;
  90981. }
  90982. }
  90983. declare module BABYLON {
  90984. /**
  90985. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  90986. */
  90987. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  90988. private static _AnyMouseID;
  90989. private _attachedNode;
  90990. private _dragPlane;
  90991. private _scene;
  90992. private _pointerObserver;
  90993. private _beforeRenderObserver;
  90994. private static _planeScene;
  90995. /**
  90996. * 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)
  90997. */
  90998. maxDragAngle: number;
  90999. /**
  91000. * @hidden
  91001. */
  91002. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91003. /**
  91004. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91005. */
  91006. currentDraggingPointerID: number;
  91007. /**
  91008. * The last position where the pointer hit the drag plane in world space
  91009. */
  91010. lastDragPosition: Vector3;
  91011. /**
  91012. * If the behavior is currently in a dragging state
  91013. */
  91014. dragging: boolean;
  91015. /**
  91016. * 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)
  91017. */
  91018. dragDeltaRatio: number;
  91019. /**
  91020. * If the drag plane orientation should be updated during the dragging (Default: true)
  91021. */
  91022. updateDragPlane: boolean;
  91023. private _debugMode;
  91024. private _moving;
  91025. /**
  91026. * Fires each time the attached mesh is dragged with the pointer
  91027. * * delta between last drag position and current drag position in world space
  91028. * * dragDistance along the drag axis
  91029. * * dragPlaneNormal normal of the current drag plane used during the drag
  91030. * * dragPlanePoint in world space where the drag intersects the drag plane
  91031. */
  91032. onDragObservable: Observable<{
  91033. delta: Vector3;
  91034. dragPlanePoint: Vector3;
  91035. dragPlaneNormal: Vector3;
  91036. dragDistance: number;
  91037. pointerId: number;
  91038. }>;
  91039. /**
  91040. * Fires each time a drag begins (eg. mouse down on mesh)
  91041. */
  91042. onDragStartObservable: Observable<{
  91043. dragPlanePoint: Vector3;
  91044. pointerId: number;
  91045. }>;
  91046. /**
  91047. * Fires each time a drag ends (eg. mouse release after drag)
  91048. */
  91049. onDragEndObservable: Observable<{
  91050. dragPlanePoint: Vector3;
  91051. pointerId: number;
  91052. }>;
  91053. /**
  91054. * If the attached mesh should be moved when dragged
  91055. */
  91056. moveAttached: boolean;
  91057. /**
  91058. * If the drag behavior will react to drag events (Default: true)
  91059. */
  91060. enabled: boolean;
  91061. /**
  91062. * If camera controls should be detached during the drag
  91063. */
  91064. detachCameraControls: boolean;
  91065. /**
  91066. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91067. */
  91068. useObjectOrienationForDragging: boolean;
  91069. private _options;
  91070. /**
  91071. * Creates a pointer drag behavior that can be attached to a mesh
  91072. * @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)
  91073. */
  91074. constructor(options?: {
  91075. dragAxis?: Vector3;
  91076. dragPlaneNormal?: Vector3;
  91077. });
  91078. /**
  91079. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91080. */
  91081. validateDrag: (targetPosition: Vector3) => boolean;
  91082. /**
  91083. * The name of the behavior
  91084. */
  91085. readonly name: string;
  91086. /**
  91087. * Initializes the behavior
  91088. */
  91089. init(): void;
  91090. private _tmpVector;
  91091. private _alternatePickedPoint;
  91092. private _worldDragAxis;
  91093. private _targetPosition;
  91094. private _attachedElement;
  91095. /**
  91096. * Attaches the drag behavior the passed in mesh
  91097. * @param ownerNode The mesh that will be dragged around once attached
  91098. */
  91099. attach(ownerNode: AbstractMesh): void;
  91100. /**
  91101. * Force relase the drag action by code.
  91102. */
  91103. releaseDrag(): void;
  91104. private _startDragRay;
  91105. private _lastPointerRay;
  91106. /**
  91107. * Simulates the start of a pointer drag event on the behavior
  91108. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91109. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91110. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91111. */
  91112. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91113. private _startDrag;
  91114. private _dragDelta;
  91115. private _moveDrag;
  91116. private _pickWithRayOnDragPlane;
  91117. private _pointA;
  91118. private _pointB;
  91119. private _pointC;
  91120. private _lineA;
  91121. private _lineB;
  91122. private _localAxis;
  91123. private _lookAt;
  91124. private _updateDragPlanePosition;
  91125. /**
  91126. * Detaches the behavior from the mesh
  91127. */
  91128. detach(): void;
  91129. }
  91130. }
  91131. declare module BABYLON {
  91132. /**
  91133. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91134. */
  91135. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91136. private _dragBehaviorA;
  91137. private _dragBehaviorB;
  91138. private _startDistance;
  91139. private _initialScale;
  91140. private _targetScale;
  91141. private _ownerNode;
  91142. private _sceneRenderObserver;
  91143. /**
  91144. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91145. */
  91146. constructor();
  91147. /**
  91148. * The name of the behavior
  91149. */
  91150. readonly name: string;
  91151. /**
  91152. * Initializes the behavior
  91153. */
  91154. init(): void;
  91155. private _getCurrentDistance;
  91156. /**
  91157. * Attaches the scale behavior the passed in mesh
  91158. * @param ownerNode The mesh that will be scaled around once attached
  91159. */
  91160. attach(ownerNode: Mesh): void;
  91161. /**
  91162. * Detaches the behavior from the mesh
  91163. */
  91164. detach(): void;
  91165. }
  91166. }
  91167. declare module BABYLON {
  91168. /**
  91169. * 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
  91170. */
  91171. export class SixDofDragBehavior implements Behavior<Mesh> {
  91172. private static _virtualScene;
  91173. private _ownerNode;
  91174. private _sceneRenderObserver;
  91175. private _scene;
  91176. private _targetPosition;
  91177. private _virtualOriginMesh;
  91178. private _virtualDragMesh;
  91179. private _pointerObserver;
  91180. private _moving;
  91181. private _startingOrientation;
  91182. /**
  91183. * 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)
  91184. */
  91185. private zDragFactor;
  91186. /**
  91187. * If the object should rotate to face the drag origin
  91188. */
  91189. rotateDraggedObject: boolean;
  91190. /**
  91191. * If the behavior is currently in a dragging state
  91192. */
  91193. dragging: boolean;
  91194. /**
  91195. * 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)
  91196. */
  91197. dragDeltaRatio: number;
  91198. /**
  91199. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91200. */
  91201. currentDraggingPointerID: number;
  91202. /**
  91203. * If camera controls should be detached during the drag
  91204. */
  91205. detachCameraControls: boolean;
  91206. /**
  91207. * Fires each time a drag starts
  91208. */
  91209. onDragStartObservable: Observable<{}>;
  91210. /**
  91211. * Fires each time a drag ends (eg. mouse release after drag)
  91212. */
  91213. onDragEndObservable: Observable<{}>;
  91214. /**
  91215. * 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
  91216. */
  91217. constructor();
  91218. /**
  91219. * The name of the behavior
  91220. */
  91221. readonly name: string;
  91222. /**
  91223. * Initializes the behavior
  91224. */
  91225. init(): void;
  91226. /**
  91227. * Attaches the scale behavior the passed in mesh
  91228. * @param ownerNode The mesh that will be scaled around once attached
  91229. */
  91230. attach(ownerNode: Mesh): void;
  91231. /**
  91232. * Detaches the behavior from the mesh
  91233. */
  91234. detach(): void;
  91235. }
  91236. }
  91237. declare module BABYLON {
  91238. /**
  91239. * Class used to apply inverse kinematics to bones
  91240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91241. */
  91242. export class BoneIKController {
  91243. private static _tmpVecs;
  91244. private static _tmpQuat;
  91245. private static _tmpMats;
  91246. /**
  91247. * Gets or sets the target mesh
  91248. */
  91249. targetMesh: AbstractMesh;
  91250. /** Gets or sets the mesh used as pole */
  91251. poleTargetMesh: AbstractMesh;
  91252. /**
  91253. * Gets or sets the bone used as pole
  91254. */
  91255. poleTargetBone: Nullable<Bone>;
  91256. /**
  91257. * Gets or sets the target position
  91258. */
  91259. targetPosition: Vector3;
  91260. /**
  91261. * Gets or sets the pole target position
  91262. */
  91263. poleTargetPosition: Vector3;
  91264. /**
  91265. * Gets or sets the pole target local offset
  91266. */
  91267. poleTargetLocalOffset: Vector3;
  91268. /**
  91269. * Gets or sets the pole angle
  91270. */
  91271. poleAngle: number;
  91272. /**
  91273. * Gets or sets the mesh associated with the controller
  91274. */
  91275. mesh: AbstractMesh;
  91276. /**
  91277. * 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)
  91278. */
  91279. slerpAmount: number;
  91280. private _bone1Quat;
  91281. private _bone1Mat;
  91282. private _bone2Ang;
  91283. private _bone1;
  91284. private _bone2;
  91285. private _bone1Length;
  91286. private _bone2Length;
  91287. private _maxAngle;
  91288. private _maxReach;
  91289. private _rightHandedSystem;
  91290. private _bendAxis;
  91291. private _slerping;
  91292. private _adjustRoll;
  91293. /**
  91294. * Gets or sets maximum allowed angle
  91295. */
  91296. maxAngle: number;
  91297. /**
  91298. * Creates a new BoneIKController
  91299. * @param mesh defines the mesh to control
  91300. * @param bone defines the bone to control
  91301. * @param options defines options to set up the controller
  91302. */
  91303. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91304. targetMesh?: AbstractMesh;
  91305. poleTargetMesh?: AbstractMesh;
  91306. poleTargetBone?: Bone;
  91307. poleTargetLocalOffset?: Vector3;
  91308. poleAngle?: number;
  91309. bendAxis?: Vector3;
  91310. maxAngle?: number;
  91311. slerpAmount?: number;
  91312. });
  91313. private _setMaxAngle;
  91314. /**
  91315. * Force the controller to update the bones
  91316. */
  91317. update(): void;
  91318. }
  91319. }
  91320. declare module BABYLON {
  91321. /**
  91322. * Class used to make a bone look toward a point in space
  91323. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91324. */
  91325. export class BoneLookController {
  91326. private static _tmpVecs;
  91327. private static _tmpQuat;
  91328. private static _tmpMats;
  91329. /**
  91330. * The target Vector3 that the bone will look at
  91331. */
  91332. target: Vector3;
  91333. /**
  91334. * The mesh that the bone is attached to
  91335. */
  91336. mesh: AbstractMesh;
  91337. /**
  91338. * The bone that will be looking to the target
  91339. */
  91340. bone: Bone;
  91341. /**
  91342. * The up axis of the coordinate system that is used when the bone is rotated
  91343. */
  91344. upAxis: Vector3;
  91345. /**
  91346. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91347. */
  91348. upAxisSpace: Space;
  91349. /**
  91350. * Used to make an adjustment to the yaw of the bone
  91351. */
  91352. adjustYaw: number;
  91353. /**
  91354. * Used to make an adjustment to the pitch of the bone
  91355. */
  91356. adjustPitch: number;
  91357. /**
  91358. * Used to make an adjustment to the roll of the bone
  91359. */
  91360. adjustRoll: number;
  91361. /**
  91362. * 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)
  91363. */
  91364. slerpAmount: number;
  91365. private _minYaw;
  91366. private _maxYaw;
  91367. private _minPitch;
  91368. private _maxPitch;
  91369. private _minYawSin;
  91370. private _minYawCos;
  91371. private _maxYawSin;
  91372. private _maxYawCos;
  91373. private _midYawConstraint;
  91374. private _minPitchTan;
  91375. private _maxPitchTan;
  91376. private _boneQuat;
  91377. private _slerping;
  91378. private _transformYawPitch;
  91379. private _transformYawPitchInv;
  91380. private _firstFrameSkipped;
  91381. private _yawRange;
  91382. private _fowardAxis;
  91383. /**
  91384. * Gets or sets the minimum yaw angle that the bone can look to
  91385. */
  91386. minYaw: number;
  91387. /**
  91388. * Gets or sets the maximum yaw angle that the bone can look to
  91389. */
  91390. maxYaw: number;
  91391. /**
  91392. * Gets or sets the minimum pitch angle that the bone can look to
  91393. */
  91394. minPitch: number;
  91395. /**
  91396. * Gets or sets the maximum pitch angle that the bone can look to
  91397. */
  91398. maxPitch: number;
  91399. /**
  91400. * Create a BoneLookController
  91401. * @param mesh the mesh that the bone belongs to
  91402. * @param bone the bone that will be looking to the target
  91403. * @param target the target Vector3 to look at
  91404. * @param options optional settings:
  91405. * * maxYaw: the maximum angle the bone will yaw to
  91406. * * minYaw: the minimum angle the bone will yaw to
  91407. * * maxPitch: the maximum angle the bone will pitch to
  91408. * * minPitch: the minimum angle the bone will yaw to
  91409. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91410. * * upAxis: the up axis of the coordinate system
  91411. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91412. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91413. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91414. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91415. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91416. * * adjustRoll: used to make an adjustment to the roll of the bone
  91417. **/
  91418. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91419. maxYaw?: number;
  91420. minYaw?: number;
  91421. maxPitch?: number;
  91422. minPitch?: number;
  91423. slerpAmount?: number;
  91424. upAxis?: Vector3;
  91425. upAxisSpace?: Space;
  91426. yawAxis?: Vector3;
  91427. pitchAxis?: Vector3;
  91428. adjustYaw?: number;
  91429. adjustPitch?: number;
  91430. adjustRoll?: number;
  91431. });
  91432. /**
  91433. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91434. */
  91435. update(): void;
  91436. private _getAngleDiff;
  91437. private _getAngleBetween;
  91438. private _isAngleBetween;
  91439. }
  91440. }
  91441. declare module BABYLON {
  91442. /**
  91443. * Manage the gamepad inputs to control an arc rotate camera.
  91444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91445. */
  91446. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91447. /**
  91448. * Defines the camera the input is attached to.
  91449. */
  91450. camera: ArcRotateCamera;
  91451. /**
  91452. * Defines the gamepad the input is gathering event from.
  91453. */
  91454. gamepad: Nullable<Gamepad>;
  91455. /**
  91456. * Defines the gamepad rotation sensiblity.
  91457. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91458. */
  91459. gamepadRotationSensibility: number;
  91460. /**
  91461. * Defines the gamepad move sensiblity.
  91462. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91463. */
  91464. gamepadMoveSensibility: number;
  91465. private _onGamepadConnectedObserver;
  91466. private _onGamepadDisconnectedObserver;
  91467. /**
  91468. * Attach the input controls to a specific dom element to get the input from.
  91469. * @param element Defines the element the controls should be listened from
  91470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91471. */
  91472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91473. /**
  91474. * Detach the current controls from the specified dom element.
  91475. * @param element Defines the element to stop listening the inputs from
  91476. */
  91477. detachControl(element: Nullable<HTMLElement>): void;
  91478. /**
  91479. * Update the current camera state depending on the inputs that have been used this frame.
  91480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91481. */
  91482. checkInputs(): void;
  91483. /**
  91484. * Gets the class name of the current intput.
  91485. * @returns the class name
  91486. */
  91487. getClassName(): string;
  91488. /**
  91489. * Get the friendly name associated with the input class.
  91490. * @returns the input friendly name
  91491. */
  91492. getSimpleName(): string;
  91493. }
  91494. }
  91495. declare module BABYLON {
  91496. interface ArcRotateCameraInputsManager {
  91497. /**
  91498. * Add orientation input support to the input manager.
  91499. * @returns the current input manager
  91500. */
  91501. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91502. }
  91503. /**
  91504. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91506. */
  91507. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91508. /**
  91509. * Defines the camera the input is attached to.
  91510. */
  91511. camera: ArcRotateCamera;
  91512. /**
  91513. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91514. */
  91515. alphaCorrection: number;
  91516. /**
  91517. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91518. */
  91519. gammaCorrection: number;
  91520. private _alpha;
  91521. private _gamma;
  91522. private _dirty;
  91523. private _deviceOrientationHandler;
  91524. /**
  91525. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91526. */
  91527. constructor();
  91528. /**
  91529. * Attach the input controls to a specific dom element to get the input from.
  91530. * @param element Defines the element the controls should be listened from
  91531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91532. */
  91533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91534. /** @hidden */
  91535. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91536. /**
  91537. * Update the current camera state depending on the inputs that have been used this frame.
  91538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91539. */
  91540. checkInputs(): void;
  91541. /**
  91542. * Detach the current controls from the specified dom element.
  91543. * @param element Defines the element to stop listening the inputs from
  91544. */
  91545. detachControl(element: Nullable<HTMLElement>): void;
  91546. /**
  91547. * Gets the class name of the current intput.
  91548. * @returns the class name
  91549. */
  91550. getClassName(): string;
  91551. /**
  91552. * Get the friendly name associated with the input class.
  91553. * @returns the input friendly name
  91554. */
  91555. getSimpleName(): string;
  91556. }
  91557. }
  91558. declare module BABYLON {
  91559. /**
  91560. * Listen to mouse events to control the camera.
  91561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91562. */
  91563. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91564. /**
  91565. * Defines the camera the input is attached to.
  91566. */
  91567. camera: FlyCamera;
  91568. /**
  91569. * Defines if touch is enabled. (Default is true.)
  91570. */
  91571. touchEnabled: boolean;
  91572. /**
  91573. * Defines the buttons associated with the input to handle camera rotation.
  91574. */
  91575. buttons: number[];
  91576. /**
  91577. * Assign buttons for Yaw control.
  91578. */
  91579. buttonsYaw: number[];
  91580. /**
  91581. * Assign buttons for Pitch control.
  91582. */
  91583. buttonsPitch: number[];
  91584. /**
  91585. * Assign buttons for Roll control.
  91586. */
  91587. buttonsRoll: number[];
  91588. /**
  91589. * Detect if any button is being pressed while mouse is moved.
  91590. * -1 = Mouse locked.
  91591. * 0 = Left button.
  91592. * 1 = Middle Button.
  91593. * 2 = Right Button.
  91594. */
  91595. activeButton: number;
  91596. /**
  91597. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91598. * Higher values reduce its sensitivity.
  91599. */
  91600. angularSensibility: number;
  91601. private _mousemoveCallback;
  91602. private _observer;
  91603. private _rollObserver;
  91604. private previousPosition;
  91605. private noPreventDefault;
  91606. private element;
  91607. /**
  91608. * Listen to mouse events to control the camera.
  91609. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91611. */
  91612. constructor(touchEnabled?: boolean);
  91613. /**
  91614. * Attach the mouse control to the HTML DOM element.
  91615. * @param element Defines the element that listens to the input events.
  91616. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91617. */
  91618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91619. /**
  91620. * Detach the current controls from the specified dom element.
  91621. * @param element Defines the element to stop listening the inputs from
  91622. */
  91623. detachControl(element: Nullable<HTMLElement>): void;
  91624. /**
  91625. * Gets the class name of the current input.
  91626. * @returns the class name.
  91627. */
  91628. getClassName(): string;
  91629. /**
  91630. * Get the friendly name associated with the input class.
  91631. * @returns the input's friendly name.
  91632. */
  91633. getSimpleName(): string;
  91634. private _pointerInput;
  91635. private _onMouseMove;
  91636. /**
  91637. * Rotate camera by mouse offset.
  91638. */
  91639. private rotateCamera;
  91640. }
  91641. }
  91642. declare module BABYLON {
  91643. /**
  91644. * Default Inputs manager for the FlyCamera.
  91645. * It groups all the default supported inputs for ease of use.
  91646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91647. */
  91648. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91649. /**
  91650. * Instantiates a new FlyCameraInputsManager.
  91651. * @param camera Defines the camera the inputs belong to.
  91652. */
  91653. constructor(camera: FlyCamera);
  91654. /**
  91655. * Add keyboard input support to the input manager.
  91656. * @returns the new FlyCameraKeyboardMoveInput().
  91657. */
  91658. addKeyboard(): FlyCameraInputsManager;
  91659. /**
  91660. * Add mouse input support to the input manager.
  91661. * @param touchEnabled Enable touch screen support.
  91662. * @returns the new FlyCameraMouseInput().
  91663. */
  91664. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91665. }
  91666. }
  91667. declare module BABYLON {
  91668. /**
  91669. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91670. * such as in a 3D Space Shooter or a Flight Simulator.
  91671. */
  91672. export class FlyCamera extends TargetCamera {
  91673. /**
  91674. * Define the collision ellipsoid of the camera.
  91675. * This is helpful for simulating a camera body, like a player's body.
  91676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91677. */
  91678. ellipsoid: Vector3;
  91679. /**
  91680. * Define an offset for the position of the ellipsoid around the camera.
  91681. * This can be helpful if the camera is attached away from the player's body center,
  91682. * such as at its head.
  91683. */
  91684. ellipsoidOffset: Vector3;
  91685. /**
  91686. * Enable or disable collisions of the camera with the rest of the scene objects.
  91687. */
  91688. checkCollisions: boolean;
  91689. /**
  91690. * Enable or disable gravity on the camera.
  91691. */
  91692. applyGravity: boolean;
  91693. /**
  91694. * Define the current direction the camera is moving to.
  91695. */
  91696. cameraDirection: Vector3;
  91697. /**
  91698. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91699. * This overrides and empties cameraRotation.
  91700. */
  91701. rotationQuaternion: Quaternion;
  91702. /**
  91703. * Track Roll to maintain the wanted Rolling when looking around.
  91704. */
  91705. _trackRoll: number;
  91706. /**
  91707. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91708. */
  91709. rollCorrect: number;
  91710. /**
  91711. * Mimic a banked turn, Rolling the camera when Yawing.
  91712. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91713. */
  91714. bankedTurn: boolean;
  91715. /**
  91716. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91717. */
  91718. bankedTurnLimit: number;
  91719. /**
  91720. * Value of 0 disables the banked Roll.
  91721. * Value of 1 is equal to the Yaw angle in radians.
  91722. */
  91723. bankedTurnMultiplier: number;
  91724. /**
  91725. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91726. */
  91727. inputs: FlyCameraInputsManager;
  91728. /**
  91729. * Gets the input sensibility for mouse input.
  91730. * Higher values reduce sensitivity.
  91731. */
  91732. /**
  91733. * Sets the input sensibility for a mouse input.
  91734. * Higher values reduce sensitivity.
  91735. */
  91736. angularSensibility: number;
  91737. /**
  91738. * Get the keys for camera movement forward.
  91739. */
  91740. /**
  91741. * Set the keys for camera movement forward.
  91742. */
  91743. keysForward: number[];
  91744. /**
  91745. * Get the keys for camera movement backward.
  91746. */
  91747. keysBackward: number[];
  91748. /**
  91749. * Get the keys for camera movement up.
  91750. */
  91751. /**
  91752. * Set the keys for camera movement up.
  91753. */
  91754. keysUp: number[];
  91755. /**
  91756. * Get the keys for camera movement down.
  91757. */
  91758. /**
  91759. * Set the keys for camera movement down.
  91760. */
  91761. keysDown: number[];
  91762. /**
  91763. * Get the keys for camera movement left.
  91764. */
  91765. /**
  91766. * Set the keys for camera movement left.
  91767. */
  91768. keysLeft: number[];
  91769. /**
  91770. * Set the keys for camera movement right.
  91771. */
  91772. /**
  91773. * Set the keys for camera movement right.
  91774. */
  91775. keysRight: number[];
  91776. /**
  91777. * Event raised when the camera collides with a mesh in the scene.
  91778. */
  91779. onCollide: (collidedMesh: AbstractMesh) => void;
  91780. private _collider;
  91781. private _needMoveForGravity;
  91782. private _oldPosition;
  91783. private _diffPosition;
  91784. private _newPosition;
  91785. /** @hidden */
  91786. _localDirection: Vector3;
  91787. /** @hidden */
  91788. _transformedDirection: Vector3;
  91789. /**
  91790. * Instantiates a FlyCamera.
  91791. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91792. * such as in a 3D Space Shooter or a Flight Simulator.
  91793. * @param name Define the name of the camera in the scene.
  91794. * @param position Define the starting position of the camera in the scene.
  91795. * @param scene Define the scene the camera belongs to.
  91796. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91797. */
  91798. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91799. /**
  91800. * Attach a control to the HTML DOM element.
  91801. * @param element Defines the element that listens to the input events.
  91802. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91803. */
  91804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91805. /**
  91806. * Detach a control from the HTML DOM element.
  91807. * The camera will stop reacting to that input.
  91808. * @param element Defines the element that listens to the input events.
  91809. */
  91810. detachControl(element: HTMLElement): void;
  91811. private _collisionMask;
  91812. /**
  91813. * Get the mask that the camera ignores in collision events.
  91814. */
  91815. /**
  91816. * Set the mask that the camera ignores in collision events.
  91817. */
  91818. collisionMask: number;
  91819. /** @hidden */
  91820. _collideWithWorld(displacement: Vector3): void;
  91821. /** @hidden */
  91822. private _onCollisionPositionChange;
  91823. /** @hidden */
  91824. _checkInputs(): void;
  91825. /** @hidden */
  91826. _decideIfNeedsToMove(): boolean;
  91827. /** @hidden */
  91828. _updatePosition(): void;
  91829. /**
  91830. * Restore the Roll to its target value at the rate specified.
  91831. * @param rate - Higher means slower restoring.
  91832. * @hidden
  91833. */
  91834. restoreRoll(rate: number): void;
  91835. /**
  91836. * Destroy the camera and release the current resources held by it.
  91837. */
  91838. dispose(): void;
  91839. /**
  91840. * Get the current object class name.
  91841. * @returns the class name.
  91842. */
  91843. getClassName(): string;
  91844. }
  91845. }
  91846. declare module BABYLON {
  91847. /**
  91848. * Listen to keyboard events to control the camera.
  91849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91850. */
  91851. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91852. /**
  91853. * Defines the camera the input is attached to.
  91854. */
  91855. camera: FlyCamera;
  91856. /**
  91857. * The list of keyboard keys used to control the forward move of the camera.
  91858. */
  91859. keysForward: number[];
  91860. /**
  91861. * The list of keyboard keys used to control the backward move of the camera.
  91862. */
  91863. keysBackward: number[];
  91864. /**
  91865. * The list of keyboard keys used to control the forward move of the camera.
  91866. */
  91867. keysUp: number[];
  91868. /**
  91869. * The list of keyboard keys used to control the backward move of the camera.
  91870. */
  91871. keysDown: number[];
  91872. /**
  91873. * The list of keyboard keys used to control the right strafe move of the camera.
  91874. */
  91875. keysRight: number[];
  91876. /**
  91877. * The list of keyboard keys used to control the left strafe move of the camera.
  91878. */
  91879. keysLeft: number[];
  91880. private _keys;
  91881. private _onCanvasBlurObserver;
  91882. private _onKeyboardObserver;
  91883. private _engine;
  91884. private _scene;
  91885. /**
  91886. * Attach the input controls to a specific dom element to get the input from.
  91887. * @param element Defines the element the controls should be listened from
  91888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91889. */
  91890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91891. /**
  91892. * Detach the current controls from the specified dom element.
  91893. * @param element Defines the element to stop listening the inputs from
  91894. */
  91895. detachControl(element: Nullable<HTMLElement>): void;
  91896. /**
  91897. * Gets the class name of the current intput.
  91898. * @returns the class name
  91899. */
  91900. getClassName(): string;
  91901. /** @hidden */
  91902. _onLostFocus(e: FocusEvent): void;
  91903. /**
  91904. * Get the friendly name associated with the input class.
  91905. * @returns the input friendly name
  91906. */
  91907. getSimpleName(): string;
  91908. /**
  91909. * Update the current camera state depending on the inputs that have been used this frame.
  91910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91911. */
  91912. checkInputs(): void;
  91913. }
  91914. }
  91915. declare module BABYLON {
  91916. interface FreeCameraInputsManager {
  91917. /**
  91918. * Add orientation input support to the input manager.
  91919. * @returns the current input manager
  91920. */
  91921. addDeviceOrientation(): FreeCameraInputsManager;
  91922. }
  91923. /**
  91924. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  91925. * Screen rotation is taken into account.
  91926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91927. */
  91928. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  91929. private _camera;
  91930. private _screenOrientationAngle;
  91931. private _constantTranform;
  91932. private _screenQuaternion;
  91933. private _alpha;
  91934. private _beta;
  91935. private _gamma;
  91936. /**
  91937. * Instantiates a new input
  91938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91939. */
  91940. constructor();
  91941. /**
  91942. * Define the camera controlled by the input.
  91943. */
  91944. camera: FreeCamera;
  91945. /**
  91946. * Attach the input controls to a specific dom element to get the input from.
  91947. * @param element Defines the element the controls should be listened from
  91948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91949. */
  91950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91951. private _orientationChanged;
  91952. private _deviceOrientation;
  91953. /**
  91954. * Detach the current controls from the specified dom element.
  91955. * @param element Defines the element to stop listening the inputs from
  91956. */
  91957. detachControl(element: Nullable<HTMLElement>): void;
  91958. /**
  91959. * Update the current camera state depending on the inputs that have been used this frame.
  91960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91961. */
  91962. checkInputs(): void;
  91963. /**
  91964. * Gets the class name of the current intput.
  91965. * @returns the class name
  91966. */
  91967. getClassName(): string;
  91968. /**
  91969. * Get the friendly name associated with the input class.
  91970. * @returns the input friendly name
  91971. */
  91972. getSimpleName(): string;
  91973. }
  91974. }
  91975. declare module BABYLON {
  91976. /**
  91977. * Manage the gamepad inputs to control a free camera.
  91978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91979. */
  91980. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  91981. /**
  91982. * Define the camera the input is attached to.
  91983. */
  91984. camera: FreeCamera;
  91985. /**
  91986. * Define the Gamepad controlling the input
  91987. */
  91988. gamepad: Nullable<Gamepad>;
  91989. /**
  91990. * Defines the gamepad rotation sensiblity.
  91991. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91992. */
  91993. gamepadAngularSensibility: number;
  91994. /**
  91995. * Defines the gamepad move sensiblity.
  91996. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91997. */
  91998. gamepadMoveSensibility: number;
  91999. private _onGamepadConnectedObserver;
  92000. private _onGamepadDisconnectedObserver;
  92001. private _cameraTransform;
  92002. private _deltaTransform;
  92003. private _vector3;
  92004. private _vector2;
  92005. /**
  92006. * Attach the input controls to a specific dom element to get the input from.
  92007. * @param element Defines the element the controls should be listened from
  92008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92009. */
  92010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92011. /**
  92012. * Detach the current controls from the specified dom element.
  92013. * @param element Defines the element to stop listening the inputs from
  92014. */
  92015. detachControl(element: Nullable<HTMLElement>): void;
  92016. /**
  92017. * Update the current camera state depending on the inputs that have been used this frame.
  92018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92019. */
  92020. checkInputs(): void;
  92021. /**
  92022. * Gets the class name of the current intput.
  92023. * @returns the class name
  92024. */
  92025. getClassName(): string;
  92026. /**
  92027. * Get the friendly name associated with the input class.
  92028. * @returns the input friendly name
  92029. */
  92030. getSimpleName(): string;
  92031. }
  92032. }
  92033. declare module BABYLON {
  92034. /**
  92035. * Defines the potential axis of a Joystick
  92036. */
  92037. export enum JoystickAxis {
  92038. /** X axis */
  92039. X = 0,
  92040. /** Y axis */
  92041. Y = 1,
  92042. /** Z axis */
  92043. Z = 2
  92044. }
  92045. /**
  92046. * Class used to define virtual joystick (used in touch mode)
  92047. */
  92048. export class VirtualJoystick {
  92049. /**
  92050. * Gets or sets a boolean indicating that left and right values must be inverted
  92051. */
  92052. reverseLeftRight: boolean;
  92053. /**
  92054. * Gets or sets a boolean indicating that up and down values must be inverted
  92055. */
  92056. reverseUpDown: boolean;
  92057. /**
  92058. * Gets the offset value for the position (ie. the change of the position value)
  92059. */
  92060. deltaPosition: Vector3;
  92061. /**
  92062. * Gets a boolean indicating if the virtual joystick was pressed
  92063. */
  92064. pressed: boolean;
  92065. /**
  92066. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92067. */
  92068. static Canvas: Nullable<HTMLCanvasElement>;
  92069. private static _globalJoystickIndex;
  92070. private static vjCanvasContext;
  92071. private static vjCanvasWidth;
  92072. private static vjCanvasHeight;
  92073. private static halfWidth;
  92074. private _action;
  92075. private _axisTargetedByLeftAndRight;
  92076. private _axisTargetedByUpAndDown;
  92077. private _joystickSensibility;
  92078. private _inversedSensibility;
  92079. private _joystickPointerID;
  92080. private _joystickColor;
  92081. private _joystickPointerPos;
  92082. private _joystickPreviousPointerPos;
  92083. private _joystickPointerStartPos;
  92084. private _deltaJoystickVector;
  92085. private _leftJoystick;
  92086. private _touches;
  92087. private _onPointerDownHandlerRef;
  92088. private _onPointerMoveHandlerRef;
  92089. private _onPointerUpHandlerRef;
  92090. private _onResize;
  92091. /**
  92092. * Creates a new virtual joystick
  92093. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92094. */
  92095. constructor(leftJoystick?: boolean);
  92096. /**
  92097. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92098. * @param newJoystickSensibility defines the new sensibility
  92099. */
  92100. setJoystickSensibility(newJoystickSensibility: number): void;
  92101. private _onPointerDown;
  92102. private _onPointerMove;
  92103. private _onPointerUp;
  92104. /**
  92105. * Change the color of the virtual joystick
  92106. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92107. */
  92108. setJoystickColor(newColor: string): void;
  92109. /**
  92110. * Defines a callback to call when the joystick is touched
  92111. * @param action defines the callback
  92112. */
  92113. setActionOnTouch(action: () => any): void;
  92114. /**
  92115. * Defines which axis you'd like to control for left & right
  92116. * @param axis defines the axis to use
  92117. */
  92118. setAxisForLeftRight(axis: JoystickAxis): void;
  92119. /**
  92120. * Defines which axis you'd like to control for up & down
  92121. * @param axis defines the axis to use
  92122. */
  92123. setAxisForUpDown(axis: JoystickAxis): void;
  92124. private _drawVirtualJoystick;
  92125. /**
  92126. * Release internal HTML canvas
  92127. */
  92128. releaseCanvas(): void;
  92129. }
  92130. }
  92131. declare module BABYLON {
  92132. interface FreeCameraInputsManager {
  92133. /**
  92134. * Add virtual joystick input support to the input manager.
  92135. * @returns the current input manager
  92136. */
  92137. addVirtualJoystick(): FreeCameraInputsManager;
  92138. }
  92139. /**
  92140. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92142. */
  92143. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92144. /**
  92145. * Defines the camera the input is attached to.
  92146. */
  92147. camera: FreeCamera;
  92148. private _leftjoystick;
  92149. private _rightjoystick;
  92150. /**
  92151. * Gets the left stick of the virtual joystick.
  92152. * @returns The virtual Joystick
  92153. */
  92154. getLeftJoystick(): VirtualJoystick;
  92155. /**
  92156. * Gets the right stick of the virtual joystick.
  92157. * @returns The virtual Joystick
  92158. */
  92159. getRightJoystick(): VirtualJoystick;
  92160. /**
  92161. * Update the current camera state depending on the inputs that have been used this frame.
  92162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92163. */
  92164. checkInputs(): void;
  92165. /**
  92166. * Attach the input controls to a specific dom element to get the input from.
  92167. * @param element Defines the element the controls should be listened from
  92168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92169. */
  92170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92171. /**
  92172. * Detach the current controls from the specified dom element.
  92173. * @param element Defines the element to stop listening the inputs from
  92174. */
  92175. detachControl(element: Nullable<HTMLElement>): void;
  92176. /**
  92177. * Gets the class name of the current intput.
  92178. * @returns the class name
  92179. */
  92180. getClassName(): string;
  92181. /**
  92182. * Get the friendly name associated with the input class.
  92183. * @returns the input friendly name
  92184. */
  92185. getSimpleName(): string;
  92186. }
  92187. }
  92188. declare module BABYLON {
  92189. /**
  92190. * This represents a FPS type of camera controlled by touch.
  92191. * This is like a universal camera minus the Gamepad controls.
  92192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92193. */
  92194. export class TouchCamera extends FreeCamera {
  92195. /**
  92196. * Defines the touch sensibility for rotation.
  92197. * The higher the faster.
  92198. */
  92199. touchAngularSensibility: number;
  92200. /**
  92201. * Defines the touch sensibility for move.
  92202. * The higher the faster.
  92203. */
  92204. touchMoveSensibility: number;
  92205. /**
  92206. * Instantiates a new touch camera.
  92207. * This represents a FPS type of camera controlled by touch.
  92208. * This is like a universal camera minus the Gamepad controls.
  92209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92210. * @param name Define the name of the camera in the scene
  92211. * @param position Define the start position of the camera in the scene
  92212. * @param scene Define the scene the camera belongs to
  92213. */
  92214. constructor(name: string, position: Vector3, scene: Scene);
  92215. /**
  92216. * Gets the current object class name.
  92217. * @return the class name
  92218. */
  92219. getClassName(): string;
  92220. /** @hidden */
  92221. _setupInputs(): void;
  92222. }
  92223. }
  92224. declare module BABYLON {
  92225. /**
  92226. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92227. * being tilted forward or back and left or right.
  92228. */
  92229. export class DeviceOrientationCamera extends FreeCamera {
  92230. private _initialQuaternion;
  92231. private _quaternionCache;
  92232. /**
  92233. * Creates a new device orientation camera
  92234. * @param name The name of the camera
  92235. * @param position The start position camera
  92236. * @param scene The scene the camera belongs to
  92237. */
  92238. constructor(name: string, position: Vector3, scene: Scene);
  92239. /**
  92240. * Gets the current instance class name ("DeviceOrientationCamera").
  92241. * This helps avoiding instanceof at run time.
  92242. * @returns the class name
  92243. */
  92244. getClassName(): string;
  92245. /**
  92246. * @hidden
  92247. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92248. */
  92249. _checkInputs(): void;
  92250. /**
  92251. * Reset the camera to its default orientation on the specified axis only.
  92252. * @param axis The axis to reset
  92253. */
  92254. resetToCurrentRotation(axis?: Axis): void;
  92255. }
  92256. }
  92257. declare module BABYLON {
  92258. /**
  92259. * Manage the keyboard inputs to control the movement of a follow camera.
  92260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92261. */
  92262. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92263. /**
  92264. * Defines the camera the input is attached to.
  92265. */
  92266. camera: FollowCamera;
  92267. /**
  92268. * Defines the list of key codes associated with the up action (increase heightOffset)
  92269. */
  92270. keysHeightOffsetIncr: number[];
  92271. /**
  92272. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92273. */
  92274. keysHeightOffsetDecr: number[];
  92275. /**
  92276. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92277. */
  92278. keysHeightOffsetModifierAlt: boolean;
  92279. /**
  92280. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92281. */
  92282. keysHeightOffsetModifierCtrl: boolean;
  92283. /**
  92284. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92285. */
  92286. keysHeightOffsetModifierShift: boolean;
  92287. /**
  92288. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92289. */
  92290. keysRotationOffsetIncr: number[];
  92291. /**
  92292. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92293. */
  92294. keysRotationOffsetDecr: number[];
  92295. /**
  92296. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92297. */
  92298. keysRotationOffsetModifierAlt: boolean;
  92299. /**
  92300. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92301. */
  92302. keysRotationOffsetModifierCtrl: boolean;
  92303. /**
  92304. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92305. */
  92306. keysRotationOffsetModifierShift: boolean;
  92307. /**
  92308. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92309. */
  92310. keysRadiusIncr: number[];
  92311. /**
  92312. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92313. */
  92314. keysRadiusDecr: number[];
  92315. /**
  92316. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92317. */
  92318. keysRadiusModifierAlt: boolean;
  92319. /**
  92320. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92321. */
  92322. keysRadiusModifierCtrl: boolean;
  92323. /**
  92324. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92325. */
  92326. keysRadiusModifierShift: boolean;
  92327. /**
  92328. * Defines the rate of change of heightOffset.
  92329. */
  92330. heightSensibility: number;
  92331. /**
  92332. * Defines the rate of change of rotationOffset.
  92333. */
  92334. rotationSensibility: number;
  92335. /**
  92336. * Defines the rate of change of radius.
  92337. */
  92338. radiusSensibility: number;
  92339. private _keys;
  92340. private _ctrlPressed;
  92341. private _altPressed;
  92342. private _shiftPressed;
  92343. private _onCanvasBlurObserver;
  92344. private _onKeyboardObserver;
  92345. private _engine;
  92346. private _scene;
  92347. /**
  92348. * Attach the input controls to a specific dom element to get the input from.
  92349. * @param element Defines the element the controls should be listened from
  92350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92351. */
  92352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92353. /**
  92354. * Detach the current controls from the specified dom element.
  92355. * @param element Defines the element to stop listening the inputs from
  92356. */
  92357. detachControl(element: Nullable<HTMLElement>): void;
  92358. /**
  92359. * Update the current camera state depending on the inputs that have been used this frame.
  92360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92361. */
  92362. checkInputs(): void;
  92363. /**
  92364. * Gets the class name of the current input.
  92365. * @returns the class name
  92366. */
  92367. getClassName(): string;
  92368. /**
  92369. * Get the friendly name associated with the input class.
  92370. * @returns the input friendly name
  92371. */
  92372. getSimpleName(): string;
  92373. /**
  92374. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92375. * allow modification of the heightOffset value.
  92376. */
  92377. private _modifierHeightOffset;
  92378. /**
  92379. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92380. * allow modification of the rotationOffset value.
  92381. */
  92382. private _modifierRotationOffset;
  92383. /**
  92384. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92385. * allow modification of the radius value.
  92386. */
  92387. private _modifierRadius;
  92388. }
  92389. }
  92390. declare module BABYLON {
  92391. /**
  92392. * Manage the mouse wheel inputs to control a follow camera.
  92393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92394. */
  92395. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92396. /**
  92397. * Defines the camera the input is attached to.
  92398. */
  92399. camera: FollowCamera;
  92400. /**
  92401. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92402. */
  92403. axisControlRadius: boolean;
  92404. /**
  92405. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92406. */
  92407. axisControlHeight: boolean;
  92408. /**
  92409. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92410. */
  92411. axisControlRotation: boolean;
  92412. /**
  92413. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92414. * relation to mouseWheel events.
  92415. */
  92416. wheelPrecision: number;
  92417. /**
  92418. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92419. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92420. */
  92421. wheelDeltaPercentage: number;
  92422. private _wheel;
  92423. private _observer;
  92424. /**
  92425. * Attach the input controls to a specific dom element to get the input from.
  92426. * @param element Defines the element the controls should be listened from
  92427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92428. */
  92429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92430. /**
  92431. * Detach the current controls from the specified dom element.
  92432. * @param element Defines the element to stop listening the inputs from
  92433. */
  92434. detachControl(element: Nullable<HTMLElement>): void;
  92435. /**
  92436. * Gets the class name of the current intput.
  92437. * @returns the class name
  92438. */
  92439. getClassName(): string;
  92440. /**
  92441. * Get the friendly name associated with the input class.
  92442. * @returns the input friendly name
  92443. */
  92444. getSimpleName(): string;
  92445. }
  92446. }
  92447. declare module BABYLON {
  92448. /**
  92449. * Default Inputs manager for the FollowCamera.
  92450. * It groups all the default supported inputs for ease of use.
  92451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92452. */
  92453. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92454. /**
  92455. * Instantiates a new FollowCameraInputsManager.
  92456. * @param camera Defines the camera the inputs belong to
  92457. */
  92458. constructor(camera: FollowCamera);
  92459. /**
  92460. * Add keyboard input support to the input manager.
  92461. * @returns the current input manager
  92462. */
  92463. addKeyboard(): FollowCameraInputsManager;
  92464. /**
  92465. * Add mouse wheel input support to the input manager.
  92466. * @returns the current input manager
  92467. */
  92468. addMouseWheel(): FollowCameraInputsManager;
  92469. /**
  92470. * Add pointers input support to the input manager.
  92471. * @returns the current input manager
  92472. */
  92473. addPointers(): FollowCameraInputsManager;
  92474. /**
  92475. * Add orientation input support to the input manager.
  92476. * @returns the current input manager
  92477. */
  92478. addVRDeviceOrientation(): FollowCameraInputsManager;
  92479. }
  92480. }
  92481. declare module BABYLON {
  92482. /**
  92483. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92484. * an arc rotate version arcFollowCamera are available.
  92485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92486. */
  92487. export class FollowCamera extends TargetCamera {
  92488. /**
  92489. * Distance the follow camera should follow an object at
  92490. */
  92491. radius: number;
  92492. /**
  92493. * Minimum allowed distance of the camera to the axis of rotation
  92494. * (The camera can not get closer).
  92495. * This can help limiting how the Camera is able to move in the scene.
  92496. */
  92497. lowerRadiusLimit: Nullable<number>;
  92498. /**
  92499. * Maximum allowed distance of the camera to the axis of rotation
  92500. * (The camera can not get further).
  92501. * This can help limiting how the Camera is able to move in the scene.
  92502. */
  92503. upperRadiusLimit: Nullable<number>;
  92504. /**
  92505. * Define a rotation offset between the camera and the object it follows
  92506. */
  92507. rotationOffset: number;
  92508. /**
  92509. * Minimum allowed angle to camera position relative to target object.
  92510. * This can help limiting how the Camera is able to move in the scene.
  92511. */
  92512. lowerRotationOffsetLimit: Nullable<number>;
  92513. /**
  92514. * Maximum allowed angle to camera position relative to target object.
  92515. * This can help limiting how the Camera is able to move in the scene.
  92516. */
  92517. upperRotationOffsetLimit: Nullable<number>;
  92518. /**
  92519. * Define a height offset between the camera and the object it follows.
  92520. * It can help following an object from the top (like a car chaing a plane)
  92521. */
  92522. heightOffset: number;
  92523. /**
  92524. * Minimum allowed height of camera position relative to target object.
  92525. * This can help limiting how the Camera is able to move in the scene.
  92526. */
  92527. lowerHeightOffsetLimit: Nullable<number>;
  92528. /**
  92529. * Maximum allowed height of camera position relative to target object.
  92530. * This can help limiting how the Camera is able to move in the scene.
  92531. */
  92532. upperHeightOffsetLimit: Nullable<number>;
  92533. /**
  92534. * Define how fast the camera can accelerate to follow it s target.
  92535. */
  92536. cameraAcceleration: number;
  92537. /**
  92538. * Define the speed limit of the camera following an object.
  92539. */
  92540. maxCameraSpeed: number;
  92541. /**
  92542. * Define the target of the camera.
  92543. */
  92544. lockedTarget: Nullable<AbstractMesh>;
  92545. /**
  92546. * Defines the input associated with the camera.
  92547. */
  92548. inputs: FollowCameraInputsManager;
  92549. /**
  92550. * Instantiates the follow camera.
  92551. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92552. * @param name Define the name of the camera in the scene
  92553. * @param position Define the position of the camera
  92554. * @param scene Define the scene the camera belong to
  92555. * @param lockedTarget Define the target of the camera
  92556. */
  92557. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92558. private _follow;
  92559. /**
  92560. * Attached controls to the current camera.
  92561. * @param element Defines the element the controls should be listened from
  92562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92563. */
  92564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92565. /**
  92566. * Detach the current controls from the camera.
  92567. * The camera will stop reacting to inputs.
  92568. * @param element Defines the element to stop listening the inputs from
  92569. */
  92570. detachControl(element: HTMLElement): void;
  92571. /** @hidden */
  92572. _checkInputs(): void;
  92573. private _checkLimits;
  92574. /**
  92575. * Gets the camera class name.
  92576. * @returns the class name
  92577. */
  92578. getClassName(): string;
  92579. }
  92580. /**
  92581. * Arc Rotate version of the follow camera.
  92582. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92583. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92584. */
  92585. export class ArcFollowCamera extends TargetCamera {
  92586. /** The longitudinal angle of the camera */
  92587. alpha: number;
  92588. /** The latitudinal angle of the camera */
  92589. beta: number;
  92590. /** The radius of the camera from its target */
  92591. radius: number;
  92592. /** Define the camera target (the messh it should follow) */
  92593. target: Nullable<AbstractMesh>;
  92594. private _cartesianCoordinates;
  92595. /**
  92596. * Instantiates a new ArcFollowCamera
  92597. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92598. * @param name Define the name of the camera
  92599. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92600. * @param beta Define the rotation angle of the camera around the elevation axis
  92601. * @param radius Define the radius of the camera from its target point
  92602. * @param target Define the target of the camera
  92603. * @param scene Define the scene the camera belongs to
  92604. */
  92605. constructor(name: string,
  92606. /** The longitudinal angle of the camera */
  92607. alpha: number,
  92608. /** The latitudinal angle of the camera */
  92609. beta: number,
  92610. /** The radius of the camera from its target */
  92611. radius: number,
  92612. /** Define the camera target (the messh it should follow) */
  92613. target: Nullable<AbstractMesh>, scene: Scene);
  92614. private _follow;
  92615. /** @hidden */
  92616. _checkInputs(): void;
  92617. /**
  92618. * Returns the class name of the object.
  92619. * It is mostly used internally for serialization purposes.
  92620. */
  92621. getClassName(): string;
  92622. }
  92623. }
  92624. declare module BABYLON {
  92625. /**
  92626. * 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,
  92627. * which still works and will still be found in many Playgrounds.
  92628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92629. */
  92630. export class UniversalCamera extends TouchCamera {
  92631. /**
  92632. * Defines the gamepad rotation sensiblity.
  92633. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92634. */
  92635. gamepadAngularSensibility: number;
  92636. /**
  92637. * Defines the gamepad move sensiblity.
  92638. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92639. */
  92640. gamepadMoveSensibility: number;
  92641. /**
  92642. * 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,
  92643. * which still works and will still be found in many Playgrounds.
  92644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92645. * @param name Define the name of the camera in the scene
  92646. * @param position Define the start position of the camera in the scene
  92647. * @param scene Define the scene the camera belongs to
  92648. */
  92649. constructor(name: string, position: Vector3, scene: Scene);
  92650. /**
  92651. * Gets the current object class name.
  92652. * @return the class name
  92653. */
  92654. getClassName(): string;
  92655. }
  92656. }
  92657. declare module BABYLON {
  92658. /**
  92659. * This represents a FPS type of camera. This is only here for back compat purpose.
  92660. * Please use the UniversalCamera instead as both are identical.
  92661. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92662. */
  92663. export class GamepadCamera extends UniversalCamera {
  92664. /**
  92665. * Instantiates a new Gamepad Camera
  92666. * This represents a FPS type of camera. This is only here for back compat purpose.
  92667. * Please use the UniversalCamera instead as both are identical.
  92668. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92669. * @param name Define the name of the camera in the scene
  92670. * @param position Define the start position of the camera in the scene
  92671. * @param scene Define the scene the camera belongs to
  92672. */
  92673. constructor(name: string, position: Vector3, scene: Scene);
  92674. /**
  92675. * Gets the current object class name.
  92676. * @return the class name
  92677. */
  92678. getClassName(): string;
  92679. }
  92680. }
  92681. declare module BABYLON {
  92682. /** @hidden */
  92683. export var passPixelShader: {
  92684. name: string;
  92685. shader: string;
  92686. };
  92687. }
  92688. declare module BABYLON {
  92689. /** @hidden */
  92690. export var passCubePixelShader: {
  92691. name: string;
  92692. shader: string;
  92693. };
  92694. }
  92695. declare module BABYLON {
  92696. /**
  92697. * PassPostProcess which produces an output the same as it's input
  92698. */
  92699. export class PassPostProcess extends PostProcess {
  92700. /**
  92701. * Creates the PassPostProcess
  92702. * @param name The name of the effect.
  92703. * @param options The required width/height ratio to downsize to before computing the render pass.
  92704. * @param camera The camera to apply the render pass to.
  92705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92706. * @param engine The engine which the post process will be applied. (default: current engine)
  92707. * @param reusable If the post process can be reused on the same frame. (default: false)
  92708. * @param textureType The type of texture to be used when performing the post processing.
  92709. * @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)
  92710. */
  92711. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92712. }
  92713. /**
  92714. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92715. */
  92716. export class PassCubePostProcess extends PostProcess {
  92717. private _face;
  92718. /**
  92719. * Gets or sets the cube face to display.
  92720. * * 0 is +X
  92721. * * 1 is -X
  92722. * * 2 is +Y
  92723. * * 3 is -Y
  92724. * * 4 is +Z
  92725. * * 5 is -Z
  92726. */
  92727. face: number;
  92728. /**
  92729. * Creates the PassCubePostProcess
  92730. * @param name The name of the effect.
  92731. * @param options The required width/height ratio to downsize to before computing the render pass.
  92732. * @param camera The camera to apply the render pass to.
  92733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92734. * @param engine The engine which the post process will be applied. (default: current engine)
  92735. * @param reusable If the post process can be reused on the same frame. (default: false)
  92736. * @param textureType The type of texture to be used when performing the post processing.
  92737. * @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)
  92738. */
  92739. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. /** @hidden */
  92744. export var anaglyphPixelShader: {
  92745. name: string;
  92746. shader: string;
  92747. };
  92748. }
  92749. declare module BABYLON {
  92750. /**
  92751. * Postprocess used to generate anaglyphic rendering
  92752. */
  92753. export class AnaglyphPostProcess extends PostProcess {
  92754. private _passedProcess;
  92755. /**
  92756. * Creates a new AnaglyphPostProcess
  92757. * @param name defines postprocess name
  92758. * @param options defines creation options or target ratio scale
  92759. * @param rigCameras defines cameras using this postprocess
  92760. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92761. * @param engine defines hosting engine
  92762. * @param reusable defines if the postprocess will be reused multiple times per frame
  92763. */
  92764. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92765. }
  92766. }
  92767. declare module BABYLON {
  92768. /**
  92769. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92770. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92771. */
  92772. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92773. /**
  92774. * Creates a new AnaglyphArcRotateCamera
  92775. * @param name defines camera name
  92776. * @param alpha defines alpha angle (in radians)
  92777. * @param beta defines beta angle (in radians)
  92778. * @param radius defines radius
  92779. * @param target defines camera target
  92780. * @param interaxialDistance defines distance between each color axis
  92781. * @param scene defines the hosting scene
  92782. */
  92783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92784. /**
  92785. * Gets camera class name
  92786. * @returns AnaglyphArcRotateCamera
  92787. */
  92788. getClassName(): string;
  92789. }
  92790. }
  92791. declare module BABYLON {
  92792. /**
  92793. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92794. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92795. */
  92796. export class AnaglyphFreeCamera extends FreeCamera {
  92797. /**
  92798. * Creates a new AnaglyphFreeCamera
  92799. * @param name defines camera name
  92800. * @param position defines initial position
  92801. * @param interaxialDistance defines distance between each color axis
  92802. * @param scene defines the hosting scene
  92803. */
  92804. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92805. /**
  92806. * Gets camera class name
  92807. * @returns AnaglyphFreeCamera
  92808. */
  92809. getClassName(): string;
  92810. }
  92811. }
  92812. declare module BABYLON {
  92813. /**
  92814. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92815. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92816. */
  92817. export class AnaglyphGamepadCamera extends GamepadCamera {
  92818. /**
  92819. * Creates a new AnaglyphGamepadCamera
  92820. * @param name defines camera name
  92821. * @param position defines initial position
  92822. * @param interaxialDistance defines distance between each color axis
  92823. * @param scene defines the hosting scene
  92824. */
  92825. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92826. /**
  92827. * Gets camera class name
  92828. * @returns AnaglyphGamepadCamera
  92829. */
  92830. getClassName(): string;
  92831. }
  92832. }
  92833. declare module BABYLON {
  92834. /**
  92835. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92836. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92837. */
  92838. export class AnaglyphUniversalCamera extends UniversalCamera {
  92839. /**
  92840. * Creates a new AnaglyphUniversalCamera
  92841. * @param name defines camera name
  92842. * @param position defines initial position
  92843. * @param interaxialDistance defines distance between each color axis
  92844. * @param scene defines the hosting scene
  92845. */
  92846. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92847. /**
  92848. * Gets camera class name
  92849. * @returns AnaglyphUniversalCamera
  92850. */
  92851. getClassName(): string;
  92852. }
  92853. }
  92854. declare module BABYLON {
  92855. /** @hidden */
  92856. export var stereoscopicInterlacePixelShader: {
  92857. name: string;
  92858. shader: string;
  92859. };
  92860. }
  92861. declare module BABYLON {
  92862. /**
  92863. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92864. */
  92865. export class StereoscopicInterlacePostProcess extends PostProcess {
  92866. private _stepSize;
  92867. private _passedProcess;
  92868. /**
  92869. * Initializes a StereoscopicInterlacePostProcess
  92870. * @param name The name of the effect.
  92871. * @param rigCameras The rig cameras to be appled to the post process
  92872. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92874. * @param engine The engine which the post process will be applied. (default: current engine)
  92875. * @param reusable If the post process can be reused on the same frame. (default: false)
  92876. */
  92877. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92878. }
  92879. }
  92880. declare module BABYLON {
  92881. /**
  92882. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92883. * @see http://doc.babylonjs.com/features/cameras
  92884. */
  92885. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92886. /**
  92887. * Creates a new StereoscopicArcRotateCamera
  92888. * @param name defines camera name
  92889. * @param alpha defines alpha angle (in radians)
  92890. * @param beta defines beta angle (in radians)
  92891. * @param radius defines radius
  92892. * @param target defines camera target
  92893. * @param interaxialDistance defines distance between each color axis
  92894. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92895. * @param scene defines the hosting scene
  92896. */
  92897. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92898. /**
  92899. * Gets camera class name
  92900. * @returns StereoscopicArcRotateCamera
  92901. */
  92902. getClassName(): string;
  92903. }
  92904. }
  92905. declare module BABYLON {
  92906. /**
  92907. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92908. * @see http://doc.babylonjs.com/features/cameras
  92909. */
  92910. export class StereoscopicFreeCamera extends FreeCamera {
  92911. /**
  92912. * Creates a new StereoscopicFreeCamera
  92913. * @param name defines camera name
  92914. * @param position defines initial position
  92915. * @param interaxialDistance defines distance between each color axis
  92916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92917. * @param scene defines the hosting scene
  92918. */
  92919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92920. /**
  92921. * Gets camera class name
  92922. * @returns StereoscopicFreeCamera
  92923. */
  92924. getClassName(): string;
  92925. }
  92926. }
  92927. declare module BABYLON {
  92928. /**
  92929. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  92930. * @see http://doc.babylonjs.com/features/cameras
  92931. */
  92932. export class StereoscopicGamepadCamera extends GamepadCamera {
  92933. /**
  92934. * Creates a new StereoscopicGamepadCamera
  92935. * @param name defines camera name
  92936. * @param position defines initial position
  92937. * @param interaxialDistance defines distance between each color axis
  92938. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92939. * @param scene defines the hosting scene
  92940. */
  92941. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92942. /**
  92943. * Gets camera class name
  92944. * @returns StereoscopicGamepadCamera
  92945. */
  92946. getClassName(): string;
  92947. }
  92948. }
  92949. declare module BABYLON {
  92950. /**
  92951. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  92952. * @see http://doc.babylonjs.com/features/cameras
  92953. */
  92954. export class StereoscopicUniversalCamera extends UniversalCamera {
  92955. /**
  92956. * Creates a new StereoscopicUniversalCamera
  92957. * @param name defines camera name
  92958. * @param position defines initial position
  92959. * @param interaxialDistance defines distance between each color axis
  92960. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92961. * @param scene defines the hosting scene
  92962. */
  92963. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92964. /**
  92965. * Gets camera class name
  92966. * @returns StereoscopicUniversalCamera
  92967. */
  92968. getClassName(): string;
  92969. }
  92970. }
  92971. declare module BABYLON {
  92972. /**
  92973. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92974. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92975. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92976. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92977. */
  92978. export class VirtualJoysticksCamera extends FreeCamera {
  92979. /**
  92980. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  92981. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92982. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92983. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92984. * @param name Define the name of the camera in the scene
  92985. * @param position Define the start position of the camera in the scene
  92986. * @param scene Define the scene the camera belongs to
  92987. */
  92988. constructor(name: string, position: Vector3, scene: Scene);
  92989. /**
  92990. * Gets the current object class name.
  92991. * @return the class name
  92992. */
  92993. getClassName(): string;
  92994. }
  92995. }
  92996. declare module BABYLON {
  92997. /**
  92998. * This represents all the required metrics to create a VR camera.
  92999. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93000. */
  93001. export class VRCameraMetrics {
  93002. /**
  93003. * Define the horizontal resolution off the screen.
  93004. */
  93005. hResolution: number;
  93006. /**
  93007. * Define the vertical resolution off the screen.
  93008. */
  93009. vResolution: number;
  93010. /**
  93011. * Define the horizontal screen size.
  93012. */
  93013. hScreenSize: number;
  93014. /**
  93015. * Define the vertical screen size.
  93016. */
  93017. vScreenSize: number;
  93018. /**
  93019. * Define the vertical screen center position.
  93020. */
  93021. vScreenCenter: number;
  93022. /**
  93023. * Define the distance of the eyes to the screen.
  93024. */
  93025. eyeToScreenDistance: number;
  93026. /**
  93027. * Define the distance between both lenses
  93028. */
  93029. lensSeparationDistance: number;
  93030. /**
  93031. * Define the distance between both viewer's eyes.
  93032. */
  93033. interpupillaryDistance: number;
  93034. /**
  93035. * Define the distortion factor of the VR postprocess.
  93036. * Please, touch with care.
  93037. */
  93038. distortionK: number[];
  93039. /**
  93040. * Define the chromatic aberration correction factors for the VR post process.
  93041. */
  93042. chromaAbCorrection: number[];
  93043. /**
  93044. * Define the scale factor of the post process.
  93045. * The smaller the better but the slower.
  93046. */
  93047. postProcessScaleFactor: number;
  93048. /**
  93049. * Define an offset for the lens center.
  93050. */
  93051. lensCenterOffset: number;
  93052. /**
  93053. * Define if the current vr camera should compensate the distortion of the lense or not.
  93054. */
  93055. compensateDistortion: boolean;
  93056. /**
  93057. * Gets the rendering aspect ratio based on the provided resolutions.
  93058. */
  93059. readonly aspectRatio: number;
  93060. /**
  93061. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93062. */
  93063. readonly aspectRatioFov: number;
  93064. /**
  93065. * @hidden
  93066. */
  93067. readonly leftHMatrix: Matrix;
  93068. /**
  93069. * @hidden
  93070. */
  93071. readonly rightHMatrix: Matrix;
  93072. /**
  93073. * @hidden
  93074. */
  93075. readonly leftPreViewMatrix: Matrix;
  93076. /**
  93077. * @hidden
  93078. */
  93079. readonly rightPreViewMatrix: Matrix;
  93080. /**
  93081. * Get the default VRMetrics based on the most generic setup.
  93082. * @returns the default vr metrics
  93083. */
  93084. static GetDefault(): VRCameraMetrics;
  93085. }
  93086. }
  93087. declare module BABYLON {
  93088. /** @hidden */
  93089. export var vrDistortionCorrectionPixelShader: {
  93090. name: string;
  93091. shader: string;
  93092. };
  93093. }
  93094. declare module BABYLON {
  93095. /**
  93096. * VRDistortionCorrectionPostProcess used for mobile VR
  93097. */
  93098. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93099. private _isRightEye;
  93100. private _distortionFactors;
  93101. private _postProcessScaleFactor;
  93102. private _lensCenterOffset;
  93103. private _scaleIn;
  93104. private _scaleFactor;
  93105. private _lensCenter;
  93106. /**
  93107. * Initializes the VRDistortionCorrectionPostProcess
  93108. * @param name The name of the effect.
  93109. * @param camera The camera to apply the render pass to.
  93110. * @param isRightEye If this is for the right eye distortion
  93111. * @param vrMetrics All the required metrics for the VR camera
  93112. */
  93113. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93114. }
  93115. }
  93116. declare module BABYLON {
  93117. /**
  93118. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93119. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93120. */
  93121. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93122. /**
  93123. * Creates a new VRDeviceOrientationArcRotateCamera
  93124. * @param name defines camera name
  93125. * @param alpha defines the camera rotation along the logitudinal axis
  93126. * @param beta defines the camera rotation along the latitudinal axis
  93127. * @param radius defines the camera distance from its target
  93128. * @param target defines the camera target
  93129. * @param scene defines the scene the camera belongs to
  93130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93132. */
  93133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93134. /**
  93135. * Gets camera class name
  93136. * @returns VRDeviceOrientationArcRotateCamera
  93137. */
  93138. getClassName(): string;
  93139. }
  93140. }
  93141. declare module BABYLON {
  93142. /**
  93143. * Camera used to simulate VR rendering (based on FreeCamera)
  93144. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93145. */
  93146. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93147. /**
  93148. * Creates a new VRDeviceOrientationFreeCamera
  93149. * @param name defines camera name
  93150. * @param position defines the start position of the camera
  93151. * @param scene defines the scene the camera belongs to
  93152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93154. */
  93155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93156. /**
  93157. * Gets camera class name
  93158. * @returns VRDeviceOrientationFreeCamera
  93159. */
  93160. getClassName(): string;
  93161. }
  93162. }
  93163. declare module BABYLON {
  93164. /**
  93165. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93166. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93167. */
  93168. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93169. /**
  93170. * Creates a new VRDeviceOrientationGamepadCamera
  93171. * @param name defines camera name
  93172. * @param position defines the start position of the camera
  93173. * @param scene defines the scene the camera belongs to
  93174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93176. */
  93177. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93178. /**
  93179. * Gets camera class name
  93180. * @returns VRDeviceOrientationGamepadCamera
  93181. */
  93182. getClassName(): string;
  93183. }
  93184. }
  93185. declare module BABYLON {
  93186. /**
  93187. * Defines supported buttons for XBox360 compatible gamepads
  93188. */
  93189. export enum Xbox360Button {
  93190. /** A */
  93191. A = 0,
  93192. /** B */
  93193. B = 1,
  93194. /** X */
  93195. X = 2,
  93196. /** Y */
  93197. Y = 3,
  93198. /** Start */
  93199. Start = 4,
  93200. /** Back */
  93201. Back = 5,
  93202. /** Left button */
  93203. LB = 6,
  93204. /** Right button */
  93205. RB = 7,
  93206. /** Left stick */
  93207. LeftStick = 8,
  93208. /** Right stick */
  93209. RightStick = 9
  93210. }
  93211. /** Defines values for XBox360 DPad */
  93212. export enum Xbox360Dpad {
  93213. /** Up */
  93214. Up = 0,
  93215. /** Down */
  93216. Down = 1,
  93217. /** Left */
  93218. Left = 2,
  93219. /** Right */
  93220. Right = 3
  93221. }
  93222. /**
  93223. * Defines a XBox360 gamepad
  93224. */
  93225. export class Xbox360Pad extends Gamepad {
  93226. private _leftTrigger;
  93227. private _rightTrigger;
  93228. private _onlefttriggerchanged;
  93229. private _onrighttriggerchanged;
  93230. private _onbuttondown;
  93231. private _onbuttonup;
  93232. private _ondpaddown;
  93233. private _ondpadup;
  93234. /** Observable raised when a button is pressed */
  93235. onButtonDownObservable: Observable<Xbox360Button>;
  93236. /** Observable raised when a button is released */
  93237. onButtonUpObservable: Observable<Xbox360Button>;
  93238. /** Observable raised when a pad is pressed */
  93239. onPadDownObservable: Observable<Xbox360Dpad>;
  93240. /** Observable raised when a pad is released */
  93241. onPadUpObservable: Observable<Xbox360Dpad>;
  93242. private _buttonA;
  93243. private _buttonB;
  93244. private _buttonX;
  93245. private _buttonY;
  93246. private _buttonBack;
  93247. private _buttonStart;
  93248. private _buttonLB;
  93249. private _buttonRB;
  93250. private _buttonLeftStick;
  93251. private _buttonRightStick;
  93252. private _dPadUp;
  93253. private _dPadDown;
  93254. private _dPadLeft;
  93255. private _dPadRight;
  93256. private _isXboxOnePad;
  93257. /**
  93258. * Creates a new XBox360 gamepad object
  93259. * @param id defines the id of this gamepad
  93260. * @param index defines its index
  93261. * @param gamepad defines the internal HTML gamepad object
  93262. * @param xboxOne defines if it is a XBox One gamepad
  93263. */
  93264. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93265. /**
  93266. * Defines the callback to call when left trigger is pressed
  93267. * @param callback defines the callback to use
  93268. */
  93269. onlefttriggerchanged(callback: (value: number) => void): void;
  93270. /**
  93271. * Defines the callback to call when right trigger is pressed
  93272. * @param callback defines the callback to use
  93273. */
  93274. onrighttriggerchanged(callback: (value: number) => void): void;
  93275. /**
  93276. * Gets the left trigger value
  93277. */
  93278. /**
  93279. * Sets the left trigger value
  93280. */
  93281. leftTrigger: number;
  93282. /**
  93283. * Gets the right trigger value
  93284. */
  93285. /**
  93286. * Sets the right trigger value
  93287. */
  93288. rightTrigger: number;
  93289. /**
  93290. * Defines the callback to call when a button is pressed
  93291. * @param callback defines the callback to use
  93292. */
  93293. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93294. /**
  93295. * Defines the callback to call when a button is released
  93296. * @param callback defines the callback to use
  93297. */
  93298. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93299. /**
  93300. * Defines the callback to call when a pad is pressed
  93301. * @param callback defines the callback to use
  93302. */
  93303. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93304. /**
  93305. * Defines the callback to call when a pad is released
  93306. * @param callback defines the callback to use
  93307. */
  93308. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93309. private _setButtonValue;
  93310. private _setDPadValue;
  93311. /**
  93312. * Gets the value of the `A` button
  93313. */
  93314. /**
  93315. * Sets the value of the `A` button
  93316. */
  93317. buttonA: number;
  93318. /**
  93319. * Gets the value of the `B` button
  93320. */
  93321. /**
  93322. * Sets the value of the `B` button
  93323. */
  93324. buttonB: number;
  93325. /**
  93326. * Gets the value of the `X` button
  93327. */
  93328. /**
  93329. * Sets the value of the `X` button
  93330. */
  93331. buttonX: number;
  93332. /**
  93333. * Gets the value of the `Y` button
  93334. */
  93335. /**
  93336. * Sets the value of the `Y` button
  93337. */
  93338. buttonY: number;
  93339. /**
  93340. * Gets the value of the `Start` button
  93341. */
  93342. /**
  93343. * Sets the value of the `Start` button
  93344. */
  93345. buttonStart: number;
  93346. /**
  93347. * Gets the value of the `Back` button
  93348. */
  93349. /**
  93350. * Sets the value of the `Back` button
  93351. */
  93352. buttonBack: number;
  93353. /**
  93354. * Gets the value of the `Left` button
  93355. */
  93356. /**
  93357. * Sets the value of the `Left` button
  93358. */
  93359. buttonLB: number;
  93360. /**
  93361. * Gets the value of the `Right` button
  93362. */
  93363. /**
  93364. * Sets the value of the `Right` button
  93365. */
  93366. buttonRB: number;
  93367. /**
  93368. * Gets the value of the Left joystick
  93369. */
  93370. /**
  93371. * Sets the value of the Left joystick
  93372. */
  93373. buttonLeftStick: number;
  93374. /**
  93375. * Gets the value of the Right joystick
  93376. */
  93377. /**
  93378. * Sets the value of the Right joystick
  93379. */
  93380. buttonRightStick: number;
  93381. /**
  93382. * Gets the value of D-pad up
  93383. */
  93384. /**
  93385. * Sets the value of D-pad up
  93386. */
  93387. dPadUp: number;
  93388. /**
  93389. * Gets the value of D-pad down
  93390. */
  93391. /**
  93392. * Sets the value of D-pad down
  93393. */
  93394. dPadDown: number;
  93395. /**
  93396. * Gets the value of D-pad left
  93397. */
  93398. /**
  93399. * Sets the value of D-pad left
  93400. */
  93401. dPadLeft: number;
  93402. /**
  93403. * Gets the value of D-pad right
  93404. */
  93405. /**
  93406. * Sets the value of D-pad right
  93407. */
  93408. dPadRight: number;
  93409. /**
  93410. * Force the gamepad to synchronize with device values
  93411. */
  93412. update(): void;
  93413. /**
  93414. * Disposes the gamepad
  93415. */
  93416. dispose(): void;
  93417. }
  93418. }
  93419. declare module BABYLON {
  93420. /**
  93421. * Base class of materials working in push mode in babylon JS
  93422. * @hidden
  93423. */
  93424. export class PushMaterial extends Material {
  93425. protected _activeEffect: Effect;
  93426. protected _normalMatrix: Matrix;
  93427. /**
  93428. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93429. * This means that the material can keep using a previous shader while a new one is being compiled.
  93430. * This is mostly used when shader parallel compilation is supported (true by default)
  93431. */
  93432. allowShaderHotSwapping: boolean;
  93433. constructor(name: string, scene: Scene);
  93434. getEffect(): Effect;
  93435. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93436. /**
  93437. * Binds the given world matrix to the active effect
  93438. *
  93439. * @param world the matrix to bind
  93440. */
  93441. bindOnlyWorldMatrix(world: Matrix): void;
  93442. /**
  93443. * Binds the given normal matrix to the active effect
  93444. *
  93445. * @param normalMatrix the matrix to bind
  93446. */
  93447. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93448. bind(world: Matrix, mesh?: Mesh): void;
  93449. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93450. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93451. }
  93452. }
  93453. declare module BABYLON {
  93454. /**
  93455. * This groups all the flags used to control the materials channel.
  93456. */
  93457. export class MaterialFlags {
  93458. private static _DiffuseTextureEnabled;
  93459. /**
  93460. * Are diffuse textures enabled in the application.
  93461. */
  93462. static DiffuseTextureEnabled: boolean;
  93463. private static _AmbientTextureEnabled;
  93464. /**
  93465. * Are ambient textures enabled in the application.
  93466. */
  93467. static AmbientTextureEnabled: boolean;
  93468. private static _OpacityTextureEnabled;
  93469. /**
  93470. * Are opacity textures enabled in the application.
  93471. */
  93472. static OpacityTextureEnabled: boolean;
  93473. private static _ReflectionTextureEnabled;
  93474. /**
  93475. * Are reflection textures enabled in the application.
  93476. */
  93477. static ReflectionTextureEnabled: boolean;
  93478. private static _EmissiveTextureEnabled;
  93479. /**
  93480. * Are emissive textures enabled in the application.
  93481. */
  93482. static EmissiveTextureEnabled: boolean;
  93483. private static _SpecularTextureEnabled;
  93484. /**
  93485. * Are specular textures enabled in the application.
  93486. */
  93487. static SpecularTextureEnabled: boolean;
  93488. private static _BumpTextureEnabled;
  93489. /**
  93490. * Are bump textures enabled in the application.
  93491. */
  93492. static BumpTextureEnabled: boolean;
  93493. private static _LightmapTextureEnabled;
  93494. /**
  93495. * Are lightmap textures enabled in the application.
  93496. */
  93497. static LightmapTextureEnabled: boolean;
  93498. private static _RefractionTextureEnabled;
  93499. /**
  93500. * Are refraction textures enabled in the application.
  93501. */
  93502. static RefractionTextureEnabled: boolean;
  93503. private static _ColorGradingTextureEnabled;
  93504. /**
  93505. * Are color grading textures enabled in the application.
  93506. */
  93507. static ColorGradingTextureEnabled: boolean;
  93508. private static _FresnelEnabled;
  93509. /**
  93510. * Are fresnels enabled in the application.
  93511. */
  93512. static FresnelEnabled: boolean;
  93513. }
  93514. }
  93515. declare module BABYLON {
  93516. /** @hidden */
  93517. export var defaultFragmentDeclaration: {
  93518. name: string;
  93519. shader: string;
  93520. };
  93521. }
  93522. declare module BABYLON {
  93523. /** @hidden */
  93524. export var defaultUboDeclaration: {
  93525. name: string;
  93526. shader: string;
  93527. };
  93528. }
  93529. declare module BABYLON {
  93530. /** @hidden */
  93531. export var lightFragmentDeclaration: {
  93532. name: string;
  93533. shader: string;
  93534. };
  93535. }
  93536. declare module BABYLON {
  93537. /** @hidden */
  93538. export var lightUboDeclaration: {
  93539. name: string;
  93540. shader: string;
  93541. };
  93542. }
  93543. declare module BABYLON {
  93544. /** @hidden */
  93545. export var lightsFragmentFunctions: {
  93546. name: string;
  93547. shader: string;
  93548. };
  93549. }
  93550. declare module BABYLON {
  93551. /** @hidden */
  93552. export var shadowsFragmentFunctions: {
  93553. name: string;
  93554. shader: string;
  93555. };
  93556. }
  93557. declare module BABYLON {
  93558. /** @hidden */
  93559. export var fresnelFunction: {
  93560. name: string;
  93561. shader: string;
  93562. };
  93563. }
  93564. declare module BABYLON {
  93565. /** @hidden */
  93566. export var reflectionFunction: {
  93567. name: string;
  93568. shader: string;
  93569. };
  93570. }
  93571. declare module BABYLON {
  93572. /** @hidden */
  93573. export var bumpFragmentFunctions: {
  93574. name: string;
  93575. shader: string;
  93576. };
  93577. }
  93578. declare module BABYLON {
  93579. /** @hidden */
  93580. export var logDepthDeclaration: {
  93581. name: string;
  93582. shader: string;
  93583. };
  93584. }
  93585. declare module BABYLON {
  93586. /** @hidden */
  93587. export var bumpFragment: {
  93588. name: string;
  93589. shader: string;
  93590. };
  93591. }
  93592. declare module BABYLON {
  93593. /** @hidden */
  93594. export var depthPrePass: {
  93595. name: string;
  93596. shader: string;
  93597. };
  93598. }
  93599. declare module BABYLON {
  93600. /** @hidden */
  93601. export var lightFragment: {
  93602. name: string;
  93603. shader: string;
  93604. };
  93605. }
  93606. declare module BABYLON {
  93607. /** @hidden */
  93608. export var logDepthFragment: {
  93609. name: string;
  93610. shader: string;
  93611. };
  93612. }
  93613. declare module BABYLON {
  93614. /** @hidden */
  93615. export var defaultPixelShader: {
  93616. name: string;
  93617. shader: string;
  93618. };
  93619. }
  93620. declare module BABYLON {
  93621. /** @hidden */
  93622. export var defaultVertexDeclaration: {
  93623. name: string;
  93624. shader: string;
  93625. };
  93626. }
  93627. declare module BABYLON {
  93628. /** @hidden */
  93629. export var bumpVertexDeclaration: {
  93630. name: string;
  93631. shader: string;
  93632. };
  93633. }
  93634. declare module BABYLON {
  93635. /** @hidden */
  93636. export var bumpVertex: {
  93637. name: string;
  93638. shader: string;
  93639. };
  93640. }
  93641. declare module BABYLON {
  93642. /** @hidden */
  93643. export var fogVertex: {
  93644. name: string;
  93645. shader: string;
  93646. };
  93647. }
  93648. declare module BABYLON {
  93649. /** @hidden */
  93650. export var shadowsVertex: {
  93651. name: string;
  93652. shader: string;
  93653. };
  93654. }
  93655. declare module BABYLON {
  93656. /** @hidden */
  93657. export var pointCloudVertex: {
  93658. name: string;
  93659. shader: string;
  93660. };
  93661. }
  93662. declare module BABYLON {
  93663. /** @hidden */
  93664. export var logDepthVertex: {
  93665. name: string;
  93666. shader: string;
  93667. };
  93668. }
  93669. declare module BABYLON {
  93670. /** @hidden */
  93671. export var defaultVertexShader: {
  93672. name: string;
  93673. shader: string;
  93674. };
  93675. }
  93676. declare module BABYLON {
  93677. /** @hidden */
  93678. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93679. MAINUV1: boolean;
  93680. MAINUV2: boolean;
  93681. DIFFUSE: boolean;
  93682. DIFFUSEDIRECTUV: number;
  93683. AMBIENT: boolean;
  93684. AMBIENTDIRECTUV: number;
  93685. OPACITY: boolean;
  93686. OPACITYDIRECTUV: number;
  93687. OPACITYRGB: boolean;
  93688. REFLECTION: boolean;
  93689. EMISSIVE: boolean;
  93690. EMISSIVEDIRECTUV: number;
  93691. SPECULAR: boolean;
  93692. SPECULARDIRECTUV: number;
  93693. BUMP: boolean;
  93694. BUMPDIRECTUV: number;
  93695. PARALLAX: boolean;
  93696. PARALLAXOCCLUSION: boolean;
  93697. SPECULAROVERALPHA: boolean;
  93698. CLIPPLANE: boolean;
  93699. CLIPPLANE2: boolean;
  93700. CLIPPLANE3: boolean;
  93701. CLIPPLANE4: boolean;
  93702. ALPHATEST: boolean;
  93703. DEPTHPREPASS: boolean;
  93704. ALPHAFROMDIFFUSE: boolean;
  93705. POINTSIZE: boolean;
  93706. FOG: boolean;
  93707. SPECULARTERM: boolean;
  93708. DIFFUSEFRESNEL: boolean;
  93709. OPACITYFRESNEL: boolean;
  93710. REFLECTIONFRESNEL: boolean;
  93711. REFRACTIONFRESNEL: boolean;
  93712. EMISSIVEFRESNEL: boolean;
  93713. FRESNEL: boolean;
  93714. NORMAL: boolean;
  93715. UV1: boolean;
  93716. UV2: boolean;
  93717. VERTEXCOLOR: boolean;
  93718. VERTEXALPHA: boolean;
  93719. NUM_BONE_INFLUENCERS: number;
  93720. BonesPerMesh: number;
  93721. BONETEXTURE: boolean;
  93722. INSTANCES: boolean;
  93723. GLOSSINESS: boolean;
  93724. ROUGHNESS: boolean;
  93725. EMISSIVEASILLUMINATION: boolean;
  93726. LINKEMISSIVEWITHDIFFUSE: boolean;
  93727. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93728. LIGHTMAP: boolean;
  93729. LIGHTMAPDIRECTUV: number;
  93730. OBJECTSPACE_NORMALMAP: boolean;
  93731. USELIGHTMAPASSHADOWMAP: boolean;
  93732. REFLECTIONMAP_3D: boolean;
  93733. REFLECTIONMAP_SPHERICAL: boolean;
  93734. REFLECTIONMAP_PLANAR: boolean;
  93735. REFLECTIONMAP_CUBIC: boolean;
  93736. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93737. REFLECTIONMAP_PROJECTION: boolean;
  93738. REFLECTIONMAP_SKYBOX: boolean;
  93739. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93740. REFLECTIONMAP_EXPLICIT: boolean;
  93741. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93742. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93743. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93744. INVERTCUBICMAP: boolean;
  93745. LOGARITHMICDEPTH: boolean;
  93746. REFRACTION: boolean;
  93747. REFRACTIONMAP_3D: boolean;
  93748. REFLECTIONOVERALPHA: boolean;
  93749. TWOSIDEDLIGHTING: boolean;
  93750. SHADOWFLOAT: boolean;
  93751. MORPHTARGETS: boolean;
  93752. MORPHTARGETS_NORMAL: boolean;
  93753. MORPHTARGETS_TANGENT: boolean;
  93754. NUM_MORPH_INFLUENCERS: number;
  93755. NONUNIFORMSCALING: boolean;
  93756. PREMULTIPLYALPHA: boolean;
  93757. IMAGEPROCESSING: boolean;
  93758. VIGNETTE: boolean;
  93759. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93760. VIGNETTEBLENDMODEOPAQUE: boolean;
  93761. TONEMAPPING: boolean;
  93762. TONEMAPPING_ACES: boolean;
  93763. CONTRAST: boolean;
  93764. COLORCURVES: boolean;
  93765. COLORGRADING: boolean;
  93766. COLORGRADING3D: boolean;
  93767. SAMPLER3DGREENDEPTH: boolean;
  93768. SAMPLER3DBGRMAP: boolean;
  93769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93770. /**
  93771. * If the reflection texture on this material is in linear color space
  93772. * @hidden
  93773. */
  93774. IS_REFLECTION_LINEAR: boolean;
  93775. /**
  93776. * If the refraction texture on this material is in linear color space
  93777. * @hidden
  93778. */
  93779. IS_REFRACTION_LINEAR: boolean;
  93780. EXPOSURE: boolean;
  93781. constructor();
  93782. setReflectionMode(modeToEnable: string): void;
  93783. }
  93784. /**
  93785. * This is the default material used in Babylon. It is the best trade off between quality
  93786. * and performances.
  93787. * @see http://doc.babylonjs.com/babylon101/materials
  93788. */
  93789. export class StandardMaterial extends PushMaterial {
  93790. private _diffuseTexture;
  93791. /**
  93792. * The basic texture of the material as viewed under a light.
  93793. */
  93794. diffuseTexture: Nullable<BaseTexture>;
  93795. private _ambientTexture;
  93796. /**
  93797. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93798. */
  93799. ambientTexture: Nullable<BaseTexture>;
  93800. private _opacityTexture;
  93801. /**
  93802. * Define the transparency of the material from a texture.
  93803. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93804. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93805. */
  93806. opacityTexture: Nullable<BaseTexture>;
  93807. private _reflectionTexture;
  93808. /**
  93809. * Define the texture used to display the reflection.
  93810. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93811. */
  93812. reflectionTexture: Nullable<BaseTexture>;
  93813. private _emissiveTexture;
  93814. /**
  93815. * Define texture of the material as if self lit.
  93816. * This will be mixed in the final result even in the absence of light.
  93817. */
  93818. emissiveTexture: Nullable<BaseTexture>;
  93819. private _specularTexture;
  93820. /**
  93821. * Define how the color and intensity of the highlight given by the light in the material.
  93822. */
  93823. specularTexture: Nullable<BaseTexture>;
  93824. private _bumpTexture;
  93825. /**
  93826. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93827. * 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.
  93828. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93829. */
  93830. bumpTexture: Nullable<BaseTexture>;
  93831. private _lightmapTexture;
  93832. /**
  93833. * Complex lighting can be computationally expensive to compute at runtime.
  93834. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93835. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93836. */
  93837. lightmapTexture: Nullable<BaseTexture>;
  93838. private _refractionTexture;
  93839. /**
  93840. * Define the texture used to display the refraction.
  93841. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93842. */
  93843. refractionTexture: Nullable<BaseTexture>;
  93844. /**
  93845. * The color of the material lit by the environmental background lighting.
  93846. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93847. */
  93848. ambientColor: Color3;
  93849. /**
  93850. * The basic color of the material as viewed under a light.
  93851. */
  93852. diffuseColor: Color3;
  93853. /**
  93854. * Define how the color and intensity of the highlight given by the light in the material.
  93855. */
  93856. specularColor: Color3;
  93857. /**
  93858. * Define the color of the material as if self lit.
  93859. * This will be mixed in the final result even in the absence of light.
  93860. */
  93861. emissiveColor: Color3;
  93862. /**
  93863. * Defines how sharp are the highlights in the material.
  93864. * The bigger the value the sharper giving a more glossy feeling to the result.
  93865. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93866. */
  93867. specularPower: number;
  93868. private _useAlphaFromDiffuseTexture;
  93869. /**
  93870. * Does the transparency come from the diffuse texture alpha channel.
  93871. */
  93872. useAlphaFromDiffuseTexture: boolean;
  93873. private _useEmissiveAsIllumination;
  93874. /**
  93875. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93876. */
  93877. useEmissiveAsIllumination: boolean;
  93878. private _linkEmissiveWithDiffuse;
  93879. /**
  93880. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93881. * the emissive level when the final color is close to one.
  93882. */
  93883. linkEmissiveWithDiffuse: boolean;
  93884. private _useSpecularOverAlpha;
  93885. /**
  93886. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93887. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93888. */
  93889. useSpecularOverAlpha: boolean;
  93890. private _useReflectionOverAlpha;
  93891. /**
  93892. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93893. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93894. */
  93895. useReflectionOverAlpha: boolean;
  93896. private _disableLighting;
  93897. /**
  93898. * Does lights from the scene impacts this material.
  93899. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93900. */
  93901. disableLighting: boolean;
  93902. private _useObjectSpaceNormalMap;
  93903. /**
  93904. * Allows using an object space normal map (instead of tangent space).
  93905. */
  93906. useObjectSpaceNormalMap: boolean;
  93907. private _useParallax;
  93908. /**
  93909. * Is parallax enabled or not.
  93910. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93911. */
  93912. useParallax: boolean;
  93913. private _useParallaxOcclusion;
  93914. /**
  93915. * Is parallax occlusion enabled or not.
  93916. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93917. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93918. */
  93919. useParallaxOcclusion: boolean;
  93920. /**
  93921. * 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.
  93922. */
  93923. parallaxScaleBias: number;
  93924. private _roughness;
  93925. /**
  93926. * Helps to define how blurry the reflections should appears in the material.
  93927. */
  93928. roughness: number;
  93929. /**
  93930. * In case of refraction, define the value of the indice of refraction.
  93931. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93932. */
  93933. indexOfRefraction: number;
  93934. /**
  93935. * Invert the refraction texture alongside the y axis.
  93936. * It can be useful with procedural textures or probe for instance.
  93937. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93938. */
  93939. invertRefractionY: boolean;
  93940. /**
  93941. * Defines the alpha limits in alpha test mode.
  93942. */
  93943. alphaCutOff: number;
  93944. private _useLightmapAsShadowmap;
  93945. /**
  93946. * In case of light mapping, define whether the map contains light or shadow informations.
  93947. */
  93948. useLightmapAsShadowmap: boolean;
  93949. private _diffuseFresnelParameters;
  93950. /**
  93951. * Define the diffuse fresnel parameters of the material.
  93952. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93953. */
  93954. diffuseFresnelParameters: FresnelParameters;
  93955. private _opacityFresnelParameters;
  93956. /**
  93957. * Define the opacity fresnel parameters of the material.
  93958. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93959. */
  93960. opacityFresnelParameters: FresnelParameters;
  93961. private _reflectionFresnelParameters;
  93962. /**
  93963. * Define the reflection fresnel parameters of the material.
  93964. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93965. */
  93966. reflectionFresnelParameters: FresnelParameters;
  93967. private _refractionFresnelParameters;
  93968. /**
  93969. * Define the refraction fresnel parameters of the material.
  93970. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93971. */
  93972. refractionFresnelParameters: FresnelParameters;
  93973. private _emissiveFresnelParameters;
  93974. /**
  93975. * Define the emissive fresnel parameters of the material.
  93976. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93977. */
  93978. emissiveFresnelParameters: FresnelParameters;
  93979. private _useReflectionFresnelFromSpecular;
  93980. /**
  93981. * If true automatically deducts the fresnels values from the material specularity.
  93982. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93983. */
  93984. useReflectionFresnelFromSpecular: boolean;
  93985. private _useGlossinessFromSpecularMapAlpha;
  93986. /**
  93987. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  93988. */
  93989. useGlossinessFromSpecularMapAlpha: boolean;
  93990. private _maxSimultaneousLights;
  93991. /**
  93992. * Defines the maximum number of lights that can be used in the material
  93993. */
  93994. maxSimultaneousLights: number;
  93995. private _invertNormalMapX;
  93996. /**
  93997. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  93998. */
  93999. invertNormalMapX: boolean;
  94000. private _invertNormalMapY;
  94001. /**
  94002. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94003. */
  94004. invertNormalMapY: boolean;
  94005. private _twoSidedLighting;
  94006. /**
  94007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94008. */
  94009. twoSidedLighting: boolean;
  94010. /**
  94011. * Default configuration related to image processing available in the standard Material.
  94012. */
  94013. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94014. /**
  94015. * Gets the image processing configuration used either in this material.
  94016. */
  94017. /**
  94018. * Sets the Default image processing configuration used either in the this material.
  94019. *
  94020. * If sets to null, the scene one is in use.
  94021. */
  94022. imageProcessingConfiguration: ImageProcessingConfiguration;
  94023. /**
  94024. * Keep track of the image processing observer to allow dispose and replace.
  94025. */
  94026. private _imageProcessingObserver;
  94027. /**
  94028. * Attaches a new image processing configuration to the Standard Material.
  94029. * @param configuration
  94030. */
  94031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94032. /**
  94033. * Gets wether the color curves effect is enabled.
  94034. */
  94035. /**
  94036. * Sets wether the color curves effect is enabled.
  94037. */
  94038. cameraColorCurvesEnabled: boolean;
  94039. /**
  94040. * Gets wether the color grading effect is enabled.
  94041. */
  94042. /**
  94043. * Gets wether the color grading effect is enabled.
  94044. */
  94045. cameraColorGradingEnabled: boolean;
  94046. /**
  94047. * Gets wether tonemapping is enabled or not.
  94048. */
  94049. /**
  94050. * Sets wether tonemapping is enabled or not
  94051. */
  94052. cameraToneMappingEnabled: boolean;
  94053. /**
  94054. * The camera exposure used on this material.
  94055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94056. * This corresponds to a photographic exposure.
  94057. */
  94058. /**
  94059. * The camera exposure used on this material.
  94060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94061. * This corresponds to a photographic exposure.
  94062. */
  94063. cameraExposure: number;
  94064. /**
  94065. * Gets The camera contrast used on this material.
  94066. */
  94067. /**
  94068. * Sets The camera contrast used on this material.
  94069. */
  94070. cameraContrast: number;
  94071. /**
  94072. * Gets the Color Grading 2D Lookup Texture.
  94073. */
  94074. /**
  94075. * Sets the Color Grading 2D Lookup Texture.
  94076. */
  94077. cameraColorGradingTexture: Nullable<BaseTexture>;
  94078. /**
  94079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94081. * 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;
  94082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94083. */
  94084. /**
  94085. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94086. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94087. * 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;
  94088. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94089. */
  94090. cameraColorCurves: Nullable<ColorCurves>;
  94091. /**
  94092. * Custom callback helping to override the default shader used in the material.
  94093. */
  94094. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94095. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94096. protected _worldViewProjectionMatrix: Matrix;
  94097. protected _globalAmbientColor: Color3;
  94098. protected _useLogarithmicDepth: boolean;
  94099. /**
  94100. * Instantiates a new standard material.
  94101. * This is the default material used in Babylon. It is the best trade off between quality
  94102. * and performances.
  94103. * @see http://doc.babylonjs.com/babylon101/materials
  94104. * @param name Define the name of the material in the scene
  94105. * @param scene Define the scene the material belong to
  94106. */
  94107. constructor(name: string, scene: Scene);
  94108. /**
  94109. * Gets a boolean indicating that current material needs to register RTT
  94110. */
  94111. readonly hasRenderTargetTextures: boolean;
  94112. /**
  94113. * Gets the current class name of the material e.g. "StandardMaterial"
  94114. * Mainly use in serialization.
  94115. * @returns the class name
  94116. */
  94117. getClassName(): string;
  94118. /**
  94119. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94120. * You can try switching to logarithmic depth.
  94121. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94122. */
  94123. useLogarithmicDepth: boolean;
  94124. /**
  94125. * Specifies if the material will require alpha blending
  94126. * @returns a boolean specifying if alpha blending is needed
  94127. */
  94128. needAlphaBlending(): boolean;
  94129. /**
  94130. * Specifies if this material should be rendered in alpha test mode
  94131. * @returns a boolean specifying if an alpha test is needed.
  94132. */
  94133. needAlphaTesting(): boolean;
  94134. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94135. /**
  94136. * Get the texture used for alpha test purpose.
  94137. * @returns the diffuse texture in case of the standard material.
  94138. */
  94139. getAlphaTestTexture(): Nullable<BaseTexture>;
  94140. /**
  94141. * Get if the submesh is ready to be used and all its information available.
  94142. * Child classes can use it to update shaders
  94143. * @param mesh defines the mesh to check
  94144. * @param subMesh defines which submesh to check
  94145. * @param useInstances specifies that instances should be used
  94146. * @returns a boolean indicating that the submesh is ready or not
  94147. */
  94148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94149. /**
  94150. * Builds the material UBO layouts.
  94151. * Used internally during the effect preparation.
  94152. */
  94153. buildUniformLayout(): void;
  94154. /**
  94155. * Unbinds the material from the mesh
  94156. */
  94157. unbind(): void;
  94158. /**
  94159. * Binds the submesh to this material by preparing the effect and shader to draw
  94160. * @param world defines the world transformation matrix
  94161. * @param mesh defines the mesh containing the submesh
  94162. * @param subMesh defines the submesh to bind the material to
  94163. */
  94164. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94165. /**
  94166. * Get the list of animatables in the material.
  94167. * @returns the list of animatables object used in the material
  94168. */
  94169. getAnimatables(): IAnimatable[];
  94170. /**
  94171. * Gets the active textures from the material
  94172. * @returns an array of textures
  94173. */
  94174. getActiveTextures(): BaseTexture[];
  94175. /**
  94176. * Specifies if the material uses a texture
  94177. * @param texture defines the texture to check against the material
  94178. * @returns a boolean specifying if the material uses the texture
  94179. */
  94180. hasTexture(texture: BaseTexture): boolean;
  94181. /**
  94182. * Disposes the material
  94183. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94184. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94185. */
  94186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94187. /**
  94188. * Makes a duplicate of the material, and gives it a new name
  94189. * @param name defines the new name for the duplicated material
  94190. * @returns the cloned material
  94191. */
  94192. clone(name: string): StandardMaterial;
  94193. /**
  94194. * Serializes this material in a JSON representation
  94195. * @returns the serialized material object
  94196. */
  94197. serialize(): any;
  94198. /**
  94199. * Creates a standard material from parsed material data
  94200. * @param source defines the JSON representation of the material
  94201. * @param scene defines the hosting scene
  94202. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94203. * @returns a new standard material
  94204. */
  94205. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94206. /**
  94207. * Are diffuse textures enabled in the application.
  94208. */
  94209. static DiffuseTextureEnabled: boolean;
  94210. /**
  94211. * Are ambient textures enabled in the application.
  94212. */
  94213. static AmbientTextureEnabled: boolean;
  94214. /**
  94215. * Are opacity textures enabled in the application.
  94216. */
  94217. static OpacityTextureEnabled: boolean;
  94218. /**
  94219. * Are reflection textures enabled in the application.
  94220. */
  94221. static ReflectionTextureEnabled: boolean;
  94222. /**
  94223. * Are emissive textures enabled in the application.
  94224. */
  94225. static EmissiveTextureEnabled: boolean;
  94226. /**
  94227. * Are specular textures enabled in the application.
  94228. */
  94229. static SpecularTextureEnabled: boolean;
  94230. /**
  94231. * Are bump textures enabled in the application.
  94232. */
  94233. static BumpTextureEnabled: boolean;
  94234. /**
  94235. * Are lightmap textures enabled in the application.
  94236. */
  94237. static LightmapTextureEnabled: boolean;
  94238. /**
  94239. * Are refraction textures enabled in the application.
  94240. */
  94241. static RefractionTextureEnabled: boolean;
  94242. /**
  94243. * Are color grading textures enabled in the application.
  94244. */
  94245. static ColorGradingTextureEnabled: boolean;
  94246. /**
  94247. * Are fresnels enabled in the application.
  94248. */
  94249. static FresnelEnabled: boolean;
  94250. }
  94251. }
  94252. declare module BABYLON {
  94253. /**
  94254. * A class extending Texture allowing drawing on a texture
  94255. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94256. */
  94257. export class DynamicTexture extends Texture {
  94258. private _generateMipMaps;
  94259. private _canvas;
  94260. private _context;
  94261. private _engine;
  94262. /**
  94263. * Creates a DynamicTexture
  94264. * @param name defines the name of the texture
  94265. * @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
  94266. * @param scene defines the scene where you want the texture
  94267. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94269. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94270. */
  94271. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94272. /**
  94273. * Get the current class name of the texture useful for serialization or dynamic coding.
  94274. * @returns "DynamicTexture"
  94275. */
  94276. getClassName(): string;
  94277. /**
  94278. * Gets the current state of canRescale
  94279. */
  94280. readonly canRescale: boolean;
  94281. private _recreate;
  94282. /**
  94283. * Scales the texture
  94284. * @param ratio the scale factor to apply to both width and height
  94285. */
  94286. scale(ratio: number): void;
  94287. /**
  94288. * Resizes the texture
  94289. * @param width the new width
  94290. * @param height the new height
  94291. */
  94292. scaleTo(width: number, height: number): void;
  94293. /**
  94294. * Gets the context of the canvas used by the texture
  94295. * @returns the canvas context of the dynamic texture
  94296. */
  94297. getContext(): CanvasRenderingContext2D;
  94298. /**
  94299. * Clears the texture
  94300. */
  94301. clear(): void;
  94302. /**
  94303. * Updates the texture
  94304. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94305. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94306. */
  94307. update(invertY?: boolean, premulAlpha?: boolean): void;
  94308. /**
  94309. * Draws text onto the texture
  94310. * @param text defines the text to be drawn
  94311. * @param x defines the placement of the text from the left
  94312. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94313. * @param font defines the font to be used with font-style, font-size, font-name
  94314. * @param color defines the color used for the text
  94315. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94316. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94317. * @param update defines whether texture is immediately update (default is true)
  94318. */
  94319. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94320. /**
  94321. * Clones the texture
  94322. * @returns the clone of the texture.
  94323. */
  94324. clone(): DynamicTexture;
  94325. /**
  94326. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94327. * @returns a serialized dynamic texture object
  94328. */
  94329. serialize(): any;
  94330. /** @hidden */
  94331. _rebuild(): void;
  94332. }
  94333. }
  94334. declare module BABYLON {
  94335. /** @hidden */
  94336. export var imageProcessingPixelShader: {
  94337. name: string;
  94338. shader: string;
  94339. };
  94340. }
  94341. declare module BABYLON {
  94342. /**
  94343. * ImageProcessingPostProcess
  94344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94345. */
  94346. export class ImageProcessingPostProcess extends PostProcess {
  94347. /**
  94348. * Default configuration related to image processing available in the PBR Material.
  94349. */
  94350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94351. /**
  94352. * Gets the image processing configuration used either in this material.
  94353. */
  94354. /**
  94355. * Sets the Default image processing configuration used either in the this material.
  94356. *
  94357. * If sets to null, the scene one is in use.
  94358. */
  94359. imageProcessingConfiguration: ImageProcessingConfiguration;
  94360. /**
  94361. * Keep track of the image processing observer to allow dispose and replace.
  94362. */
  94363. private _imageProcessingObserver;
  94364. /**
  94365. * Attaches a new image processing configuration to the PBR Material.
  94366. * @param configuration
  94367. */
  94368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94369. /**
  94370. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94371. */
  94372. /**
  94373. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94374. */
  94375. colorCurves: Nullable<ColorCurves>;
  94376. /**
  94377. * Gets wether the color curves effect is enabled.
  94378. */
  94379. /**
  94380. * Sets wether the color curves effect is enabled.
  94381. */
  94382. colorCurvesEnabled: boolean;
  94383. /**
  94384. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94385. */
  94386. /**
  94387. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94388. */
  94389. colorGradingTexture: Nullable<BaseTexture>;
  94390. /**
  94391. * Gets wether the color grading effect is enabled.
  94392. */
  94393. /**
  94394. * Gets wether the color grading effect is enabled.
  94395. */
  94396. colorGradingEnabled: boolean;
  94397. /**
  94398. * Gets exposure used in the effect.
  94399. */
  94400. /**
  94401. * Sets exposure used in the effect.
  94402. */
  94403. exposure: number;
  94404. /**
  94405. * Gets wether tonemapping is enabled or not.
  94406. */
  94407. /**
  94408. * Sets wether tonemapping is enabled or not
  94409. */
  94410. toneMappingEnabled: boolean;
  94411. /**
  94412. * Gets contrast used in the effect.
  94413. */
  94414. /**
  94415. * Sets contrast used in the effect.
  94416. */
  94417. contrast: number;
  94418. /**
  94419. * Gets Vignette stretch size.
  94420. */
  94421. /**
  94422. * Sets Vignette stretch size.
  94423. */
  94424. vignetteStretch: number;
  94425. /**
  94426. * Gets Vignette centre X Offset.
  94427. */
  94428. /**
  94429. * Sets Vignette centre X Offset.
  94430. */
  94431. vignetteCentreX: number;
  94432. /**
  94433. * Gets Vignette centre Y Offset.
  94434. */
  94435. /**
  94436. * Sets Vignette centre Y Offset.
  94437. */
  94438. vignetteCentreY: number;
  94439. /**
  94440. * Gets Vignette weight or intensity of the vignette effect.
  94441. */
  94442. /**
  94443. * Sets Vignette weight or intensity of the vignette effect.
  94444. */
  94445. vignetteWeight: number;
  94446. /**
  94447. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94448. * if vignetteEnabled is set to true.
  94449. */
  94450. /**
  94451. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94452. * if vignetteEnabled is set to true.
  94453. */
  94454. vignetteColor: Color4;
  94455. /**
  94456. * Gets Camera field of view used by the Vignette effect.
  94457. */
  94458. /**
  94459. * Sets Camera field of view used by the Vignette effect.
  94460. */
  94461. vignetteCameraFov: number;
  94462. /**
  94463. * Gets the vignette blend mode allowing different kind of effect.
  94464. */
  94465. /**
  94466. * Sets the vignette blend mode allowing different kind of effect.
  94467. */
  94468. vignetteBlendMode: number;
  94469. /**
  94470. * Gets wether the vignette effect is enabled.
  94471. */
  94472. /**
  94473. * Sets wether the vignette effect is enabled.
  94474. */
  94475. vignetteEnabled: boolean;
  94476. private _fromLinearSpace;
  94477. /**
  94478. * Gets wether the input of the processing is in Gamma or Linear Space.
  94479. */
  94480. /**
  94481. * Sets wether the input of the processing is in Gamma or Linear Space.
  94482. */
  94483. fromLinearSpace: boolean;
  94484. /**
  94485. * Defines cache preventing GC.
  94486. */
  94487. private _defines;
  94488. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94489. /**
  94490. * "ImageProcessingPostProcess"
  94491. * @returns "ImageProcessingPostProcess"
  94492. */
  94493. getClassName(): string;
  94494. protected _updateParameters(): void;
  94495. dispose(camera?: Camera): void;
  94496. }
  94497. }
  94498. declare module BABYLON {
  94499. /**
  94500. * Class containing static functions to help procedurally build meshes
  94501. */
  94502. export class GroundBuilder {
  94503. /**
  94504. * Creates a ground mesh
  94505. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94506. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94508. * @param name defines the name of the mesh
  94509. * @param options defines the options used to create the mesh
  94510. * @param scene defines the hosting scene
  94511. * @returns the ground mesh
  94512. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94513. */
  94514. static CreateGround(name: string, options: {
  94515. width?: number;
  94516. height?: number;
  94517. subdivisions?: number;
  94518. subdivisionsX?: number;
  94519. subdivisionsY?: number;
  94520. updatable?: boolean;
  94521. }, scene: any): Mesh;
  94522. /**
  94523. * Creates a tiled ground mesh
  94524. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94525. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94526. * * 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
  94527. * * 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
  94528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94529. * @param name defines the name of the mesh
  94530. * @param options defines the options used to create the mesh
  94531. * @param scene defines the hosting scene
  94532. * @returns the tiled ground mesh
  94533. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94534. */
  94535. static CreateTiledGround(name: string, options: {
  94536. xmin: number;
  94537. zmin: number;
  94538. xmax: number;
  94539. zmax: number;
  94540. subdivisions?: {
  94541. w: number;
  94542. h: number;
  94543. };
  94544. precision?: {
  94545. w: number;
  94546. h: number;
  94547. };
  94548. updatable?: boolean;
  94549. }, scene: Scene): Mesh;
  94550. /**
  94551. * Creates a ground mesh from a height map
  94552. * * The parameter `url` sets the URL of the height map image resource.
  94553. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94554. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94555. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94556. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94557. * * 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.
  94558. * * 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).
  94559. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94561. * @param name defines the name of the mesh
  94562. * @param url defines the url to the height map
  94563. * @param options defines the options used to create the mesh
  94564. * @param scene defines the hosting scene
  94565. * @returns the ground mesh
  94566. * @see https://doc.babylonjs.com/babylon101/height_map
  94567. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94568. */
  94569. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94570. width?: number;
  94571. height?: number;
  94572. subdivisions?: number;
  94573. minHeight?: number;
  94574. maxHeight?: number;
  94575. colorFilter?: Color3;
  94576. alphaFilter?: number;
  94577. updatable?: boolean;
  94578. onReady?: (mesh: GroundMesh) => void;
  94579. }, scene: Scene): GroundMesh;
  94580. }
  94581. }
  94582. declare module BABYLON {
  94583. /**
  94584. * Class containing static functions to help procedurally build meshes
  94585. */
  94586. export class TorusBuilder {
  94587. /**
  94588. * Creates a torus mesh
  94589. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94590. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94591. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94595. * @param name defines the name of the mesh
  94596. * @param options defines the options used to create the mesh
  94597. * @param scene defines the hosting scene
  94598. * @returns the torus mesh
  94599. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94600. */
  94601. static CreateTorus(name: string, options: {
  94602. diameter?: number;
  94603. thickness?: number;
  94604. tessellation?: number;
  94605. updatable?: boolean;
  94606. sideOrientation?: number;
  94607. frontUVs?: Vector4;
  94608. backUVs?: Vector4;
  94609. }, scene: any): Mesh;
  94610. }
  94611. }
  94612. declare module BABYLON {
  94613. /**
  94614. * Class containing static functions to help procedurally build meshes
  94615. */
  94616. export class CylinderBuilder {
  94617. /**
  94618. * Creates a cylinder or a cone mesh
  94619. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94620. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94621. * * 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.
  94622. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94623. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94624. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94625. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94626. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94627. * * 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).
  94628. * * 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
  94629. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94630. * * 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
  94631. * * 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.
  94632. * * If `enclose` is false, a ring surface is one element.
  94633. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94634. * * 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
  94635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94638. * @param name defines the name of the mesh
  94639. * @param options defines the options used to create the mesh
  94640. * @param scene defines the hosting scene
  94641. * @returns the cylinder mesh
  94642. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94643. */
  94644. static CreateCylinder(name: string, options: {
  94645. height?: number;
  94646. diameterTop?: number;
  94647. diameterBottom?: number;
  94648. diameter?: number;
  94649. tessellation?: number;
  94650. subdivisions?: number;
  94651. arc?: number;
  94652. faceColors?: Color4[];
  94653. faceUV?: Vector4[];
  94654. updatable?: boolean;
  94655. hasRings?: boolean;
  94656. enclose?: boolean;
  94657. sideOrientation?: number;
  94658. frontUVs?: Vector4;
  94659. backUVs?: Vector4;
  94660. }, scene: any): Mesh;
  94661. }
  94662. }
  94663. declare module BABYLON {
  94664. /**
  94665. * Manager for handling gamepads
  94666. */
  94667. export class GamepadManager {
  94668. private _scene?;
  94669. private _babylonGamepads;
  94670. private _oneGamepadConnected;
  94671. /** @hidden */
  94672. _isMonitoring: boolean;
  94673. private _gamepadEventSupported;
  94674. private _gamepadSupport;
  94675. /**
  94676. * observable to be triggered when the gamepad controller has been connected
  94677. */
  94678. onGamepadConnectedObservable: Observable<Gamepad>;
  94679. /**
  94680. * observable to be triggered when the gamepad controller has been disconnected
  94681. */
  94682. onGamepadDisconnectedObservable: Observable<Gamepad>;
  94683. private _onGamepadConnectedEvent;
  94684. private _onGamepadDisconnectedEvent;
  94685. /**
  94686. * Initializes the gamepad manager
  94687. * @param _scene BabylonJS scene
  94688. */
  94689. constructor(_scene?: Scene | undefined);
  94690. /**
  94691. * The gamepads in the game pad manager
  94692. */
  94693. readonly gamepads: Gamepad[];
  94694. /**
  94695. * Get the gamepad controllers based on type
  94696. * @param type The type of gamepad controller
  94697. * @returns Nullable gamepad
  94698. */
  94699. getGamepadByType(type?: number): Nullable<Gamepad>;
  94700. /**
  94701. * Disposes the gamepad manager
  94702. */
  94703. dispose(): void;
  94704. private _addNewGamepad;
  94705. private _startMonitoringGamepads;
  94706. private _stopMonitoringGamepads;
  94707. /** @hidden */
  94708. _checkGamepadsStatus(): void;
  94709. private _updateGamepadObjects;
  94710. }
  94711. }
  94712. declare module BABYLON {
  94713. interface Scene {
  94714. /** @hidden */
  94715. _gamepadManager: Nullable<GamepadManager>;
  94716. /**
  94717. * Gets the gamepad manager associated with the scene
  94718. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  94719. */
  94720. gamepadManager: GamepadManager;
  94721. }
  94722. /**
  94723. * Interface representing a free camera inputs manager
  94724. */
  94725. interface FreeCameraInputsManager {
  94726. /**
  94727. * Adds gamepad input support to the FreeCameraInputsManager.
  94728. * @returns the FreeCameraInputsManager
  94729. */
  94730. addGamepad(): FreeCameraInputsManager;
  94731. }
  94732. /**
  94733. * Interface representing an arc rotate camera inputs manager
  94734. */
  94735. interface ArcRotateCameraInputsManager {
  94736. /**
  94737. * Adds gamepad input support to the ArcRotateCamera InputManager.
  94738. * @returns the camera inputs manager
  94739. */
  94740. addGamepad(): ArcRotateCameraInputsManager;
  94741. }
  94742. /**
  94743. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  94744. */
  94745. export class GamepadSystemSceneComponent implements ISceneComponent {
  94746. /**
  94747. * The component name helpfull to identify the component in the list of scene components.
  94748. */
  94749. readonly name: string;
  94750. /**
  94751. * The scene the component belongs to.
  94752. */
  94753. scene: Scene;
  94754. /**
  94755. * Creates a new instance of the component for the given scene
  94756. * @param scene Defines the scene to register the component in
  94757. */
  94758. constructor(scene: Scene);
  94759. /**
  94760. * Registers the component in a given scene
  94761. */
  94762. register(): void;
  94763. /**
  94764. * Rebuilds the elements related to this component in case of
  94765. * context lost for instance.
  94766. */
  94767. rebuild(): void;
  94768. /**
  94769. * Disposes the component and the associated ressources
  94770. */
  94771. dispose(): void;
  94772. private _beforeCameraUpdate;
  94773. }
  94774. }
  94775. declare module BABYLON {
  94776. /**
  94777. * Options to modify the vr teleportation behavior.
  94778. */
  94779. export interface VRTeleportationOptions {
  94780. /**
  94781. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94782. */
  94783. floorMeshName?: string;
  94784. /**
  94785. * A list of meshes to be used as the teleportation floor. (default: empty)
  94786. */
  94787. floorMeshes?: Mesh[];
  94788. }
  94789. /**
  94790. * Options to modify the vr experience helper's behavior.
  94791. */
  94792. export interface VRExperienceHelperOptions extends WebVROptions {
  94793. /**
  94794. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94795. */
  94796. createDeviceOrientationCamera?: boolean;
  94797. /**
  94798. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94799. */
  94800. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94801. /**
  94802. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94803. */
  94804. laserToggle?: boolean;
  94805. /**
  94806. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94807. */
  94808. floorMeshes?: Mesh[];
  94809. /**
  94810. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  94811. */
  94812. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  94813. }
  94814. /**
  94815. * Helps to quickly add VR support to an existing scene.
  94816. * See http://doc.babylonjs.com/how_to/webvr_helper
  94817. */
  94818. export class VRExperienceHelper {
  94819. /** Options to modify the vr experience helper's behavior. */
  94820. webVROptions: VRExperienceHelperOptions;
  94821. private _scene;
  94822. private _position;
  94823. private _btnVR;
  94824. private _btnVRDisplayed;
  94825. private _webVRsupported;
  94826. private _webVRready;
  94827. private _webVRrequesting;
  94828. private _webVRpresenting;
  94829. private _hasEnteredVR;
  94830. private _fullscreenVRpresenting;
  94831. private _canvas;
  94832. private _webVRCamera;
  94833. private _vrDeviceOrientationCamera;
  94834. private _deviceOrientationCamera;
  94835. private _existingCamera;
  94836. private _onKeyDown;
  94837. private _onVrDisplayPresentChange;
  94838. private _onVRDisplayChanged;
  94839. private _onVRRequestPresentStart;
  94840. private _onVRRequestPresentComplete;
  94841. /**
  94842. * Observable raised when entering VR.
  94843. */
  94844. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94845. /**
  94846. * Observable raised when exiting VR.
  94847. */
  94848. onExitingVRObservable: Observable<VRExperienceHelper>;
  94849. /**
  94850. * Observable raised when controller mesh is loaded.
  94851. */
  94852. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94853. /** Return this.onEnteringVRObservable
  94854. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94855. */
  94856. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94857. /** Return this.onExitingVRObservable
  94858. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94859. */
  94860. readonly onExitingVR: Observable<VRExperienceHelper>;
  94861. /** Return this.onControllerMeshLoadedObservable
  94862. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94863. */
  94864. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94865. private _rayLength;
  94866. private _useCustomVRButton;
  94867. private _teleportationRequested;
  94868. private _teleportActive;
  94869. private _floorMeshName;
  94870. private _floorMeshesCollection;
  94871. private _rotationAllowed;
  94872. private _teleportBackwardsVector;
  94873. private _teleportationTarget;
  94874. private _isDefaultTeleportationTarget;
  94875. private _postProcessMove;
  94876. private _teleportationFillColor;
  94877. private _teleportationBorderColor;
  94878. private _rotationAngle;
  94879. private _haloCenter;
  94880. private _cameraGazer;
  94881. private _padSensibilityUp;
  94882. private _padSensibilityDown;
  94883. private _leftController;
  94884. private _rightController;
  94885. /**
  94886. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94887. */
  94888. onNewMeshSelected: Observable<AbstractMesh>;
  94889. /**
  94890. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94891. */
  94892. onNewMeshPicked: Observable<PickingInfo>;
  94893. private _circleEase;
  94894. /**
  94895. * Observable raised before camera teleportation
  94896. */
  94897. onBeforeCameraTeleport: Observable<Vector3>;
  94898. /**
  94899. * Observable raised after camera teleportation
  94900. */
  94901. onAfterCameraTeleport: Observable<Vector3>;
  94902. /**
  94903. * Observable raised when current selected mesh gets unselected
  94904. */
  94905. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94906. private _raySelectionPredicate;
  94907. /**
  94908. * To be optionaly changed by user to define custom ray selection
  94909. */
  94910. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94911. /**
  94912. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94913. */
  94914. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94915. /**
  94916. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94917. */
  94918. teleportationEnabled: boolean;
  94919. private _defaultHeight;
  94920. private _teleportationInitialized;
  94921. private _interactionsEnabled;
  94922. private _interactionsRequested;
  94923. private _displayGaze;
  94924. private _displayLaserPointer;
  94925. /**
  94926. * The mesh used to display where the user is going to teleport.
  94927. */
  94928. /**
  94929. * Sets the mesh to be used to display where the user is going to teleport.
  94930. */
  94931. teleportationTarget: Mesh;
  94932. /**
  94933. * 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
  94934. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  94935. * See http://doc.babylonjs.com/resources/baking_transformations
  94936. */
  94937. gazeTrackerMesh: Mesh;
  94938. /**
  94939. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  94940. */
  94941. updateGazeTrackerScale: boolean;
  94942. /**
  94943. * If the gaze trackers color should be updated when selecting meshes
  94944. */
  94945. updateGazeTrackerColor: boolean;
  94946. /**
  94947. * The gaze tracking mesh corresponding to the left controller
  94948. */
  94949. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  94950. /**
  94951. * The gaze tracking mesh corresponding to the right controller
  94952. */
  94953. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  94954. /**
  94955. * If the ray of the gaze should be displayed.
  94956. */
  94957. /**
  94958. * Sets if the ray of the gaze should be displayed.
  94959. */
  94960. displayGaze: boolean;
  94961. /**
  94962. * If the ray of the LaserPointer should be displayed.
  94963. */
  94964. /**
  94965. * Sets if the ray of the LaserPointer should be displayed.
  94966. */
  94967. displayLaserPointer: boolean;
  94968. /**
  94969. * The deviceOrientationCamera used as the camera when not in VR.
  94970. */
  94971. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  94972. /**
  94973. * Based on the current WebVR support, returns the current VR camera used.
  94974. */
  94975. readonly currentVRCamera: Nullable<Camera>;
  94976. /**
  94977. * The webVRCamera which is used when in VR.
  94978. */
  94979. readonly webVRCamera: WebVRFreeCamera;
  94980. /**
  94981. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  94982. */
  94983. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  94984. private readonly _teleportationRequestInitiated;
  94985. /**
  94986. * Defines wether or not Pointer lock should be requested when switching to
  94987. * full screen.
  94988. */
  94989. requestPointerLockOnFullScreen: boolean;
  94990. /**
  94991. * Instantiates a VRExperienceHelper.
  94992. * Helps to quickly add VR support to an existing scene.
  94993. * @param scene The scene the VRExperienceHelper belongs to.
  94994. * @param webVROptions Options to modify the vr experience helper's behavior.
  94995. */
  94996. constructor(scene: Scene,
  94997. /** Options to modify the vr experience helper's behavior. */
  94998. webVROptions?: VRExperienceHelperOptions);
  94999. private _onDefaultMeshLoaded;
  95000. private _onResize;
  95001. private _onFullscreenChange;
  95002. /**
  95003. * Gets a value indicating if we are currently in VR mode.
  95004. */
  95005. readonly isInVRMode: boolean;
  95006. private onVrDisplayPresentChange;
  95007. private onVRDisplayChanged;
  95008. private moveButtonToBottomRight;
  95009. private displayVRButton;
  95010. private updateButtonVisibility;
  95011. private _cachedAngularSensibility;
  95012. /**
  95013. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95014. * Otherwise, will use the fullscreen API.
  95015. */
  95016. enterVR(): void;
  95017. /**
  95018. * Attempt to exit VR, or fullscreen.
  95019. */
  95020. exitVR(): void;
  95021. /**
  95022. * The position of the vr experience helper.
  95023. */
  95024. /**
  95025. * Sets the position of the vr experience helper.
  95026. */
  95027. position: Vector3;
  95028. /**
  95029. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95030. */
  95031. enableInteractions(): void;
  95032. private readonly _noControllerIsActive;
  95033. private beforeRender;
  95034. private _isTeleportationFloor;
  95035. /**
  95036. * Adds a floor mesh to be used for teleportation.
  95037. * @param floorMesh the mesh to be used for teleportation.
  95038. */
  95039. addFloorMesh(floorMesh: Mesh): void;
  95040. /**
  95041. * Removes a floor mesh from being used for teleportation.
  95042. * @param floorMesh the mesh to be removed.
  95043. */
  95044. removeFloorMesh(floorMesh: Mesh): void;
  95045. /**
  95046. * Enables interactions and teleportation using the VR controllers and gaze.
  95047. * @param vrTeleportationOptions options to modify teleportation behavior.
  95048. */
  95049. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95050. private _onNewGamepadConnected;
  95051. private _tryEnableInteractionOnController;
  95052. private _onNewGamepadDisconnected;
  95053. private _enableInteractionOnController;
  95054. private _checkTeleportWithRay;
  95055. private _checkRotate;
  95056. private _checkTeleportBackwards;
  95057. private _enableTeleportationOnController;
  95058. private _createTeleportationCircles;
  95059. private _displayTeleportationTarget;
  95060. private _hideTeleportationTarget;
  95061. private _rotateCamera;
  95062. private _moveTeleportationSelectorTo;
  95063. private _workingVector;
  95064. private _workingQuaternion;
  95065. private _workingMatrix;
  95066. /**
  95067. * Teleports the users feet to the desired location
  95068. * @param location The location where the user's feet should be placed
  95069. */
  95070. teleportCamera(location: Vector3): void;
  95071. private _convertNormalToDirectionOfRay;
  95072. private _castRayAndSelectObject;
  95073. private _notifySelectedMeshUnselected;
  95074. /**
  95075. * Sets the color of the laser ray from the vr controllers.
  95076. * @param color new color for the ray.
  95077. */
  95078. changeLaserColor(color: Color3): void;
  95079. /**
  95080. * Sets the color of the ray from the vr headsets gaze.
  95081. * @param color new color for the ray.
  95082. */
  95083. changeGazeColor(color: Color3): void;
  95084. /**
  95085. * Exits VR and disposes of the vr experience helper
  95086. */
  95087. dispose(): void;
  95088. /**
  95089. * Gets the name of the VRExperienceHelper class
  95090. * @returns "VRExperienceHelper"
  95091. */
  95092. getClassName(): string;
  95093. }
  95094. }
  95095. declare module BABYLON {
  95096. /**
  95097. * Manages an XRSession
  95098. * @see https://doc.babylonjs.com/how_to/webxr
  95099. */
  95100. export class WebXRSessionManager implements IDisposable {
  95101. private scene;
  95102. /**
  95103. * Fires every time a new xrFrame arrives which can be used to update the camera
  95104. */
  95105. onXRFrameObservable: Observable<any>;
  95106. /**
  95107. * Fires when the xr session is ended either by the device or manually done
  95108. */
  95109. onXRSessionEnded: Observable<any>;
  95110. /** @hidden */
  95111. _xrSession: XRSession;
  95112. /** @hidden */
  95113. _frameOfReference: XRFrameOfReference;
  95114. /** @hidden */
  95115. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95116. /** @hidden */
  95117. _currentXRFrame: Nullable<XRFrame>;
  95118. private _xrNavigator;
  95119. private _xrDevice;
  95120. private _tmpMatrix;
  95121. /**
  95122. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95123. * @param scene The scene which the session should be created for
  95124. */
  95125. constructor(scene: Scene);
  95126. /**
  95127. * Initializes the manager
  95128. * After initialization enterXR can be called to start an XR session
  95129. * @returns Promise which resolves after it is initialized
  95130. */
  95131. initializeAsync(): Promise<void>;
  95132. /**
  95133. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95134. * @param sessionCreationOptions xr options to create the session with
  95135. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95136. * @returns Promise which resolves after it enters XR
  95137. */
  95138. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95139. /**
  95140. * Stops the xrSession and restores the renderloop
  95141. * @returns Promise which resolves after it exits XR
  95142. */
  95143. exitXRAsync(): Promise<void>;
  95144. /**
  95145. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95146. * @param ray ray to cast into the environment
  95147. * @returns Promise which resolves with a collision point in the environment if it exists
  95148. */
  95149. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95150. /**
  95151. * Checks if a session would be supported for the creation options specified
  95152. * @param options creation options to check if they are supported
  95153. * @returns true if supported
  95154. */
  95155. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95156. /**
  95157. * @hidden
  95158. * Converts the render layer of xrSession to a render target
  95159. * @param session session to create render target for
  95160. * @param scene scene the new render target should be created for
  95161. */
  95162. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95163. /**
  95164. * Disposes of the session manager
  95165. */
  95166. dispose(): void;
  95167. }
  95168. }
  95169. declare module BABYLON {
  95170. /**
  95171. * WebXR Camera which holds the views for the xrSession
  95172. * @see https://doc.babylonjs.com/how_to/webxr
  95173. */
  95174. export class WebXRCamera extends FreeCamera {
  95175. private static _TmpMatrix;
  95176. /**
  95177. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95178. * @param name the name of the camera
  95179. * @param scene the scene to add the camera to
  95180. */
  95181. constructor(name: string, scene: Scene);
  95182. private _updateNumberOfRigCameras;
  95183. /** @hidden */
  95184. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95185. /**
  95186. * Updates the cameras position from the current pose information of the XR session
  95187. * @param xrSessionManager the session containing pose information
  95188. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95189. */
  95190. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95191. }
  95192. }
  95193. declare module BABYLON {
  95194. /**
  95195. * States of the webXR experience
  95196. */
  95197. export enum WebXRState {
  95198. /**
  95199. * Transitioning to being in XR mode
  95200. */
  95201. ENTERING_XR = 0,
  95202. /**
  95203. * Transitioning to non XR mode
  95204. */
  95205. EXITING_XR = 1,
  95206. /**
  95207. * In XR mode and presenting
  95208. */
  95209. IN_XR = 2,
  95210. /**
  95211. * Not entered XR mode
  95212. */
  95213. NOT_IN_XR = 3
  95214. }
  95215. /**
  95216. * Helper class used to enable XR
  95217. * @see https://doc.babylonjs.com/how_to/webxr
  95218. */
  95219. export class WebXRExperienceHelper implements IDisposable {
  95220. private scene;
  95221. /**
  95222. * 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
  95223. */
  95224. container: AbstractMesh;
  95225. /**
  95226. * Camera used to render xr content
  95227. */
  95228. camera: WebXRCamera;
  95229. /**
  95230. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95231. */
  95232. state: WebXRState;
  95233. private _setState;
  95234. private static _TmpVector;
  95235. /**
  95236. * Fires when the state of the experience helper has changed
  95237. */
  95238. onStateChangedObservable: Observable<WebXRState>;
  95239. /** @hidden */
  95240. _sessionManager: WebXRSessionManager;
  95241. private _nonVRCamera;
  95242. private _originalSceneAutoClear;
  95243. private _supported;
  95244. /**
  95245. * Creates the experience helper
  95246. * @param scene the scene to attach the experience helper to
  95247. * @returns a promise for the experience helper
  95248. */
  95249. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95250. /**
  95251. * Creates a WebXRExperienceHelper
  95252. * @param scene The scene the helper should be created in
  95253. */
  95254. private constructor();
  95255. /**
  95256. * Exits XR mode and returns the scene to its original state
  95257. * @returns promise that resolves after xr mode has exited
  95258. */
  95259. exitXRAsync(): Promise<void>;
  95260. /**
  95261. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95262. * @param sessionCreationOptions options for the XR session
  95263. * @param frameOfReference frame of reference of the XR session
  95264. * @returns promise that resolves after xr mode has entered
  95265. */
  95266. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95267. /**
  95268. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95269. * @param ray ray to cast into the environment
  95270. * @returns Promise which resolves with a collision point in the environment if it exists
  95271. */
  95272. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95273. /**
  95274. * Updates the global position of the camera by moving the camera's container
  95275. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95276. * @param position The desired global position of the camera
  95277. */
  95278. setPositionOfCameraUsingContainer(position: Vector3): void;
  95279. /**
  95280. * Rotates the xr camera by rotating the camera's container around the camera's position
  95281. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95282. * @param rotation the desired quaternion rotation to apply to the camera
  95283. */
  95284. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95285. /**
  95286. * Checks if the creation options are supported by the xr session
  95287. * @param options creation options
  95288. * @returns true if supported
  95289. */
  95290. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95291. /**
  95292. * Disposes of the experience helper
  95293. */
  95294. dispose(): void;
  95295. }
  95296. }
  95297. declare module BABYLON {
  95298. /**
  95299. * Button which can be used to enter a different mode of XR
  95300. */
  95301. export class WebXREnterExitUIButton {
  95302. /** button element */
  95303. element: HTMLElement;
  95304. /** XR initialization options for the button */
  95305. initializationOptions: XRSessionCreationOptions;
  95306. /**
  95307. * Creates a WebXREnterExitUIButton
  95308. * @param element button element
  95309. * @param initializationOptions XR initialization options for the button
  95310. */
  95311. constructor(
  95312. /** button element */
  95313. element: HTMLElement,
  95314. /** XR initialization options for the button */
  95315. initializationOptions: XRSessionCreationOptions);
  95316. /**
  95317. * Overwritable function which can be used to update the button's visuals when the state changes
  95318. * @param activeButton the current active button in the UI
  95319. */
  95320. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95321. }
  95322. /**
  95323. * Options to create the webXR UI
  95324. */
  95325. export class WebXREnterExitUIOptions {
  95326. /**
  95327. * Context to enter xr with
  95328. */
  95329. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95330. /**
  95331. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95332. */
  95333. customButtons?: Array<WebXREnterExitUIButton>;
  95334. }
  95335. /**
  95336. * UI to allow the user to enter/exit XR mode
  95337. */
  95338. export class WebXREnterExitUI implements IDisposable {
  95339. private scene;
  95340. private _overlay;
  95341. private _buttons;
  95342. private _activeButton;
  95343. /**
  95344. * Fired every time the active button is changed.
  95345. *
  95346. * When xr is entered via a button that launches xr that button will be the callback parameter
  95347. *
  95348. * When exiting xr the callback parameter will be null)
  95349. */
  95350. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95351. /**
  95352. * Creates UI to allow the user to enter/exit XR mode
  95353. * @param scene the scene to add the ui to
  95354. * @param helper the xr experience helper to enter/exit xr with
  95355. * @param options options to configure the UI
  95356. * @returns the created ui
  95357. */
  95358. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95359. private constructor();
  95360. private _updateButtons;
  95361. /**
  95362. * Disposes of the object
  95363. */
  95364. dispose(): void;
  95365. }
  95366. }
  95367. declare module BABYLON {
  95368. /**
  95369. * Represents an XR input
  95370. */
  95371. export class WebXRController {
  95372. /**
  95373. * 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
  95374. */
  95375. grip?: AbstractMesh;
  95376. /**
  95377. * Pointer which can be used to select objects or attach a visible laser to
  95378. */
  95379. pointer: AbstractMesh;
  95380. /**
  95381. * Creates the controller
  95382. * @see https://doc.babylonjs.com/how_to/webxr
  95383. * @param scene the scene which the controller should be associated to
  95384. */
  95385. constructor(scene: Scene);
  95386. /**
  95387. * Disposes of the object
  95388. */
  95389. dispose(): void;
  95390. }
  95391. /**
  95392. * XR input used to track XR inputs such as controllers/rays
  95393. */
  95394. export class WebXRInput implements IDisposable {
  95395. private helper;
  95396. /**
  95397. * XR controllers being tracked
  95398. */
  95399. controllers: Array<WebXRController>;
  95400. private _tmpMatrix;
  95401. private _frameObserver;
  95402. /**
  95403. * Initializes the WebXRInput
  95404. * @param helper experience helper which the input should be created for
  95405. */
  95406. constructor(helper: WebXRExperienceHelper);
  95407. /**
  95408. * Disposes of the object
  95409. */
  95410. dispose(): void;
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95416. */
  95417. export class WebXRManagedOutputCanvas implements IDisposable {
  95418. private _canvas;
  95419. /**
  95420. * xrpresent context of the canvas which can be used to display/mirror xr content
  95421. */
  95422. canvasContext: Nullable<WebGLRenderingContext>;
  95423. /**
  95424. * Initializes the canvas to be added/removed upon entering/exiting xr
  95425. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95426. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95427. */
  95428. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95429. /**
  95430. * Disposes of the object
  95431. */
  95432. dispose(): void;
  95433. private _setManagedOutputCanvas;
  95434. private _addCanvas;
  95435. private _removeCanvas;
  95436. }
  95437. }
  95438. declare module BABYLON {
  95439. /**
  95440. * Contains an array of blocks representing the octree
  95441. */
  95442. export interface IOctreeContainer<T> {
  95443. /**
  95444. * Blocks within the octree
  95445. */
  95446. blocks: Array<OctreeBlock<T>>;
  95447. }
  95448. /**
  95449. * Class used to store a cell in an octree
  95450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95451. */
  95452. export class OctreeBlock<T> {
  95453. /**
  95454. * Gets the content of the current block
  95455. */
  95456. entries: T[];
  95457. /**
  95458. * Gets the list of block children
  95459. */
  95460. blocks: Array<OctreeBlock<T>>;
  95461. private _depth;
  95462. private _maxDepth;
  95463. private _capacity;
  95464. private _minPoint;
  95465. private _maxPoint;
  95466. private _boundingVectors;
  95467. private _creationFunc;
  95468. /**
  95469. * Creates a new block
  95470. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95471. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95472. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95473. * @param depth defines the current depth of this block in the octree
  95474. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95475. * @param creationFunc defines a callback to call when an element is added to the block
  95476. */
  95477. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95478. /**
  95479. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95480. */
  95481. readonly capacity: number;
  95482. /**
  95483. * Gets the minimum vector (in world space) of the block's bounding box
  95484. */
  95485. readonly minPoint: Vector3;
  95486. /**
  95487. * Gets the maximum vector (in world space) of the block's bounding box
  95488. */
  95489. readonly maxPoint: Vector3;
  95490. /**
  95491. * Add a new element to this block
  95492. * @param entry defines the element to add
  95493. */
  95494. addEntry(entry: T): void;
  95495. /**
  95496. * Remove an element from this block
  95497. * @param entry defines the element to remove
  95498. */
  95499. removeEntry(entry: T): void;
  95500. /**
  95501. * Add an array of elements to this block
  95502. * @param entries defines the array of elements to add
  95503. */
  95504. addEntries(entries: T[]): void;
  95505. /**
  95506. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95507. * @param frustumPlanes defines the frustum planes to test
  95508. * @param selection defines the array to store current content if selection is positive
  95509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95510. */
  95511. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95512. /**
  95513. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95514. * @param sphereCenter defines the bounding sphere center
  95515. * @param sphereRadius defines the bounding sphere radius
  95516. * @param selection defines the array to store current content if selection is positive
  95517. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95518. */
  95519. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95520. /**
  95521. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95522. * @param ray defines the ray to test with
  95523. * @param selection defines the array to store current content if selection is positive
  95524. */
  95525. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95526. /**
  95527. * Subdivide the content into child blocks (this block will then be empty)
  95528. */
  95529. createInnerBlocks(): void;
  95530. /**
  95531. * @hidden
  95532. */
  95533. 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;
  95534. }
  95535. }
  95536. declare module BABYLON {
  95537. /**
  95538. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95540. */
  95541. export class Octree<T> {
  95542. /** 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.) */
  95543. maxDepth: number;
  95544. /**
  95545. * Blocks within the octree containing objects
  95546. */
  95547. blocks: Array<OctreeBlock<T>>;
  95548. /**
  95549. * Content stored in the octree
  95550. */
  95551. dynamicContent: T[];
  95552. private _maxBlockCapacity;
  95553. private _selectionContent;
  95554. private _creationFunc;
  95555. /**
  95556. * Creates a octree
  95557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95558. * @param creationFunc function to be used to instatiate the octree
  95559. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95560. * @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.)
  95561. */
  95562. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95563. /** 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.) */
  95564. maxDepth?: number);
  95565. /**
  95566. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95567. * @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);
  95568. * @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);
  95569. * @param entries meshes to be added to the octree blocks
  95570. */
  95571. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95572. /**
  95573. * Adds a mesh to the octree
  95574. * @param entry Mesh to add to the octree
  95575. */
  95576. addMesh(entry: T): void;
  95577. /**
  95578. * Remove an element from the octree
  95579. * @param entry defines the element to remove
  95580. */
  95581. removeMesh(entry: T): void;
  95582. /**
  95583. * Selects an array of meshes within the frustum
  95584. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95585. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95586. * @returns array of meshes within the frustum
  95587. */
  95588. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95589. /**
  95590. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95591. * @param sphereCenter defines the bounding sphere center
  95592. * @param sphereRadius defines the bounding sphere radius
  95593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95594. * @returns an array of objects that intersect the sphere
  95595. */
  95596. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95597. /**
  95598. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95599. * @param ray defines the ray to test with
  95600. * @returns array of intersected objects
  95601. */
  95602. intersectsRay(ray: Ray): SmartArray<T>;
  95603. /**
  95604. * Adds a mesh into the octree block if it intersects the block
  95605. */
  95606. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95607. /**
  95608. * Adds a submesh into the octree block if it intersects the block
  95609. */
  95610. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95611. }
  95612. }
  95613. declare module BABYLON {
  95614. interface Scene {
  95615. /**
  95616. * @hidden
  95617. * Backing Filed
  95618. */
  95619. _selectionOctree: Octree<AbstractMesh>;
  95620. /**
  95621. * Gets the octree used to boost mesh selection (picking)
  95622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95623. */
  95624. selectionOctree: Octree<AbstractMesh>;
  95625. /**
  95626. * Creates or updates the octree used to boost selection (picking)
  95627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95628. * @param maxCapacity defines the maximum capacity per leaf
  95629. * @param maxDepth defines the maximum depth of the octree
  95630. * @returns an octree of AbstractMesh
  95631. */
  95632. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95633. }
  95634. interface AbstractMesh {
  95635. /**
  95636. * @hidden
  95637. * Backing Field
  95638. */
  95639. _submeshesOctree: Octree<SubMesh>;
  95640. /**
  95641. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95642. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95643. * @param maxCapacity defines the maximum size of each block (64 by default)
  95644. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95645. * @returns the new octree
  95646. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95648. */
  95649. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95650. }
  95651. /**
  95652. * Defines the octree scene component responsible to manage any octrees
  95653. * in a given scene.
  95654. */
  95655. export class OctreeSceneComponent {
  95656. /**
  95657. * The component name helpfull to identify the component in the list of scene components.
  95658. */
  95659. readonly name: string;
  95660. /**
  95661. * The scene the component belongs to.
  95662. */
  95663. scene: Scene;
  95664. /**
  95665. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95666. */
  95667. readonly checksIsEnabled: boolean;
  95668. /**
  95669. * Creates a new instance of the component for the given scene
  95670. * @param scene Defines the scene to register the component in
  95671. */
  95672. constructor(scene: Scene);
  95673. /**
  95674. * Registers the component in a given scene
  95675. */
  95676. register(): void;
  95677. /**
  95678. * Return the list of active meshes
  95679. * @returns the list of active meshes
  95680. */
  95681. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95682. /**
  95683. * Return the list of active sub meshes
  95684. * @param mesh The mesh to get the candidates sub meshes from
  95685. * @returns the list of active sub meshes
  95686. */
  95687. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95688. private _tempRay;
  95689. /**
  95690. * Return the list of sub meshes intersecting with a given local ray
  95691. * @param mesh defines the mesh to find the submesh for
  95692. * @param localRay defines the ray in local space
  95693. * @returns the list of intersecting sub meshes
  95694. */
  95695. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95696. /**
  95697. * Return the list of sub meshes colliding with a collider
  95698. * @param mesh defines the mesh to find the submesh for
  95699. * @param collider defines the collider to evaluate the collision against
  95700. * @returns the list of colliding sub meshes
  95701. */
  95702. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95703. /**
  95704. * Rebuilds the elements related to this component in case of
  95705. * context lost for instance.
  95706. */
  95707. rebuild(): void;
  95708. /**
  95709. * Disposes the component and the associated ressources.
  95710. */
  95711. dispose(): void;
  95712. }
  95713. }
  95714. declare module BABYLON {
  95715. /**
  95716. * Class containing static functions to help procedurally build meshes
  95717. */
  95718. export class LinesBuilder {
  95719. /**
  95720. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95721. * * 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
  95722. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95723. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95724. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95725. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95726. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95727. * * 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
  95728. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95731. * @param name defines the name of the new line system
  95732. * @param options defines the options used to create the line system
  95733. * @param scene defines the hosting scene
  95734. * @returns a new line system mesh
  95735. */
  95736. static CreateLineSystem(name: string, options: {
  95737. lines: Vector3[][];
  95738. updatable?: boolean;
  95739. instance?: Nullable<LinesMesh>;
  95740. colors?: Nullable<Color4[][]>;
  95741. useVertexAlpha?: boolean;
  95742. }, scene: Nullable<Scene>): LinesMesh;
  95743. /**
  95744. * Creates a line mesh
  95745. * 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
  95746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95747. * * The parameter `points` is an array successive Vector3
  95748. * * 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
  95749. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95750. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95751. * * When updating an instance, remember that only point positions can change, not the number of points
  95752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95754. * @param name defines the name of the new line system
  95755. * @param options defines the options used to create the line system
  95756. * @param scene defines the hosting scene
  95757. * @returns a new line mesh
  95758. */
  95759. static CreateLines(name: string, options: {
  95760. points: Vector3[];
  95761. updatable?: boolean;
  95762. instance?: Nullable<LinesMesh>;
  95763. colors?: Color4[];
  95764. useVertexAlpha?: boolean;
  95765. }, scene?: Nullable<Scene>): LinesMesh;
  95766. /**
  95767. * Creates a dashed line mesh
  95768. * * 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
  95769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95770. * * The parameter `points` is an array successive Vector3
  95771. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95772. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95773. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95774. * * 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
  95775. * * When updating an instance, remember that only point positions can change, not the number of points
  95776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95777. * @param name defines the name of the mesh
  95778. * @param options defines the options used to create the mesh
  95779. * @param scene defines the hosting scene
  95780. * @returns the dashed line mesh
  95781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95782. */
  95783. static CreateDashedLines(name: string, options: {
  95784. points: Vector3[];
  95785. dashSize?: number;
  95786. gapSize?: number;
  95787. dashNb?: number;
  95788. updatable?: boolean;
  95789. instance?: LinesMesh;
  95790. }, scene?: Nullable<Scene>): LinesMesh;
  95791. }
  95792. }
  95793. declare module BABYLON {
  95794. /**
  95795. * Renders a layer on top of an existing scene
  95796. */
  95797. export class UtilityLayerRenderer implements IDisposable {
  95798. /** the original scene that will be rendered on top of */
  95799. originalScene: Scene;
  95800. private _pointerCaptures;
  95801. private _lastPointerEvents;
  95802. private static _DefaultUtilityLayer;
  95803. private static _DefaultKeepDepthUtilityLayer;
  95804. /**
  95805. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95806. */
  95807. pickUtilitySceneFirst: boolean;
  95808. /**
  95809. * 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)
  95810. */
  95811. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95812. /**
  95813. * 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)
  95814. */
  95815. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95816. /**
  95817. * The scene that is rendered on top of the original scene
  95818. */
  95819. utilityLayerScene: Scene;
  95820. /**
  95821. * If the utility layer should automatically be rendered on top of existing scene
  95822. */
  95823. shouldRender: boolean;
  95824. /**
  95825. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95826. */
  95827. onlyCheckPointerDownEvents: boolean;
  95828. /**
  95829. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95830. */
  95831. processAllEvents: boolean;
  95832. /**
  95833. * Observable raised when the pointer move from the utility layer scene to the main scene
  95834. */
  95835. onPointerOutObservable: Observable<number>;
  95836. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95837. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95838. private _afterRenderObserver;
  95839. private _sceneDisposeObserver;
  95840. private _originalPointerObserver;
  95841. /**
  95842. * Instantiates a UtilityLayerRenderer
  95843. * @param originalScene the original scene that will be rendered on top of
  95844. * @param handleEvents boolean indicating if the utility layer should handle events
  95845. */
  95846. constructor(
  95847. /** the original scene that will be rendered on top of */
  95848. originalScene: Scene, handleEvents?: boolean);
  95849. private _notifyObservers;
  95850. /**
  95851. * Renders the utility layers scene on top of the original scene
  95852. */
  95853. render(): void;
  95854. /**
  95855. * Disposes of the renderer
  95856. */
  95857. dispose(): void;
  95858. private _updateCamera;
  95859. }
  95860. }
  95861. declare module BABYLON {
  95862. /**
  95863. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95864. */
  95865. export class Gizmo implements IDisposable {
  95866. /** The utility layer the gizmo will be added to */
  95867. gizmoLayer: UtilityLayerRenderer;
  95868. /**
  95869. * The root mesh of the gizmo
  95870. */
  95871. protected _rootMesh: Mesh;
  95872. private _attachedMesh;
  95873. /**
  95874. * Ratio for the scale of the gizmo (Default: 1)
  95875. */
  95876. scaleRatio: number;
  95877. private _tmpMatrix;
  95878. /**
  95879. * If a custom mesh has been set (Default: false)
  95880. */
  95881. protected _customMeshSet: boolean;
  95882. /**
  95883. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95884. * * When set, interactions will be enabled
  95885. */
  95886. attachedMesh: Nullable<AbstractMesh>;
  95887. /**
  95888. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95889. * @param mesh The mesh to replace the default mesh of the gizmo
  95890. */
  95891. setCustomMesh(mesh: Mesh): void;
  95892. /**
  95893. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95894. */
  95895. updateGizmoRotationToMatchAttachedMesh: boolean;
  95896. /**
  95897. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95898. */
  95899. updateGizmoPositionToMatchAttachedMesh: boolean;
  95900. /**
  95901. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95902. */
  95903. protected _updateScale: boolean;
  95904. protected _interactionsEnabled: boolean;
  95905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95906. private _beforeRenderObserver;
  95907. /**
  95908. * Creates a gizmo
  95909. * @param gizmoLayer The utility layer the gizmo will be added to
  95910. */
  95911. constructor(
  95912. /** The utility layer the gizmo will be added to */
  95913. gizmoLayer?: UtilityLayerRenderer);
  95914. private _tempVector;
  95915. /**
  95916. * @hidden
  95917. * Updates the gizmo to match the attached mesh's position/rotation
  95918. */
  95919. protected _update(): void;
  95920. /**
  95921. * Disposes of the gizmo
  95922. */
  95923. dispose(): void;
  95924. }
  95925. }
  95926. declare module BABYLON {
  95927. /**
  95928. * Single axis drag gizmo
  95929. */
  95930. export class AxisDragGizmo extends Gizmo {
  95931. /**
  95932. * Drag behavior responsible for the gizmos dragging interactions
  95933. */
  95934. dragBehavior: PointerDragBehavior;
  95935. private _pointerObserver;
  95936. /**
  95937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  95938. */
  95939. snapDistance: number;
  95940. /**
  95941. * Event that fires each time the gizmo snaps to a new location.
  95942. * * snapDistance is the the change in distance
  95943. */
  95944. onSnapObservable: Observable<{
  95945. snapDistance: number;
  95946. }>;
  95947. /** @hidden */
  95948. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  95949. /** @hidden */
  95950. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  95951. /**
  95952. * Creates an AxisDragGizmo
  95953. * @param gizmoLayer The utility layer the gizmo will be added to
  95954. * @param dragAxis The axis which the gizmo will be able to drag on
  95955. * @param color The color of the gizmo
  95956. */
  95957. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  95958. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95959. /**
  95960. * Disposes of the gizmo
  95961. */
  95962. dispose(): void;
  95963. }
  95964. }
  95965. declare module BABYLON.Debug {
  95966. /**
  95967. * The Axes viewer will show 3 axes in a specific point in space
  95968. */
  95969. export class AxesViewer {
  95970. private _xAxis;
  95971. private _yAxis;
  95972. private _zAxis;
  95973. private _scaleLinesFactor;
  95974. private _instanced;
  95975. /**
  95976. * Gets the hosting scene
  95977. */
  95978. scene: Scene;
  95979. /**
  95980. * Gets or sets a number used to scale line length
  95981. */
  95982. scaleLines: number;
  95983. /** Gets the node hierarchy used to render x-axis */
  95984. readonly xAxis: TransformNode;
  95985. /** Gets the node hierarchy used to render y-axis */
  95986. readonly yAxis: TransformNode;
  95987. /** Gets the node hierarchy used to render z-axis */
  95988. readonly zAxis: TransformNode;
  95989. /**
  95990. * Creates a new AxesViewer
  95991. * @param scene defines the hosting scene
  95992. * @param scaleLines defines a number used to scale line length (1 by default)
  95993. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  95994. * @param xAxis defines the node hierarchy used to render the x-axis
  95995. * @param yAxis defines the node hierarchy used to render the y-axis
  95996. * @param zAxis defines the node hierarchy used to render the z-axis
  95997. */
  95998. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  95999. /**
  96000. * Force the viewer to update
  96001. * @param position defines the position of the viewer
  96002. * @param xaxis defines the x axis of the viewer
  96003. * @param yaxis defines the y axis of the viewer
  96004. * @param zaxis defines the z axis of the viewer
  96005. */
  96006. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96007. /**
  96008. * Creates an instance of this axes viewer.
  96009. * @returns a new axes viewer with instanced meshes
  96010. */
  96011. createInstance(): AxesViewer;
  96012. /** Releases resources */
  96013. dispose(): void;
  96014. private static _SetRenderingGroupId;
  96015. }
  96016. }
  96017. declare module BABYLON.Debug {
  96018. /**
  96019. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96020. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96021. */
  96022. export class BoneAxesViewer extends AxesViewer {
  96023. /**
  96024. * Gets or sets the target mesh where to display the axes viewer
  96025. */
  96026. mesh: Nullable<Mesh>;
  96027. /**
  96028. * Gets or sets the target bone where to display the axes viewer
  96029. */
  96030. bone: Nullable<Bone>;
  96031. /** Gets current position */
  96032. pos: Vector3;
  96033. /** Gets direction of X axis */
  96034. xaxis: Vector3;
  96035. /** Gets direction of Y axis */
  96036. yaxis: Vector3;
  96037. /** Gets direction of Z axis */
  96038. zaxis: Vector3;
  96039. /**
  96040. * Creates a new BoneAxesViewer
  96041. * @param scene defines the hosting scene
  96042. * @param bone defines the target bone
  96043. * @param mesh defines the target mesh
  96044. * @param scaleLines defines a scaling factor for line length (1 by default)
  96045. */
  96046. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96047. /**
  96048. * Force the viewer to update
  96049. */
  96050. update(): void;
  96051. /** Releases resources */
  96052. dispose(): void;
  96053. }
  96054. }
  96055. declare module BABYLON {
  96056. /**
  96057. * Interface used to define scene explorer extensibility option
  96058. */
  96059. export interface IExplorerExtensibilityOption {
  96060. /**
  96061. * Define the option label
  96062. */
  96063. label: string;
  96064. /**
  96065. * Defines the action to execute on click
  96066. */
  96067. action: (entity: any) => void;
  96068. }
  96069. /**
  96070. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96071. */
  96072. export interface IExplorerExtensibilityGroup {
  96073. /**
  96074. * Defines a predicate to test if a given type mut be extended
  96075. */
  96076. predicate: (entity: any) => boolean;
  96077. /**
  96078. * Gets the list of options added to a type
  96079. */
  96080. entries: IExplorerExtensibilityOption[];
  96081. }
  96082. /**
  96083. * Interface used to define the options to use to create the Inspector
  96084. */
  96085. export interface IInspectorOptions {
  96086. /**
  96087. * Display in overlay mode (default: false)
  96088. */
  96089. overlay?: boolean;
  96090. /**
  96091. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96092. */
  96093. globalRoot?: HTMLElement;
  96094. /**
  96095. * Display the Scene explorer
  96096. */
  96097. showExplorer?: boolean;
  96098. /**
  96099. * Display the property inspector
  96100. */
  96101. showInspector?: boolean;
  96102. /**
  96103. * Display in embed mode (both panes on the right)
  96104. */
  96105. embedMode?: boolean;
  96106. /**
  96107. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96108. */
  96109. handleResize?: boolean;
  96110. /**
  96111. * Allow the panes to popup (default: true)
  96112. */
  96113. enablePopup?: boolean;
  96114. /**
  96115. * Allow the panes to be closed by users (default: true)
  96116. */
  96117. enableClose?: boolean;
  96118. /**
  96119. * Optional list of extensibility entries
  96120. */
  96121. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96122. }
  96123. interface Scene {
  96124. /**
  96125. * @hidden
  96126. * Backing field
  96127. */
  96128. _debugLayer: DebugLayer;
  96129. /**
  96130. * Gets the debug layer (aka Inspector) associated with the scene
  96131. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96132. */
  96133. debugLayer: DebugLayer;
  96134. }
  96135. /**
  96136. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96137. * what is happening in your scene
  96138. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96139. */
  96140. export class DebugLayer {
  96141. /**
  96142. * Define the url to get the inspector script from.
  96143. * By default it uses the babylonjs CDN.
  96144. * @ignoreNaming
  96145. */
  96146. static InspectorURL: string;
  96147. private _scene;
  96148. private BJSINSPECTOR;
  96149. /**
  96150. * Observable triggered when a property is changed through the inspector.
  96151. */
  96152. onPropertyChangedObservable: Observable<{
  96153. object: any;
  96154. property: string;
  96155. value: any;
  96156. initialValue: any;
  96157. }>;
  96158. /**
  96159. * Instantiates a new debug layer.
  96160. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96161. * what is happening in your scene
  96162. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96163. * @param scene Defines the scene to inspect
  96164. */
  96165. constructor(scene: Scene);
  96166. /** Creates the inspector window. */
  96167. private _createInspector;
  96168. /** Get the inspector from bundle or global */
  96169. private _getGlobalInspector;
  96170. /**
  96171. * Get if the inspector is visible or not.
  96172. * @returns true if visible otherwise, false
  96173. */
  96174. isVisible(): boolean;
  96175. /**
  96176. * Hide the inspector and close its window.
  96177. */
  96178. hide(): void;
  96179. /**
  96180. * Launch the debugLayer.
  96181. * @param config Define the configuration of the inspector
  96182. */
  96183. show(config?: IInspectorOptions): void;
  96184. }
  96185. }
  96186. declare module BABYLON {
  96187. /**
  96188. * Class containing static functions to help procedurally build meshes
  96189. */
  96190. export class BoxBuilder {
  96191. /**
  96192. * Creates a box mesh
  96193. * * The parameter `size` sets the size (float) of each box side (default 1)
  96194. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96195. * * 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)
  96196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96200. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96201. * @param name defines the name of the mesh
  96202. * @param options defines the options used to create the mesh
  96203. * @param scene defines the hosting scene
  96204. * @returns the box mesh
  96205. */
  96206. static CreateBox(name: string, options: {
  96207. size?: number;
  96208. width?: number;
  96209. height?: number;
  96210. depth?: number;
  96211. faceUV?: Vector4[];
  96212. faceColors?: Color4[];
  96213. sideOrientation?: number;
  96214. frontUVs?: Vector4;
  96215. backUVs?: Vector4;
  96216. updatable?: boolean;
  96217. }, scene?: Nullable<Scene>): Mesh;
  96218. }
  96219. }
  96220. declare module BABYLON {
  96221. /**
  96222. * Class containing static functions to help procedurally build meshes
  96223. */
  96224. export class SphereBuilder {
  96225. /**
  96226. * Creates a sphere mesh
  96227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96228. * * 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`)
  96229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96230. * * 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
  96231. * * 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)
  96232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96235. * @param name defines the name of the mesh
  96236. * @param options defines the options used to create the mesh
  96237. * @param scene defines the hosting scene
  96238. * @returns the sphere mesh
  96239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96240. */
  96241. static CreateSphere(name: string, options: {
  96242. segments?: number;
  96243. diameter?: number;
  96244. diameterX?: number;
  96245. diameterY?: number;
  96246. diameterZ?: number;
  96247. arc?: number;
  96248. slice?: number;
  96249. sideOrientation?: number;
  96250. frontUVs?: Vector4;
  96251. backUVs?: Vector4;
  96252. updatable?: boolean;
  96253. }, scene: any): Mesh;
  96254. }
  96255. }
  96256. declare module BABYLON.Debug {
  96257. /**
  96258. * Used to show the physics impostor around the specific mesh
  96259. */
  96260. export class PhysicsViewer {
  96261. /** @hidden */
  96262. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96263. /** @hidden */
  96264. protected _meshes: Array<Nullable<AbstractMesh>>;
  96265. /** @hidden */
  96266. protected _scene: Nullable<Scene>;
  96267. /** @hidden */
  96268. protected _numMeshes: number;
  96269. /** @hidden */
  96270. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96271. private _renderFunction;
  96272. private _utilityLayer;
  96273. private _debugBoxMesh;
  96274. private _debugSphereMesh;
  96275. private _debugMaterial;
  96276. /**
  96277. * Creates a new PhysicsViewer
  96278. * @param scene defines the hosting scene
  96279. */
  96280. constructor(scene: Scene);
  96281. /** @hidden */
  96282. protected _updateDebugMeshes(): void;
  96283. /**
  96284. * Renders a specified physic impostor
  96285. * @param impostor defines the impostor to render
  96286. * @returns the new debug mesh used to render the impostor
  96287. */
  96288. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96289. /**
  96290. * Hides a specified physic impostor
  96291. * @param impostor defines the impostor to hide
  96292. */
  96293. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96294. private _getDebugMaterial;
  96295. private _getDebugBoxMesh;
  96296. private _getDebugSphereMesh;
  96297. private _getDebugMesh;
  96298. /** Releases all resources */
  96299. dispose(): void;
  96300. }
  96301. }
  96302. declare module BABYLON {
  96303. /**
  96304. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96305. * in order to better appreciate the issue one might have.
  96306. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96307. */
  96308. export class RayHelper {
  96309. /**
  96310. * Defines the ray we are currently tryin to visualize.
  96311. */
  96312. ray: Nullable<Ray>;
  96313. private _renderPoints;
  96314. private _renderLine;
  96315. private _renderFunction;
  96316. private _scene;
  96317. private _updateToMeshFunction;
  96318. private _attachedToMesh;
  96319. private _meshSpaceDirection;
  96320. private _meshSpaceOrigin;
  96321. /**
  96322. * Helper function to create a colored helper in a scene in one line.
  96323. * @param ray Defines the ray we are currently tryin to visualize
  96324. * @param scene Defines the scene the ray is used in
  96325. * @param color Defines the color we want to see the ray in
  96326. * @returns The newly created ray helper.
  96327. */
  96328. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96329. /**
  96330. * Instantiate a new ray helper.
  96331. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96332. * in order to better appreciate the issue one might have.
  96333. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96334. * @param ray Defines the ray we are currently tryin to visualize
  96335. */
  96336. constructor(ray: Ray);
  96337. /**
  96338. * Shows the ray we are willing to debug.
  96339. * @param scene Defines the scene the ray needs to be rendered in
  96340. * @param color Defines the color the ray needs to be rendered in
  96341. */
  96342. show(scene: Scene, color?: Color3): void;
  96343. /**
  96344. * Hides the ray we are debugging.
  96345. */
  96346. hide(): void;
  96347. private _render;
  96348. /**
  96349. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96350. * @param mesh Defines the mesh we want the helper attached to
  96351. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96352. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96353. * @param length Defines the length of the ray
  96354. */
  96355. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96356. /**
  96357. * Detach the ray helper from the mesh it has previously been attached to.
  96358. */
  96359. detachFromMesh(): void;
  96360. private _updateToMesh;
  96361. /**
  96362. * Dispose the helper and release its associated resources.
  96363. */
  96364. dispose(): void;
  96365. }
  96366. }
  96367. declare module BABYLON.Debug {
  96368. /**
  96369. * Class used to render a debug view of a given skeleton
  96370. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96371. */
  96372. export class SkeletonViewer {
  96373. /** defines the skeleton to render */
  96374. skeleton: Skeleton;
  96375. /** defines the mesh attached to the skeleton */
  96376. mesh: AbstractMesh;
  96377. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96378. autoUpdateBonesMatrices: boolean;
  96379. /** defines the rendering group id to use with the viewer */
  96380. renderingGroupId: number;
  96381. /** Gets or sets the color used to render the skeleton */
  96382. color: Color3;
  96383. private _scene;
  96384. private _debugLines;
  96385. private _debugMesh;
  96386. private _isEnabled;
  96387. private _renderFunction;
  96388. private _utilityLayer;
  96389. /**
  96390. * Returns the mesh used to render the bones
  96391. */
  96392. readonly debugMesh: Nullable<LinesMesh>;
  96393. /**
  96394. * Creates a new SkeletonViewer
  96395. * @param skeleton defines the skeleton to render
  96396. * @param mesh defines the mesh attached to the skeleton
  96397. * @param scene defines the hosting scene
  96398. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96399. * @param renderingGroupId defines the rendering group id to use with the viewer
  96400. */
  96401. constructor(
  96402. /** defines the skeleton to render */
  96403. skeleton: Skeleton,
  96404. /** defines the mesh attached to the skeleton */
  96405. mesh: AbstractMesh, scene: Scene,
  96406. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96407. autoUpdateBonesMatrices?: boolean,
  96408. /** defines the rendering group id to use with the viewer */
  96409. renderingGroupId?: number);
  96410. /** Gets or sets a boolean indicating if the viewer is enabled */
  96411. isEnabled: boolean;
  96412. private _getBonePosition;
  96413. private _getLinesForBonesWithLength;
  96414. private _getLinesForBonesNoLength;
  96415. /** Update the viewer to sync with current skeleton state */
  96416. update(): void;
  96417. /** Release associated resources */
  96418. dispose(): void;
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. /**
  96423. * Options to create the null engine
  96424. */
  96425. export class NullEngineOptions {
  96426. /**
  96427. * Render width (Default: 512)
  96428. */
  96429. renderWidth: number;
  96430. /**
  96431. * Render height (Default: 256)
  96432. */
  96433. renderHeight: number;
  96434. /**
  96435. * Texture size (Default: 512)
  96436. */
  96437. textureSize: number;
  96438. /**
  96439. * If delta time between frames should be constant
  96440. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96441. */
  96442. deterministicLockstep: boolean;
  96443. /**
  96444. * Maximum about of steps between frames (Default: 4)
  96445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96446. */
  96447. lockstepMaxSteps: number;
  96448. }
  96449. /**
  96450. * The null engine class provides support for headless version of babylon.js.
  96451. * This can be used in server side scenario or for testing purposes
  96452. */
  96453. export class NullEngine extends Engine {
  96454. private _options;
  96455. /**
  96456. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96457. */
  96458. isDeterministicLockStep(): boolean;
  96459. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96460. getLockstepMaxSteps(): number;
  96461. /**
  96462. * Sets hardware scaling, used to save performance if needed
  96463. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96464. */
  96465. getHardwareScalingLevel(): number;
  96466. constructor(options?: NullEngineOptions);
  96467. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96468. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96469. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96470. getRenderWidth(useScreen?: boolean): number;
  96471. getRenderHeight(useScreen?: boolean): number;
  96472. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96473. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96474. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96475. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96476. bindSamplers(effect: Effect): void;
  96477. enableEffect(effect: Effect): void;
  96478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96479. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96480. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96481. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96482. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96483. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96484. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96485. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96486. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96487. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96488. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96489. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96490. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96491. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96492. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96493. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96494. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96495. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96496. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96497. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96498. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96499. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96500. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96501. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96502. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96503. bindBuffers(vertexBuffers: {
  96504. [key: string]: VertexBuffer;
  96505. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96506. wipeCaches(bruteForce?: boolean): void;
  96507. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96508. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96509. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96510. /** @hidden */
  96511. _createTexture(): WebGLTexture;
  96512. /** @hidden */
  96513. _releaseTexture(texture: InternalTexture): void;
  96514. 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;
  96515. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96516. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96517. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96518. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96519. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96520. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96521. areAllEffectsReady(): boolean;
  96522. /**
  96523. * @hidden
  96524. * Get the current error code of the webGL context
  96525. * @returns the error code
  96526. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96527. */
  96528. getError(): number;
  96529. /** @hidden */
  96530. _getUnpackAlignement(): number;
  96531. /** @hidden */
  96532. _unpackFlipY(value: boolean): void;
  96533. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96534. /**
  96535. * Updates a dynamic vertex buffer.
  96536. * @param vertexBuffer the vertex buffer to update
  96537. * @param data the data used to update the vertex buffer
  96538. * @param byteOffset the byte offset of the data (optional)
  96539. * @param byteLength the byte length of the data (optional)
  96540. */
  96541. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96542. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96543. /** @hidden */
  96544. _bindTexture(channel: number, texture: InternalTexture): void;
  96545. /** @hidden */
  96546. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96547. releaseEffects(): void;
  96548. displayLoadingUI(): void;
  96549. hideLoadingUI(): void;
  96550. /** @hidden */
  96551. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96552. /** @hidden */
  96553. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96554. /** @hidden */
  96555. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96556. /** @hidden */
  96557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96558. }
  96559. }
  96560. declare module BABYLON {
  96561. /** @hidden */
  96562. export class _OcclusionDataStorage {
  96563. /** @hidden */
  96564. occlusionInternalRetryCounter: number;
  96565. /** @hidden */
  96566. isOcclusionQueryInProgress: boolean;
  96567. /** @hidden */
  96568. isOccluded: boolean;
  96569. /** @hidden */
  96570. occlusionRetryCount: number;
  96571. /** @hidden */
  96572. occlusionType: number;
  96573. /** @hidden */
  96574. occlusionQueryAlgorithmType: number;
  96575. }
  96576. interface Engine {
  96577. /**
  96578. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96579. * @return the new query
  96580. */
  96581. createQuery(): WebGLQuery;
  96582. /**
  96583. * Delete and release a webGL query
  96584. * @param query defines the query to delete
  96585. * @return the current engine
  96586. */
  96587. deleteQuery(query: WebGLQuery): Engine;
  96588. /**
  96589. * Check if a given query has resolved and got its value
  96590. * @param query defines the query to check
  96591. * @returns true if the query got its value
  96592. */
  96593. isQueryResultAvailable(query: WebGLQuery): boolean;
  96594. /**
  96595. * Gets the value of a given query
  96596. * @param query defines the query to check
  96597. * @returns the value of the query
  96598. */
  96599. getQueryResult(query: WebGLQuery): number;
  96600. /**
  96601. * Initiates an occlusion query
  96602. * @param algorithmType defines the algorithm to use
  96603. * @param query defines the query to use
  96604. * @returns the current engine
  96605. * @see http://doc.babylonjs.com/features/occlusionquery
  96606. */
  96607. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96608. /**
  96609. * Ends an occlusion query
  96610. * @see http://doc.babylonjs.com/features/occlusionquery
  96611. * @param algorithmType defines the algorithm to use
  96612. * @returns the current engine
  96613. */
  96614. endOcclusionQuery(algorithmType: number): Engine;
  96615. /**
  96616. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96617. * Please note that only one query can be issued at a time
  96618. * @returns a time token used to track the time span
  96619. */
  96620. startTimeQuery(): Nullable<_TimeToken>;
  96621. /**
  96622. * Ends a time query
  96623. * @param token defines the token used to measure the time span
  96624. * @returns the time spent (in ns)
  96625. */
  96626. endTimeQuery(token: _TimeToken): int;
  96627. /** @hidden */
  96628. _currentNonTimestampToken: Nullable<_TimeToken>;
  96629. /** @hidden */
  96630. _createTimeQuery(): WebGLQuery;
  96631. /** @hidden */
  96632. _deleteTimeQuery(query: WebGLQuery): void;
  96633. /** @hidden */
  96634. _getGlAlgorithmType(algorithmType: number): number;
  96635. /** @hidden */
  96636. _getTimeQueryResult(query: WebGLQuery): any;
  96637. /** @hidden */
  96638. _getTimeQueryAvailability(query: WebGLQuery): any;
  96639. }
  96640. interface AbstractMesh {
  96641. /**
  96642. * Backing filed
  96643. * @hidden
  96644. */
  96645. __occlusionDataStorage: _OcclusionDataStorage;
  96646. /**
  96647. * Access property
  96648. * @hidden
  96649. */
  96650. _occlusionDataStorage: _OcclusionDataStorage;
  96651. /**
  96652. * 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.
  96653. * The default value is -1 which means don't break the query and wait till the result
  96654. * @see http://doc.babylonjs.com/features/occlusionquery
  96655. */
  96656. occlusionRetryCount: number;
  96657. /**
  96658. * 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:
  96659. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96660. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96661. * * 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.
  96662. * @see http://doc.babylonjs.com/features/occlusionquery
  96663. */
  96664. occlusionType: number;
  96665. /**
  96666. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96667. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96668. * * 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.
  96669. * @see http://doc.babylonjs.com/features/occlusionquery
  96670. */
  96671. occlusionQueryAlgorithmType: number;
  96672. /**
  96673. * 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
  96674. * @see http://doc.babylonjs.com/features/occlusionquery
  96675. */
  96676. isOccluded: boolean;
  96677. /**
  96678. * Flag to check the progress status of the query
  96679. * @see http://doc.babylonjs.com/features/occlusionquery
  96680. */
  96681. isOcclusionQueryInProgress: boolean;
  96682. }
  96683. }
  96684. declare module BABYLON {
  96685. /** @hidden */
  96686. export var _forceTransformFeedbackToBundle: boolean;
  96687. interface Engine {
  96688. /**
  96689. * Creates a webGL transform feedback object
  96690. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96691. * @returns the webGL transform feedback object
  96692. */
  96693. createTransformFeedback(): WebGLTransformFeedback;
  96694. /**
  96695. * Delete a webGL transform feedback object
  96696. * @param value defines the webGL transform feedback object to delete
  96697. */
  96698. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96699. /**
  96700. * Bind a webGL transform feedback object to the webgl context
  96701. * @param value defines the webGL transform feedback object to bind
  96702. */
  96703. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96704. /**
  96705. * Begins a transform feedback operation
  96706. * @param usePoints defines if points or triangles must be used
  96707. */
  96708. beginTransformFeedback(usePoints: boolean): void;
  96709. /**
  96710. * Ends a transform feedback operation
  96711. */
  96712. endTransformFeedback(): void;
  96713. /**
  96714. * Specify the varyings to use with transform feedback
  96715. * @param program defines the associated webGL program
  96716. * @param value defines the list of strings representing the varying names
  96717. */
  96718. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96719. /**
  96720. * Bind a webGL buffer for a transform feedback operation
  96721. * @param value defines the webGL buffer to bind
  96722. */
  96723. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96724. }
  96725. }
  96726. declare module BABYLON {
  96727. /**
  96728. * Gather the list of clipboard event types as constants.
  96729. */
  96730. export class ClipboardEventTypes {
  96731. /**
  96732. * The clipboard event is fired when a copy command is active (pressed).
  96733. */
  96734. static readonly COPY: number;
  96735. /**
  96736. * The clipboard event is fired when a cut command is active (pressed).
  96737. */
  96738. static readonly CUT: number;
  96739. /**
  96740. * The clipboard event is fired when a paste command is active (pressed).
  96741. */
  96742. static readonly PASTE: number;
  96743. }
  96744. /**
  96745. * This class is used to store clipboard related info for the onClipboardObservable event.
  96746. */
  96747. export class ClipboardInfo {
  96748. /**
  96749. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96750. */
  96751. type: number;
  96752. /**
  96753. * Defines the related dom event
  96754. */
  96755. event: ClipboardEvent;
  96756. /**
  96757. *Creates an instance of ClipboardInfo.
  96758. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96759. * @param event Defines the related dom event
  96760. */
  96761. constructor(
  96762. /**
  96763. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96764. */
  96765. type: number,
  96766. /**
  96767. * Defines the related dom event
  96768. */
  96769. event: ClipboardEvent);
  96770. /**
  96771. * Get the clipboard event's type from the keycode.
  96772. * @param keyCode Defines the keyCode for the current keyboard event.
  96773. * @return {number}
  96774. */
  96775. static GetTypeFromCharacter(keyCode: number): number;
  96776. }
  96777. }
  96778. declare module BABYLON {
  96779. /**
  96780. * Class used to represent data loading progression
  96781. */
  96782. export class SceneLoaderProgressEvent {
  96783. /** defines if data length to load can be evaluated */
  96784. readonly lengthComputable: boolean;
  96785. /** defines the loaded data length */
  96786. readonly loaded: number;
  96787. /** defines the data length to load */
  96788. readonly total: number;
  96789. /**
  96790. * Create a new progress event
  96791. * @param lengthComputable defines if data length to load can be evaluated
  96792. * @param loaded defines the loaded data length
  96793. * @param total defines the data length to load
  96794. */
  96795. constructor(
  96796. /** defines if data length to load can be evaluated */
  96797. lengthComputable: boolean,
  96798. /** defines the loaded data length */
  96799. loaded: number,
  96800. /** defines the data length to load */
  96801. total: number);
  96802. /**
  96803. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96804. * @param event defines the source event
  96805. * @returns a new SceneLoaderProgressEvent
  96806. */
  96807. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96808. }
  96809. /**
  96810. * Interface used by SceneLoader plugins to define supported file extensions
  96811. */
  96812. export interface ISceneLoaderPluginExtensions {
  96813. /**
  96814. * Defines the list of supported extensions
  96815. */
  96816. [extension: string]: {
  96817. isBinary: boolean;
  96818. };
  96819. }
  96820. /**
  96821. * Interface used by SceneLoader plugin factory
  96822. */
  96823. export interface ISceneLoaderPluginFactory {
  96824. /**
  96825. * Defines the name of the factory
  96826. */
  96827. name: string;
  96828. /**
  96829. * Function called to create a new plugin
  96830. * @return the new plugin
  96831. */
  96832. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96833. /**
  96834. * Boolean indicating if the plugin can direct load specific data
  96835. */
  96836. canDirectLoad?: (data: string) => boolean;
  96837. }
  96838. /**
  96839. * Interface used to define a SceneLoader plugin
  96840. */
  96841. export interface ISceneLoaderPlugin {
  96842. /**
  96843. * The friendly name of this plugin.
  96844. */
  96845. name: string;
  96846. /**
  96847. * The file extensions supported by this plugin.
  96848. */
  96849. extensions: string | ISceneLoaderPluginExtensions;
  96850. /**
  96851. * Import meshes into a scene.
  96852. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96853. * @param scene The scene to import into
  96854. * @param data The data to import
  96855. * @param rootUrl The root url for scene and resources
  96856. * @param meshes The meshes array to import into
  96857. * @param particleSystems The particle systems array to import into
  96858. * @param skeletons The skeletons array to import into
  96859. * @param onError The callback when import fails
  96860. * @returns True if successful or false otherwise
  96861. */
  96862. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96863. /**
  96864. * Load into a scene.
  96865. * @param scene The scene to load into
  96866. * @param data The data to import
  96867. * @param rootUrl The root url for scene and resources
  96868. * @param onError The callback when import fails
  96869. * @returns true if successful or false otherwise
  96870. */
  96871. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96872. /**
  96873. * The callback that returns true if the data can be directly loaded.
  96874. */
  96875. canDirectLoad?: (data: string) => boolean;
  96876. /**
  96877. * The callback that allows custom handling of the root url based on the response url.
  96878. */
  96879. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96880. /**
  96881. * Load into an asset container.
  96882. * @param scene The scene to load into
  96883. * @param data The data to import
  96884. * @param rootUrl The root url for scene and resources
  96885. * @param onError The callback when import fails
  96886. * @returns The loaded asset container
  96887. */
  96888. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96889. }
  96890. /**
  96891. * Interface used to define an async SceneLoader plugin
  96892. */
  96893. export interface ISceneLoaderPluginAsync {
  96894. /**
  96895. * The friendly name of this plugin.
  96896. */
  96897. name: string;
  96898. /**
  96899. * The file extensions supported by this plugin.
  96900. */
  96901. extensions: string | ISceneLoaderPluginExtensions;
  96902. /**
  96903. * Import meshes into a scene.
  96904. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96905. * @param scene The scene to import into
  96906. * @param data The data to import
  96907. * @param rootUrl The root url for scene and resources
  96908. * @param onProgress The callback when the load progresses
  96909. * @param fileName Defines the name of the file to load
  96910. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96911. */
  96912. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96913. meshes: AbstractMesh[];
  96914. particleSystems: IParticleSystem[];
  96915. skeletons: Skeleton[];
  96916. animationGroups: AnimationGroup[];
  96917. }>;
  96918. /**
  96919. * Load into a scene.
  96920. * @param scene The scene to load into
  96921. * @param data The data to import
  96922. * @param rootUrl The root url for scene and resources
  96923. * @param onProgress The callback when the load progresses
  96924. * @param fileName Defines the name of the file to load
  96925. * @returns Nothing
  96926. */
  96927. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  96928. /**
  96929. * The callback that returns true if the data can be directly loaded.
  96930. */
  96931. canDirectLoad?: (data: string) => boolean;
  96932. /**
  96933. * The callback that allows custom handling of the root url based on the response url.
  96934. */
  96935. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96936. /**
  96937. * Load into an asset container.
  96938. * @param scene The scene to load into
  96939. * @param data The data to import
  96940. * @param rootUrl The root url for scene and resources
  96941. * @param onProgress The callback when the load progresses
  96942. * @param fileName Defines the name of the file to load
  96943. * @returns The loaded asset container
  96944. */
  96945. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  96946. }
  96947. /**
  96948. * Class used to load scene from various file formats using registered plugins
  96949. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  96950. */
  96951. export class SceneLoader {
  96952. /**
  96953. * No logging while loading
  96954. */
  96955. static readonly NO_LOGGING: number;
  96956. /**
  96957. * Minimal logging while loading
  96958. */
  96959. static readonly MINIMAL_LOGGING: number;
  96960. /**
  96961. * Summary logging while loading
  96962. */
  96963. static readonly SUMMARY_LOGGING: number;
  96964. /**
  96965. * Detailled logging while loading
  96966. */
  96967. static readonly DETAILED_LOGGING: number;
  96968. /**
  96969. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96970. */
  96971. static ForceFullSceneLoadingForIncremental: boolean;
  96972. /**
  96973. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96974. */
  96975. static ShowLoadingScreen: boolean;
  96976. /**
  96977. * Defines the current logging level (while loading the scene)
  96978. * @ignorenaming
  96979. */
  96980. static loggingLevel: number;
  96981. /**
  96982. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96983. */
  96984. static CleanBoneMatrixWeights: boolean;
  96985. /**
  96986. * Event raised when a plugin is used to load a scene
  96987. */
  96988. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  96989. private static _registeredPlugins;
  96990. private static _getDefaultPlugin;
  96991. private static _getPluginForExtension;
  96992. private static _getPluginForDirectLoad;
  96993. private static _getPluginForFilename;
  96994. private static _getDirectLoad;
  96995. private static _loadData;
  96996. private static _getFileInfo;
  96997. /**
  96998. * Gets a plugin that can load the given extension
  96999. * @param extension defines the extension to load
  97000. * @returns a plugin or null if none works
  97001. */
  97002. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97003. /**
  97004. * Gets a boolean indicating that the given extension can be loaded
  97005. * @param extension defines the extension to load
  97006. * @returns true if the extension is supported
  97007. */
  97008. static IsPluginForExtensionAvailable(extension: string): boolean;
  97009. /**
  97010. * Adds a new plugin to the list of registered plugins
  97011. * @param plugin defines the plugin to add
  97012. */
  97013. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97014. /**
  97015. * Import meshes into a scene
  97016. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97017. * @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)
  97018. * @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)
  97019. * @param scene the instance of BABYLON.Scene to append to
  97020. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97021. * @param onProgress a callback with a progress event for each file being loaded
  97022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97023. * @param pluginExtension the extension used to determine the plugin
  97024. * @returns The loaded plugin
  97025. */
  97026. 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>;
  97027. /**
  97028. * Import meshes into a scene
  97029. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97030. * @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)
  97031. * @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)
  97032. * @param scene the instance of BABYLON.Scene to append to
  97033. * @param onProgress a callback with a progress event for each file being loaded
  97034. * @param pluginExtension the extension used to determine the plugin
  97035. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97036. */
  97037. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97038. meshes: AbstractMesh[];
  97039. particleSystems: IParticleSystem[];
  97040. skeletons: Skeleton[];
  97041. animationGroups: AnimationGroup[];
  97042. }>;
  97043. /**
  97044. * Load a scene
  97045. * @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)
  97046. * @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)
  97047. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97048. * @param onSuccess a callback with the scene when import succeeds
  97049. * @param onProgress a callback with a progress event for each file being loaded
  97050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97051. * @param pluginExtension the extension used to determine the plugin
  97052. * @returns The loaded plugin
  97053. */
  97054. 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>;
  97055. /**
  97056. * Load a scene
  97057. * @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)
  97058. * @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)
  97059. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97060. * @param onProgress a callback with a progress event for each file being loaded
  97061. * @param pluginExtension the extension used to determine the plugin
  97062. * @returns The loaded scene
  97063. */
  97064. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97065. /**
  97066. * Append a scene
  97067. * @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)
  97068. * @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)
  97069. * @param scene is the instance of BABYLON.Scene to append to
  97070. * @param onSuccess a callback with the scene when import succeeds
  97071. * @param onProgress a callback with a progress event for each file being loaded
  97072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97073. * @param pluginExtension the extension used to determine the plugin
  97074. * @returns The loaded plugin
  97075. */
  97076. 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>;
  97077. /**
  97078. * Append a scene
  97079. * @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)
  97080. * @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)
  97081. * @param scene is the instance of BABYLON.Scene to append to
  97082. * @param onProgress a callback with a progress event for each file being loaded
  97083. * @param pluginExtension the extension used to determine the plugin
  97084. * @returns The given scene
  97085. */
  97086. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97087. /**
  97088. * Load a scene into an asset container
  97089. * @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)
  97090. * @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)
  97091. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97092. * @param onSuccess a callback with the scene when import succeeds
  97093. * @param onProgress a callback with a progress event for each file being loaded
  97094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97095. * @param pluginExtension the extension used to determine the plugin
  97096. * @returns The loaded plugin
  97097. */
  97098. 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>;
  97099. /**
  97100. * Load a scene into an asset container
  97101. * @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)
  97102. * @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)
  97103. * @param scene is the instance of Scene to append to
  97104. * @param onProgress a callback with a progress event for each file being loaded
  97105. * @param pluginExtension the extension used to determine the plugin
  97106. * @returns The loaded asset container
  97107. */
  97108. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97109. }
  97110. }
  97111. declare module BABYLON {
  97112. /**
  97113. * Google Daydream controller
  97114. */
  97115. export class DaydreamController extends WebVRController {
  97116. /**
  97117. * Base Url for the controller model.
  97118. */
  97119. static MODEL_BASE_URL: string;
  97120. /**
  97121. * File name for the controller model.
  97122. */
  97123. static MODEL_FILENAME: string;
  97124. /**
  97125. * Gamepad Id prefix used to identify Daydream Controller.
  97126. */
  97127. static readonly GAMEPAD_ID_PREFIX: string;
  97128. /**
  97129. * Creates a new DaydreamController from a gamepad
  97130. * @param vrGamepad the gamepad that the controller should be created from
  97131. */
  97132. constructor(vrGamepad: any);
  97133. /**
  97134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97135. * @param scene scene in which to add meshes
  97136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97137. */
  97138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97139. /**
  97140. * Called once for each button that changed state since the last frame
  97141. * @param buttonIdx Which button index changed
  97142. * @param state New state of the button
  97143. * @param changes Which properties on the state changed since last frame
  97144. */
  97145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97146. }
  97147. }
  97148. declare module BABYLON {
  97149. /**
  97150. * Gear VR Controller
  97151. */
  97152. export class GearVRController extends WebVRController {
  97153. /**
  97154. * Base Url for the controller model.
  97155. */
  97156. static MODEL_BASE_URL: string;
  97157. /**
  97158. * File name for the controller model.
  97159. */
  97160. static MODEL_FILENAME: string;
  97161. /**
  97162. * Gamepad Id prefix used to identify this controller.
  97163. */
  97164. static readonly GAMEPAD_ID_PREFIX: string;
  97165. private readonly _buttonIndexToObservableNameMap;
  97166. /**
  97167. * Creates a new GearVRController from a gamepad
  97168. * @param vrGamepad the gamepad that the controller should be created from
  97169. */
  97170. constructor(vrGamepad: any);
  97171. /**
  97172. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97173. * @param scene scene in which to add meshes
  97174. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97175. */
  97176. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97177. /**
  97178. * Called once for each button that changed state since the last frame
  97179. * @param buttonIdx Which button index changed
  97180. * @param state New state of the button
  97181. * @param changes Which properties on the state changed since last frame
  97182. */
  97183. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97184. }
  97185. }
  97186. declare module BABYLON {
  97187. /**
  97188. * Generic Controller
  97189. */
  97190. export class GenericController extends WebVRController {
  97191. /**
  97192. * Base Url for the controller model.
  97193. */
  97194. static readonly MODEL_BASE_URL: string;
  97195. /**
  97196. * File name for the controller model.
  97197. */
  97198. static readonly MODEL_FILENAME: string;
  97199. /**
  97200. * Creates a new GenericController from a gamepad
  97201. * @param vrGamepad the gamepad that the controller should be created from
  97202. */
  97203. constructor(vrGamepad: any);
  97204. /**
  97205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97206. * @param scene scene in which to add meshes
  97207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97208. */
  97209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97210. /**
  97211. * Called once for each button that changed state since the last frame
  97212. * @param buttonIdx Which button index changed
  97213. * @param state New state of the button
  97214. * @param changes Which properties on the state changed since last frame
  97215. */
  97216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97217. }
  97218. }
  97219. declare module BABYLON {
  97220. /**
  97221. * Oculus Touch Controller
  97222. */
  97223. export class OculusTouchController extends WebVRController {
  97224. /**
  97225. * Base Url for the controller model.
  97226. */
  97227. static MODEL_BASE_URL: string;
  97228. /**
  97229. * File name for the left controller model.
  97230. */
  97231. static MODEL_LEFT_FILENAME: string;
  97232. /**
  97233. * File name for the right controller model.
  97234. */
  97235. static MODEL_RIGHT_FILENAME: string;
  97236. /**
  97237. * Fired when the secondary trigger on this controller is modified
  97238. */
  97239. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97240. /**
  97241. * Fired when the thumb rest on this controller is modified
  97242. */
  97243. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97244. /**
  97245. * Creates a new OculusTouchController from a gamepad
  97246. * @param vrGamepad the gamepad that the controller should be created from
  97247. */
  97248. constructor(vrGamepad: any);
  97249. /**
  97250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97251. * @param scene scene in which to add meshes
  97252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97253. */
  97254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97255. /**
  97256. * Fired when the A button on this controller is modified
  97257. */
  97258. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97259. /**
  97260. * Fired when the B button on this controller is modified
  97261. */
  97262. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97263. /**
  97264. * Fired when the X button on this controller is modified
  97265. */
  97266. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97267. /**
  97268. * Fired when the Y button on this controller is modified
  97269. */
  97270. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97271. /**
  97272. * Called once for each button that changed state since the last frame
  97273. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97274. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97275. * 2) secondary trigger (same)
  97276. * 3) A (right) X (left), touch, pressed = value
  97277. * 4) B / Y
  97278. * 5) thumb rest
  97279. * @param buttonIdx Which button index changed
  97280. * @param state New state of the button
  97281. * @param changes Which properties on the state changed since last frame
  97282. */
  97283. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97284. }
  97285. }
  97286. declare module BABYLON {
  97287. /**
  97288. * Vive Controller
  97289. */
  97290. export class ViveController extends WebVRController {
  97291. /**
  97292. * Base Url for the controller model.
  97293. */
  97294. static MODEL_BASE_URL: string;
  97295. /**
  97296. * File name for the controller model.
  97297. */
  97298. static MODEL_FILENAME: string;
  97299. /**
  97300. * Creates a new ViveController from a gamepad
  97301. * @param vrGamepad the gamepad that the controller should be created from
  97302. */
  97303. constructor(vrGamepad: any);
  97304. /**
  97305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97306. * @param scene scene in which to add meshes
  97307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97308. */
  97309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97310. /**
  97311. * Fired when the left button on this controller is modified
  97312. */
  97313. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97314. /**
  97315. * Fired when the right button on this controller is modified
  97316. */
  97317. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97318. /**
  97319. * Fired when the menu button on this controller is modified
  97320. */
  97321. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97322. /**
  97323. * Called once for each button that changed state since the last frame
  97324. * Vive mapping:
  97325. * 0: touchpad
  97326. * 1: trigger
  97327. * 2: left AND right buttons
  97328. * 3: menu button
  97329. * @param buttonIdx Which button index changed
  97330. * @param state New state of the button
  97331. * @param changes Which properties on the state changed since last frame
  97332. */
  97333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97334. }
  97335. }
  97336. declare module BABYLON {
  97337. /**
  97338. * Defines the WindowsMotionController object that the state of the windows motion controller
  97339. */
  97340. export class WindowsMotionController extends WebVRController {
  97341. /**
  97342. * The base url used to load the left and right controller models
  97343. */
  97344. static MODEL_BASE_URL: string;
  97345. /**
  97346. * The name of the left controller model file
  97347. */
  97348. static MODEL_LEFT_FILENAME: string;
  97349. /**
  97350. * The name of the right controller model file
  97351. */
  97352. static MODEL_RIGHT_FILENAME: string;
  97353. /**
  97354. * The controller name prefix for this controller type
  97355. */
  97356. static readonly GAMEPAD_ID_PREFIX: string;
  97357. /**
  97358. * The controller id pattern for this controller type
  97359. */
  97360. private static readonly GAMEPAD_ID_PATTERN;
  97361. private _loadedMeshInfo;
  97362. private readonly _mapping;
  97363. /**
  97364. * Fired when the trackpad on this controller is clicked
  97365. */
  97366. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97367. /**
  97368. * Fired when the trackpad on this controller is modified
  97369. */
  97370. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97371. /**
  97372. * The current x and y values of this controller's trackpad
  97373. */
  97374. trackpad: StickValues;
  97375. /**
  97376. * Creates a new WindowsMotionController from a gamepad
  97377. * @param vrGamepad the gamepad that the controller should be created from
  97378. */
  97379. constructor(vrGamepad: any);
  97380. /**
  97381. * Fired when the trigger on this controller is modified
  97382. */
  97383. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97384. /**
  97385. * Fired when the menu button on this controller is modified
  97386. */
  97387. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97388. /**
  97389. * Fired when the grip button on this controller is modified
  97390. */
  97391. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97392. /**
  97393. * Fired when the thumbstick button on this controller is modified
  97394. */
  97395. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97396. /**
  97397. * Fired when the touchpad button on this controller is modified
  97398. */
  97399. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97400. /**
  97401. * Fired when the touchpad values on this controller are modified
  97402. */
  97403. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97404. private _updateTrackpad;
  97405. /**
  97406. * Called once per frame by the engine.
  97407. */
  97408. update(): void;
  97409. /**
  97410. * Called once for each button that changed state since the last frame
  97411. * @param buttonIdx Which button index changed
  97412. * @param state New state of the button
  97413. * @param changes Which properties on the state changed since last frame
  97414. */
  97415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97416. /**
  97417. * Moves the buttons on the controller mesh based on their current state
  97418. * @param buttonName the name of the button to move
  97419. * @param buttonValue the value of the button which determines the buttons new position
  97420. */
  97421. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97422. /**
  97423. * Moves the axis on the controller mesh based on its current state
  97424. * @param axis the index of the axis
  97425. * @param axisValue the value of the axis which determines the meshes new position
  97426. * @hidden
  97427. */
  97428. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97429. /**
  97430. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97431. * @param scene scene in which to add meshes
  97432. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97433. */
  97434. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97435. /**
  97436. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97437. * can be transformed by button presses and axes values, based on this._mapping.
  97438. *
  97439. * @param scene scene in which the meshes exist
  97440. * @param meshes list of meshes that make up the controller model to process
  97441. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97442. */
  97443. private processModel;
  97444. private createMeshInfo;
  97445. /**
  97446. * Gets the ray of the controller in the direction the controller is pointing
  97447. * @param length the length the resulting ray should be
  97448. * @returns a ray in the direction the controller is pointing
  97449. */
  97450. getForwardRay(length?: number): Ray;
  97451. /**
  97452. * Disposes of the controller
  97453. */
  97454. dispose(): void;
  97455. }
  97456. }
  97457. declare module BABYLON {
  97458. /**
  97459. * Single axis scale gizmo
  97460. */
  97461. export class AxisScaleGizmo extends Gizmo {
  97462. private _coloredMaterial;
  97463. /**
  97464. * Drag behavior responsible for the gizmos dragging interactions
  97465. */
  97466. dragBehavior: PointerDragBehavior;
  97467. private _pointerObserver;
  97468. /**
  97469. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97470. */
  97471. snapDistance: number;
  97472. /**
  97473. * Event that fires each time the gizmo snaps to a new location.
  97474. * * snapDistance is the the change in distance
  97475. */
  97476. onSnapObservable: Observable<{
  97477. snapDistance: number;
  97478. }>;
  97479. /**
  97480. * If the scaling operation should be done on all axis (default: false)
  97481. */
  97482. uniformScaling: boolean;
  97483. /**
  97484. * Creates an AxisScaleGizmo
  97485. * @param gizmoLayer The utility layer the gizmo will be added to
  97486. * @param dragAxis The axis which the gizmo will be able to scale on
  97487. * @param color The color of the gizmo
  97488. */
  97489. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97490. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97491. /**
  97492. * Disposes of the gizmo
  97493. */
  97494. dispose(): void;
  97495. /**
  97496. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97497. * @param mesh The mesh to replace the default mesh of the gizmo
  97498. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97499. */
  97500. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97501. }
  97502. }
  97503. declare module BABYLON {
  97504. /**
  97505. * Bounding box gizmo
  97506. */
  97507. export class BoundingBoxGizmo extends Gizmo {
  97508. private _lineBoundingBox;
  97509. private _rotateSpheresParent;
  97510. private _scaleBoxesParent;
  97511. private _boundingDimensions;
  97512. private _renderObserver;
  97513. private _pointerObserver;
  97514. private _scaleDragSpeed;
  97515. private _tmpQuaternion;
  97516. private _tmpVector;
  97517. private _tmpRotationMatrix;
  97518. /**
  97519. * 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)
  97520. */
  97521. ignoreChildren: boolean;
  97522. /**
  97523. * 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)
  97524. */
  97525. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97526. /**
  97527. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97528. */
  97529. rotationSphereSize: number;
  97530. /**
  97531. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97532. */
  97533. scaleBoxSize: number;
  97534. /**
  97535. * 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)
  97536. */
  97537. fixedDragMeshScreenSize: boolean;
  97538. /**
  97539. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97540. */
  97541. fixedDragMeshScreenSizeDistanceFactor: number;
  97542. /**
  97543. * Fired when a rotation sphere or scale box is dragged
  97544. */
  97545. onDragStartObservable: Observable<{}>;
  97546. /**
  97547. * Fired when a scale box is dragged
  97548. */
  97549. onScaleBoxDragObservable: Observable<{}>;
  97550. /**
  97551. * Fired when a scale box drag is ended
  97552. */
  97553. onScaleBoxDragEndObservable: Observable<{}>;
  97554. /**
  97555. * Fired when a rotation sphere is dragged
  97556. */
  97557. onRotationSphereDragObservable: Observable<{}>;
  97558. /**
  97559. * Fired when a rotation sphere drag is ended
  97560. */
  97561. onRotationSphereDragEndObservable: Observable<{}>;
  97562. /**
  97563. * 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)
  97564. */
  97565. scalePivot: Nullable<Vector3>;
  97566. private _anchorMesh;
  97567. private _existingMeshScale;
  97568. private _dragMesh;
  97569. private pointerDragBehavior;
  97570. /**
  97571. * Creates an BoundingBoxGizmo
  97572. * @param gizmoLayer The utility layer the gizmo will be added to
  97573. * @param color The color of the gizmo
  97574. */
  97575. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97576. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97577. private _selectNode;
  97578. /**
  97579. * Updates the bounding box information for the Gizmo
  97580. */
  97581. updateBoundingBox(): void;
  97582. private _updateRotationSpheres;
  97583. private _updateScaleBoxes;
  97584. /**
  97585. * Enables rotation on the specified axis and disables rotation on the others
  97586. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97587. */
  97588. setEnabledRotationAxis(axis: string): void;
  97589. /**
  97590. * Enables/disables scaling
  97591. * @param enable if scaling should be enabled
  97592. */
  97593. setEnabledScaling(enable: boolean): void;
  97594. private _updateDummy;
  97595. /**
  97596. * Enables a pointer drag behavior on the bounding box of the gizmo
  97597. */
  97598. enableDragBehavior(): void;
  97599. /**
  97600. * Disposes of the gizmo
  97601. */
  97602. dispose(): void;
  97603. /**
  97604. * 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)
  97605. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97606. * @returns the bounding box mesh with the passed in mesh as a child
  97607. */
  97608. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97609. /**
  97610. * CustomMeshes are not supported by this gizmo
  97611. * @param mesh The mesh to replace the default mesh of the gizmo
  97612. */
  97613. setCustomMesh(mesh: Mesh): void;
  97614. }
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * Single plane rotation gizmo
  97619. */
  97620. export class PlaneRotationGizmo extends Gizmo {
  97621. /**
  97622. * Drag behavior responsible for the gizmos dragging interactions
  97623. */
  97624. dragBehavior: PointerDragBehavior;
  97625. private _pointerObserver;
  97626. /**
  97627. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97628. */
  97629. snapDistance: number;
  97630. /**
  97631. * Event that fires each time the gizmo snaps to a new location.
  97632. * * snapDistance is the the change in distance
  97633. */
  97634. onSnapObservable: Observable<{
  97635. snapDistance: number;
  97636. }>;
  97637. /**
  97638. * Creates a PlaneRotationGizmo
  97639. * @param gizmoLayer The utility layer the gizmo will be added to
  97640. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97641. * @param color The color of the gizmo
  97642. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97643. */
  97644. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97645. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97646. /**
  97647. * Disposes of the gizmo
  97648. */
  97649. dispose(): void;
  97650. }
  97651. }
  97652. declare module BABYLON {
  97653. /**
  97654. * Gizmo that enables rotating a mesh along 3 axis
  97655. */
  97656. export class RotationGizmo extends Gizmo {
  97657. /**
  97658. * Internal gizmo used for interactions on the x axis
  97659. */
  97660. xGizmo: PlaneRotationGizmo;
  97661. /**
  97662. * Internal gizmo used for interactions on the y axis
  97663. */
  97664. yGizmo: PlaneRotationGizmo;
  97665. /**
  97666. * Internal gizmo used for interactions on the z axis
  97667. */
  97668. zGizmo: PlaneRotationGizmo;
  97669. /** Fires an event when any of it's sub gizmos are dragged */
  97670. onDragStartObservable: Observable<{}>;
  97671. /** Fires an event when any of it's sub gizmos are released from dragging */
  97672. onDragEndObservable: Observable<{}>;
  97673. attachedMesh: Nullable<AbstractMesh>;
  97674. /**
  97675. * Creates a RotationGizmo
  97676. * @param gizmoLayer The utility layer the gizmo will be added to
  97677. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97678. */
  97679. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97680. updateGizmoRotationToMatchAttachedMesh: boolean;
  97681. /**
  97682. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97683. */
  97684. snapDistance: number;
  97685. /**
  97686. * Ratio for the scale of the gizmo (Default: 1)
  97687. */
  97688. scaleRatio: number;
  97689. /**
  97690. * Disposes of the gizmo
  97691. */
  97692. dispose(): void;
  97693. /**
  97694. * CustomMeshes are not supported by this gizmo
  97695. * @param mesh The mesh to replace the default mesh of the gizmo
  97696. */
  97697. setCustomMesh(mesh: Mesh): void;
  97698. }
  97699. }
  97700. declare module BABYLON {
  97701. /**
  97702. * Gizmo that enables dragging a mesh along 3 axis
  97703. */
  97704. export class PositionGizmo extends Gizmo {
  97705. /**
  97706. * Internal gizmo used for interactions on the x axis
  97707. */
  97708. xGizmo: AxisDragGizmo;
  97709. /**
  97710. * Internal gizmo used for interactions on the y axis
  97711. */
  97712. yGizmo: AxisDragGizmo;
  97713. /**
  97714. * Internal gizmo used for interactions on the z axis
  97715. */
  97716. zGizmo: AxisDragGizmo;
  97717. /** Fires an event when any of it's sub gizmos are dragged */
  97718. onDragStartObservable: Observable<{}>;
  97719. /** Fires an event when any of it's sub gizmos are released from dragging */
  97720. onDragEndObservable: Observable<{}>;
  97721. attachedMesh: Nullable<AbstractMesh>;
  97722. /**
  97723. * Creates a PositionGizmo
  97724. * @param gizmoLayer The utility layer the gizmo will be added to
  97725. */
  97726. constructor(gizmoLayer?: UtilityLayerRenderer);
  97727. updateGizmoRotationToMatchAttachedMesh: boolean;
  97728. /**
  97729. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97730. */
  97731. snapDistance: number;
  97732. /**
  97733. * Ratio for the scale of the gizmo (Default: 1)
  97734. */
  97735. scaleRatio: number;
  97736. /**
  97737. * Disposes of the gizmo
  97738. */
  97739. dispose(): void;
  97740. /**
  97741. * CustomMeshes are not supported by this gizmo
  97742. * @param mesh The mesh to replace the default mesh of the gizmo
  97743. */
  97744. setCustomMesh(mesh: Mesh): void;
  97745. }
  97746. }
  97747. declare module BABYLON {
  97748. /**
  97749. * Class containing static functions to help procedurally build meshes
  97750. */
  97751. export class PolyhedronBuilder {
  97752. /**
  97753. * Creates a polyhedron mesh
  97754. * * 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
  97755. * * The parameter `size` (positive float, default 1) sets the polygon size
  97756. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97757. * * 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`
  97758. * * 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
  97759. * * 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)`)
  97760. * * 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
  97761. * * 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
  97762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97765. * @param name defines the name of the mesh
  97766. * @param options defines the options used to create the mesh
  97767. * @param scene defines the hosting scene
  97768. * @returns the polyhedron mesh
  97769. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97770. */
  97771. static CreatePolyhedron(name: string, options: {
  97772. type?: number;
  97773. size?: number;
  97774. sizeX?: number;
  97775. sizeY?: number;
  97776. sizeZ?: number;
  97777. custom?: any;
  97778. faceUV?: Vector4[];
  97779. faceColors?: Color4[];
  97780. flat?: boolean;
  97781. updatable?: boolean;
  97782. sideOrientation?: number;
  97783. frontUVs?: Vector4;
  97784. backUVs?: Vector4;
  97785. }, scene: Scene): Mesh;
  97786. }
  97787. }
  97788. declare module BABYLON {
  97789. /**
  97790. * Gizmo that enables scaling a mesh along 3 axis
  97791. */
  97792. export class ScaleGizmo extends Gizmo {
  97793. /**
  97794. * Internal gizmo used for interactions on the x axis
  97795. */
  97796. xGizmo: AxisScaleGizmo;
  97797. /**
  97798. * Internal gizmo used for interactions on the y axis
  97799. */
  97800. yGizmo: AxisScaleGizmo;
  97801. /**
  97802. * Internal gizmo used for interactions on the z axis
  97803. */
  97804. zGizmo: AxisScaleGizmo;
  97805. /**
  97806. * Internal gizmo used to scale all axis equally
  97807. */
  97808. uniformScaleGizmo: AxisScaleGizmo;
  97809. /** Fires an event when any of it's sub gizmos are dragged */
  97810. onDragStartObservable: Observable<{}>;
  97811. /** Fires an event when any of it's sub gizmos are released from dragging */
  97812. onDragEndObservable: Observable<{}>;
  97813. attachedMesh: Nullable<AbstractMesh>;
  97814. /**
  97815. * Creates a ScaleGizmo
  97816. * @param gizmoLayer The utility layer the gizmo will be added to
  97817. */
  97818. constructor(gizmoLayer?: UtilityLayerRenderer);
  97819. updateGizmoRotationToMatchAttachedMesh: boolean;
  97820. /**
  97821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97822. */
  97823. snapDistance: number;
  97824. /**
  97825. * Ratio for the scale of the gizmo (Default: 1)
  97826. */
  97827. scaleRatio: number;
  97828. /**
  97829. * Disposes of the gizmo
  97830. */
  97831. dispose(): void;
  97832. }
  97833. }
  97834. declare module BABYLON {
  97835. /**
  97836. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97837. */
  97838. export class GizmoManager implements IDisposable {
  97839. private scene;
  97840. /**
  97841. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97842. */
  97843. gizmos: {
  97844. positionGizmo: Nullable<PositionGizmo>;
  97845. rotationGizmo: Nullable<RotationGizmo>;
  97846. scaleGizmo: Nullable<ScaleGizmo>;
  97847. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97848. };
  97849. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97850. clearGizmoOnEmptyPointerEvent: boolean;
  97851. /** Fires an event when the manager is attached to a mesh */
  97852. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97853. private _gizmosEnabled;
  97854. private _pointerObserver;
  97855. private _attachedMesh;
  97856. private _boundingBoxColor;
  97857. private _defaultUtilityLayer;
  97858. private _defaultKeepDepthUtilityLayer;
  97859. /**
  97860. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97861. */
  97862. boundingBoxDragBehavior: SixDofDragBehavior;
  97863. /**
  97864. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97865. */
  97866. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97867. /**
  97868. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97869. */
  97870. usePointerToAttachGizmos: boolean;
  97871. /**
  97872. * Instatiates a gizmo manager
  97873. * @param scene the scene to overlay the gizmos on top of
  97874. */
  97875. constructor(scene: Scene);
  97876. /**
  97877. * Attaches a set of gizmos to the specified mesh
  97878. * @param mesh The mesh the gizmo's should be attached to
  97879. */
  97880. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97881. /**
  97882. * If the position gizmo is enabled
  97883. */
  97884. positionGizmoEnabled: boolean;
  97885. /**
  97886. * If the rotation gizmo is enabled
  97887. */
  97888. rotationGizmoEnabled: boolean;
  97889. /**
  97890. * If the scale gizmo is enabled
  97891. */
  97892. scaleGizmoEnabled: boolean;
  97893. /**
  97894. * If the boundingBox gizmo is enabled
  97895. */
  97896. boundingBoxGizmoEnabled: boolean;
  97897. /**
  97898. * Disposes of the gizmo manager
  97899. */
  97900. dispose(): void;
  97901. }
  97902. }
  97903. declare module BABYLON {
  97904. /** @hidden */
  97905. export var backgroundFragmentDeclaration: {
  97906. name: string;
  97907. shader: string;
  97908. };
  97909. }
  97910. declare module BABYLON {
  97911. /** @hidden */
  97912. export var backgroundUboDeclaration: {
  97913. name: string;
  97914. shader: string;
  97915. };
  97916. }
  97917. declare module BABYLON {
  97918. /** @hidden */
  97919. export var backgroundPixelShader: {
  97920. name: string;
  97921. shader: string;
  97922. };
  97923. }
  97924. declare module BABYLON {
  97925. /** @hidden */
  97926. export var backgroundVertexDeclaration: {
  97927. name: string;
  97928. shader: string;
  97929. };
  97930. }
  97931. declare module BABYLON {
  97932. /** @hidden */
  97933. export var backgroundVertexShader: {
  97934. name: string;
  97935. shader: string;
  97936. };
  97937. }
  97938. declare module BABYLON {
  97939. /**
  97940. * Background material used to create an efficient environement around your scene.
  97941. */
  97942. export class BackgroundMaterial extends PushMaterial {
  97943. /**
  97944. * Standard reflectance value at parallel view angle.
  97945. */
  97946. static StandardReflectance0: number;
  97947. /**
  97948. * Standard reflectance value at grazing angle.
  97949. */
  97950. static StandardReflectance90: number;
  97951. protected _primaryColor: Color3;
  97952. /**
  97953. * Key light Color (multiply against the environement texture)
  97954. */
  97955. primaryColor: Color3;
  97956. protected __perceptualColor: Nullable<Color3>;
  97957. /**
  97958. * Experimental Internal Use Only.
  97959. *
  97960. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  97961. * This acts as a helper to set the primary color to a more "human friendly" value.
  97962. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  97963. * output color as close as possible from the chosen value.
  97964. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  97965. * part of lighting setup.)
  97966. */
  97967. _perceptualColor: Nullable<Color3>;
  97968. protected _primaryColorShadowLevel: float;
  97969. /**
  97970. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  97971. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  97972. */
  97973. primaryColorShadowLevel: float;
  97974. protected _primaryColorHighlightLevel: float;
  97975. /**
  97976. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  97977. * The primary color is used at the level chosen to define what the white area would look.
  97978. */
  97979. primaryColorHighlightLevel: float;
  97980. protected _reflectionTexture: Nullable<BaseTexture>;
  97981. /**
  97982. * Reflection Texture used in the material.
  97983. * Should be author in a specific way for the best result (refer to the documentation).
  97984. */
  97985. reflectionTexture: Nullable<BaseTexture>;
  97986. protected _reflectionBlur: float;
  97987. /**
  97988. * Reflection Texture level of blur.
  97989. *
  97990. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  97991. * texture twice.
  97992. */
  97993. reflectionBlur: float;
  97994. protected _diffuseTexture: Nullable<BaseTexture>;
  97995. /**
  97996. * Diffuse Texture used in the material.
  97997. * Should be author in a specific way for the best result (refer to the documentation).
  97998. */
  97999. diffuseTexture: Nullable<BaseTexture>;
  98000. protected _shadowLights: Nullable<IShadowLight[]>;
  98001. /**
  98002. * Specify the list of lights casting shadow on the material.
  98003. * All scene shadow lights will be included if null.
  98004. */
  98005. shadowLights: Nullable<IShadowLight[]>;
  98006. protected _shadowLevel: float;
  98007. /**
  98008. * Helps adjusting the shadow to a softer level if required.
  98009. * 0 means black shadows and 1 means no shadows.
  98010. */
  98011. shadowLevel: float;
  98012. protected _sceneCenter: Vector3;
  98013. /**
  98014. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98015. * It is usually zero but might be interesting to modify according to your setup.
  98016. */
  98017. sceneCenter: Vector3;
  98018. protected _opacityFresnel: boolean;
  98019. /**
  98020. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98021. * This helps ensuring a nice transition when the camera goes under the ground.
  98022. */
  98023. opacityFresnel: boolean;
  98024. protected _reflectionFresnel: boolean;
  98025. /**
  98026. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98027. * This helps adding a mirror texture on the ground.
  98028. */
  98029. reflectionFresnel: boolean;
  98030. protected _reflectionFalloffDistance: number;
  98031. /**
  98032. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98033. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98034. */
  98035. reflectionFalloffDistance: number;
  98036. protected _reflectionAmount: number;
  98037. /**
  98038. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98039. */
  98040. reflectionAmount: number;
  98041. protected _reflectionReflectance0: number;
  98042. /**
  98043. * This specifies the weight of the reflection at grazing angle.
  98044. */
  98045. reflectionReflectance0: number;
  98046. protected _reflectionReflectance90: number;
  98047. /**
  98048. * This specifies the weight of the reflection at a perpendicular point of view.
  98049. */
  98050. reflectionReflectance90: number;
  98051. /**
  98052. * Sets the reflection reflectance fresnel values according to the default standard
  98053. * empirically know to work well :-)
  98054. */
  98055. reflectionStandardFresnelWeight: number;
  98056. protected _useRGBColor: boolean;
  98057. /**
  98058. * Helps to directly use the maps channels instead of their level.
  98059. */
  98060. useRGBColor: boolean;
  98061. protected _enableNoise: boolean;
  98062. /**
  98063. * This helps reducing the banding effect that could occur on the background.
  98064. */
  98065. enableNoise: boolean;
  98066. /**
  98067. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98068. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98069. * Recommended to be keep at 1.0 except for special cases.
  98070. */
  98071. fovMultiplier: number;
  98072. private _fovMultiplier;
  98073. /**
  98074. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98075. */
  98076. useEquirectangularFOV: boolean;
  98077. private _maxSimultaneousLights;
  98078. /**
  98079. * Number of Simultaneous lights allowed on the material.
  98080. */
  98081. maxSimultaneousLights: int;
  98082. /**
  98083. * Default configuration related to image processing available in the Background Material.
  98084. */
  98085. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98086. /**
  98087. * Keep track of the image processing observer to allow dispose and replace.
  98088. */
  98089. private _imageProcessingObserver;
  98090. /**
  98091. * Attaches a new image processing configuration to the PBR Material.
  98092. * @param configuration (if null the scene configuration will be use)
  98093. */
  98094. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98095. /**
  98096. * Gets the image processing configuration used either in this material.
  98097. */
  98098. /**
  98099. * Sets the Default image processing configuration used either in the this material.
  98100. *
  98101. * If sets to null, the scene one is in use.
  98102. */
  98103. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98104. /**
  98105. * Gets wether the color curves effect is enabled.
  98106. */
  98107. /**
  98108. * Sets wether the color curves effect is enabled.
  98109. */
  98110. cameraColorCurvesEnabled: boolean;
  98111. /**
  98112. * Gets wether the color grading effect is enabled.
  98113. */
  98114. /**
  98115. * Gets wether the color grading effect is enabled.
  98116. */
  98117. cameraColorGradingEnabled: boolean;
  98118. /**
  98119. * Gets wether tonemapping is enabled or not.
  98120. */
  98121. /**
  98122. * Sets wether tonemapping is enabled or not
  98123. */
  98124. cameraToneMappingEnabled: boolean;
  98125. /**
  98126. * The camera exposure used on this material.
  98127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98128. * This corresponds to a photographic exposure.
  98129. */
  98130. /**
  98131. * The camera exposure used on this material.
  98132. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98133. * This corresponds to a photographic exposure.
  98134. */
  98135. cameraExposure: float;
  98136. /**
  98137. * Gets The camera contrast used on this material.
  98138. */
  98139. /**
  98140. * Sets The camera contrast used on this material.
  98141. */
  98142. cameraContrast: float;
  98143. /**
  98144. * Gets the Color Grading 2D Lookup Texture.
  98145. */
  98146. /**
  98147. * Sets the Color Grading 2D Lookup Texture.
  98148. */
  98149. cameraColorGradingTexture: Nullable<BaseTexture>;
  98150. /**
  98151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98153. * 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;
  98154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98155. */
  98156. /**
  98157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98159. * 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;
  98160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98161. */
  98162. cameraColorCurves: Nullable<ColorCurves>;
  98163. /**
  98164. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98165. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98166. */
  98167. switchToBGR: boolean;
  98168. private _renderTargets;
  98169. private _reflectionControls;
  98170. private _white;
  98171. private _primaryShadowColor;
  98172. private _primaryHighlightColor;
  98173. /**
  98174. * Instantiates a Background Material in the given scene
  98175. * @param name The friendly name of the material
  98176. * @param scene The scene to add the material to
  98177. */
  98178. constructor(name: string, scene: Scene);
  98179. /**
  98180. * Gets a boolean indicating that current material needs to register RTT
  98181. */
  98182. readonly hasRenderTargetTextures: boolean;
  98183. /**
  98184. * The entire material has been created in order to prevent overdraw.
  98185. * @returns false
  98186. */
  98187. needAlphaTesting(): boolean;
  98188. /**
  98189. * The entire material has been created in order to prevent overdraw.
  98190. * @returns true if blending is enable
  98191. */
  98192. needAlphaBlending(): boolean;
  98193. /**
  98194. * Checks wether the material is ready to be rendered for a given mesh.
  98195. * @param mesh The mesh to render
  98196. * @param subMesh The submesh to check against
  98197. * @param useInstances Specify wether or not the material is used with instances
  98198. * @returns true if all the dependencies are ready (Textures, Effects...)
  98199. */
  98200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98201. /**
  98202. * Compute the primary color according to the chosen perceptual color.
  98203. */
  98204. private _computePrimaryColorFromPerceptualColor;
  98205. /**
  98206. * Compute the highlights and shadow colors according to their chosen levels.
  98207. */
  98208. private _computePrimaryColors;
  98209. /**
  98210. * Build the uniform buffer used in the material.
  98211. */
  98212. buildUniformLayout(): void;
  98213. /**
  98214. * Unbind the material.
  98215. */
  98216. unbind(): void;
  98217. /**
  98218. * Bind only the world matrix to the material.
  98219. * @param world The world matrix to bind.
  98220. */
  98221. bindOnlyWorldMatrix(world: Matrix): void;
  98222. /**
  98223. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98224. * @param world The world matrix to bind.
  98225. * @param subMesh The submesh to bind for.
  98226. */
  98227. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98228. /**
  98229. * Dispose the material.
  98230. * @param forceDisposeEffect Force disposal of the associated effect.
  98231. * @param forceDisposeTextures Force disposal of the associated textures.
  98232. */
  98233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98234. /**
  98235. * Clones the material.
  98236. * @param name The cloned name.
  98237. * @returns The cloned material.
  98238. */
  98239. clone(name: string): BackgroundMaterial;
  98240. /**
  98241. * Serializes the current material to its JSON representation.
  98242. * @returns The JSON representation.
  98243. */
  98244. serialize(): any;
  98245. /**
  98246. * Gets the class name of the material
  98247. * @returns "BackgroundMaterial"
  98248. */
  98249. getClassName(): string;
  98250. /**
  98251. * Parse a JSON input to create back a background material.
  98252. * @param source The JSON data to parse
  98253. * @param scene The scene to create the parsed material in
  98254. * @param rootUrl The root url of the assets the material depends upon
  98255. * @returns the instantiated BackgroundMaterial.
  98256. */
  98257. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98258. }
  98259. }
  98260. declare module BABYLON {
  98261. /**
  98262. * Represents the different options available during the creation of
  98263. * a Environment helper.
  98264. *
  98265. * This can control the default ground, skybox and image processing setup of your scene.
  98266. */
  98267. export interface IEnvironmentHelperOptions {
  98268. /**
  98269. * Specifies wether or not to create a ground.
  98270. * True by default.
  98271. */
  98272. createGround: boolean;
  98273. /**
  98274. * Specifies the ground size.
  98275. * 15 by default.
  98276. */
  98277. groundSize: number;
  98278. /**
  98279. * The texture used on the ground for the main color.
  98280. * Comes from the BabylonJS CDN by default.
  98281. *
  98282. * Remarks: Can be either a texture or a url.
  98283. */
  98284. groundTexture: string | BaseTexture;
  98285. /**
  98286. * The color mixed in the ground texture by default.
  98287. * BabylonJS clearColor by default.
  98288. */
  98289. groundColor: Color3;
  98290. /**
  98291. * Specifies the ground opacity.
  98292. * 1 by default.
  98293. */
  98294. groundOpacity: number;
  98295. /**
  98296. * Enables the ground to receive shadows.
  98297. * True by default.
  98298. */
  98299. enableGroundShadow: boolean;
  98300. /**
  98301. * Helps preventing the shadow to be fully black on the ground.
  98302. * 0.5 by default.
  98303. */
  98304. groundShadowLevel: number;
  98305. /**
  98306. * Creates a mirror texture attach to the ground.
  98307. * false by default.
  98308. */
  98309. enableGroundMirror: boolean;
  98310. /**
  98311. * Specifies the ground mirror size ratio.
  98312. * 0.3 by default as the default kernel is 64.
  98313. */
  98314. groundMirrorSizeRatio: number;
  98315. /**
  98316. * Specifies the ground mirror blur kernel size.
  98317. * 64 by default.
  98318. */
  98319. groundMirrorBlurKernel: number;
  98320. /**
  98321. * Specifies the ground mirror visibility amount.
  98322. * 1 by default
  98323. */
  98324. groundMirrorAmount: number;
  98325. /**
  98326. * Specifies the ground mirror reflectance weight.
  98327. * This uses the standard weight of the background material to setup the fresnel effect
  98328. * of the mirror.
  98329. * 1 by default.
  98330. */
  98331. groundMirrorFresnelWeight: number;
  98332. /**
  98333. * Specifies the ground mirror Falloff distance.
  98334. * This can helps reducing the size of the reflection.
  98335. * 0 by Default.
  98336. */
  98337. groundMirrorFallOffDistance: number;
  98338. /**
  98339. * Specifies the ground mirror texture type.
  98340. * Unsigned Int by Default.
  98341. */
  98342. groundMirrorTextureType: number;
  98343. /**
  98344. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98345. * the shown objects.
  98346. */
  98347. groundYBias: number;
  98348. /**
  98349. * Specifies wether or not to create a skybox.
  98350. * True by default.
  98351. */
  98352. createSkybox: boolean;
  98353. /**
  98354. * Specifies the skybox size.
  98355. * 20 by default.
  98356. */
  98357. skyboxSize: number;
  98358. /**
  98359. * The texture used on the skybox for the main color.
  98360. * Comes from the BabylonJS CDN by default.
  98361. *
  98362. * Remarks: Can be either a texture or a url.
  98363. */
  98364. skyboxTexture: string | BaseTexture;
  98365. /**
  98366. * The color mixed in the skybox texture by default.
  98367. * BabylonJS clearColor by default.
  98368. */
  98369. skyboxColor: Color3;
  98370. /**
  98371. * The background rotation around the Y axis of the scene.
  98372. * This helps aligning the key lights of your scene with the background.
  98373. * 0 by default.
  98374. */
  98375. backgroundYRotation: number;
  98376. /**
  98377. * Compute automatically the size of the elements to best fit with the scene.
  98378. */
  98379. sizeAuto: boolean;
  98380. /**
  98381. * Default position of the rootMesh if autoSize is not true.
  98382. */
  98383. rootPosition: Vector3;
  98384. /**
  98385. * Sets up the image processing in the scene.
  98386. * true by default.
  98387. */
  98388. setupImageProcessing: boolean;
  98389. /**
  98390. * The texture used as your environment texture in the scene.
  98391. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98392. *
  98393. * Remarks: Can be either a texture or a url.
  98394. */
  98395. environmentTexture: string | BaseTexture;
  98396. /**
  98397. * The value of the exposure to apply to the scene.
  98398. * 0.6 by default if setupImageProcessing is true.
  98399. */
  98400. cameraExposure: number;
  98401. /**
  98402. * The value of the contrast to apply to the scene.
  98403. * 1.6 by default if setupImageProcessing is true.
  98404. */
  98405. cameraContrast: number;
  98406. /**
  98407. * Specifies wether or not tonemapping should be enabled in the scene.
  98408. * true by default if setupImageProcessing is true.
  98409. */
  98410. toneMappingEnabled: boolean;
  98411. }
  98412. /**
  98413. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98414. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98415. * It also helps with the default setup of your imageProcessing configuration.
  98416. */
  98417. export class EnvironmentHelper {
  98418. /**
  98419. * Default ground texture URL.
  98420. */
  98421. private static _groundTextureCDNUrl;
  98422. /**
  98423. * Default skybox texture URL.
  98424. */
  98425. private static _skyboxTextureCDNUrl;
  98426. /**
  98427. * Default environment texture URL.
  98428. */
  98429. private static _environmentTextureCDNUrl;
  98430. /**
  98431. * Creates the default options for the helper.
  98432. */
  98433. private static _getDefaultOptions;
  98434. private _rootMesh;
  98435. /**
  98436. * Gets the root mesh created by the helper.
  98437. */
  98438. readonly rootMesh: Mesh;
  98439. private _skybox;
  98440. /**
  98441. * Gets the skybox created by the helper.
  98442. */
  98443. readonly skybox: Nullable<Mesh>;
  98444. private _skyboxTexture;
  98445. /**
  98446. * Gets the skybox texture created by the helper.
  98447. */
  98448. readonly skyboxTexture: Nullable<BaseTexture>;
  98449. private _skyboxMaterial;
  98450. /**
  98451. * Gets the skybox material created by the helper.
  98452. */
  98453. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98454. private _ground;
  98455. /**
  98456. * Gets the ground mesh created by the helper.
  98457. */
  98458. readonly ground: Nullable<Mesh>;
  98459. private _groundTexture;
  98460. /**
  98461. * Gets the ground texture created by the helper.
  98462. */
  98463. readonly groundTexture: Nullable<BaseTexture>;
  98464. private _groundMirror;
  98465. /**
  98466. * Gets the ground mirror created by the helper.
  98467. */
  98468. readonly groundMirror: Nullable<MirrorTexture>;
  98469. /**
  98470. * Gets the ground mirror render list to helps pushing the meshes
  98471. * you wish in the ground reflection.
  98472. */
  98473. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98474. private _groundMaterial;
  98475. /**
  98476. * Gets the ground material created by the helper.
  98477. */
  98478. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98479. /**
  98480. * Stores the creation options.
  98481. */
  98482. private readonly _scene;
  98483. private _options;
  98484. /**
  98485. * This observable will be notified with any error during the creation of the environment,
  98486. * mainly texture creation errors.
  98487. */
  98488. onErrorObservable: Observable<{
  98489. message?: string;
  98490. exception?: any;
  98491. }>;
  98492. /**
  98493. * constructor
  98494. * @param options Defines the options we want to customize the helper
  98495. * @param scene The scene to add the material to
  98496. */
  98497. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98498. /**
  98499. * Updates the background according to the new options
  98500. * @param options
  98501. */
  98502. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98503. /**
  98504. * Sets the primary color of all the available elements.
  98505. * @param color the main color to affect to the ground and the background
  98506. */
  98507. setMainColor(color: Color3): void;
  98508. /**
  98509. * Setup the image processing according to the specified options.
  98510. */
  98511. private _setupImageProcessing;
  98512. /**
  98513. * Setup the environment texture according to the specified options.
  98514. */
  98515. private _setupEnvironmentTexture;
  98516. /**
  98517. * Setup the background according to the specified options.
  98518. */
  98519. private _setupBackground;
  98520. /**
  98521. * Get the scene sizes according to the setup.
  98522. */
  98523. private _getSceneSize;
  98524. /**
  98525. * Setup the ground according to the specified options.
  98526. */
  98527. private _setupGround;
  98528. /**
  98529. * Setup the ground material according to the specified options.
  98530. */
  98531. private _setupGroundMaterial;
  98532. /**
  98533. * Setup the ground diffuse texture according to the specified options.
  98534. */
  98535. private _setupGroundDiffuseTexture;
  98536. /**
  98537. * Setup the ground mirror texture according to the specified options.
  98538. */
  98539. private _setupGroundMirrorTexture;
  98540. /**
  98541. * Setup the ground to receive the mirror texture.
  98542. */
  98543. private _setupMirrorInGroundMaterial;
  98544. /**
  98545. * Setup the skybox according to the specified options.
  98546. */
  98547. private _setupSkybox;
  98548. /**
  98549. * Setup the skybox material according to the specified options.
  98550. */
  98551. private _setupSkyboxMaterial;
  98552. /**
  98553. * Setup the skybox reflection texture according to the specified options.
  98554. */
  98555. private _setupSkyboxReflectionTexture;
  98556. private _errorHandler;
  98557. /**
  98558. * Dispose all the elements created by the Helper.
  98559. */
  98560. dispose(): void;
  98561. }
  98562. }
  98563. declare module BABYLON {
  98564. /**
  98565. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98566. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98567. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98568. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98569. */
  98570. export class PhotoDome extends TransformNode {
  98571. private _useDirectMapping;
  98572. /**
  98573. * The texture being displayed on the sphere
  98574. */
  98575. protected _photoTexture: Texture;
  98576. /**
  98577. * Gets or sets the texture being displayed on the sphere
  98578. */
  98579. photoTexture: Texture;
  98580. /**
  98581. * Observable raised when an error occured while loading the 360 image
  98582. */
  98583. onLoadErrorObservable: Observable<string>;
  98584. /**
  98585. * The skybox material
  98586. */
  98587. protected _material: BackgroundMaterial;
  98588. /**
  98589. * The surface used for the skybox
  98590. */
  98591. protected _mesh: Mesh;
  98592. /**
  98593. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98594. * Also see the options.resolution property.
  98595. */
  98596. fovMultiplier: number;
  98597. /**
  98598. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98599. * @param name Element's name, child elements will append suffixes for their own names.
  98600. * @param urlsOfPhoto defines the url of the photo to display
  98601. * @param options defines an object containing optional or exposed sub element properties
  98602. * @param onError defines a callback called when an error occured while loading the texture
  98603. */
  98604. constructor(name: string, urlOfPhoto: string, options: {
  98605. resolution?: number;
  98606. size?: number;
  98607. useDirectMapping?: boolean;
  98608. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98609. /**
  98610. * Releases resources associated with this node.
  98611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98613. */
  98614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98615. }
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * Class used to host texture specific utilities
  98620. */
  98621. export class TextureTools {
  98622. /**
  98623. * Uses the GPU to create a copy texture rescaled at a given size
  98624. * @param texture Texture to copy from
  98625. * @param width defines the desired width
  98626. * @param height defines the desired height
  98627. * @param useBilinearMode defines if bilinear mode has to be used
  98628. * @return the generated texture
  98629. */
  98630. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98631. /**
  98632. * Gets an environment BRDF texture for a given scene
  98633. * @param scene defines the hosting scene
  98634. * @returns the environment BRDF texture
  98635. */
  98636. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98637. private static _environmentBRDFBase64Texture;
  98638. }
  98639. }
  98640. declare module BABYLON {
  98641. /** @hidden */
  98642. export var pbrFragmentDeclaration: {
  98643. name: string;
  98644. shader: string;
  98645. };
  98646. }
  98647. declare module BABYLON {
  98648. /** @hidden */
  98649. export var pbrUboDeclaration: {
  98650. name: string;
  98651. shader: string;
  98652. };
  98653. }
  98654. declare module BABYLON {
  98655. /** @hidden */
  98656. export var pbrFunctions: {
  98657. name: string;
  98658. shader: string;
  98659. };
  98660. }
  98661. declare module BABYLON {
  98662. /** @hidden */
  98663. export var harmonicsFunctions: {
  98664. name: string;
  98665. shader: string;
  98666. };
  98667. }
  98668. declare module BABYLON {
  98669. /** @hidden */
  98670. export var pbrLightFunctions: {
  98671. name: string;
  98672. shader: string;
  98673. };
  98674. }
  98675. declare module BABYLON {
  98676. /** @hidden */
  98677. export var pbrPixelShader: {
  98678. name: string;
  98679. shader: string;
  98680. };
  98681. }
  98682. declare module BABYLON {
  98683. /** @hidden */
  98684. export var pbrVertexDeclaration: {
  98685. name: string;
  98686. shader: string;
  98687. };
  98688. }
  98689. declare module BABYLON {
  98690. /** @hidden */
  98691. export var pbrVertexShader: {
  98692. name: string;
  98693. shader: string;
  98694. };
  98695. }
  98696. declare module BABYLON {
  98697. /**
  98698. * The Physically based material base class of BJS.
  98699. *
  98700. * This offers the main features of a standard PBR material.
  98701. * For more information, please refer to the documentation :
  98702. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98703. */
  98704. export abstract class PBRBaseMaterial extends PushMaterial {
  98705. /**
  98706. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98707. */
  98708. static readonly PBRMATERIAL_OPAQUE: number;
  98709. /**
  98710. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98711. */
  98712. static readonly PBRMATERIAL_ALPHATEST: number;
  98713. /**
  98714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98715. */
  98716. static readonly PBRMATERIAL_ALPHABLEND: number;
  98717. /**
  98718. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98719. * They are also discarded below the alpha cutoff threshold to improve performances.
  98720. */
  98721. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98722. /**
  98723. * Defines the default value of how much AO map is occluding the analytical lights
  98724. * (point spot...).
  98725. */
  98726. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98727. /**
  98728. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98729. */
  98730. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98731. /**
  98732. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98733. * to enhance interoperability with other engines.
  98734. */
  98735. static readonly LIGHTFALLOFF_GLTF: number;
  98736. /**
  98737. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98738. * to enhance interoperability with other materials.
  98739. */
  98740. static readonly LIGHTFALLOFF_STANDARD: number;
  98741. /**
  98742. * Intensity of the direct lights e.g. the four lights available in your scene.
  98743. * This impacts both the direct diffuse and specular highlights.
  98744. */
  98745. protected _directIntensity: number;
  98746. /**
  98747. * Intensity of the emissive part of the material.
  98748. * This helps controlling the emissive effect without modifying the emissive color.
  98749. */
  98750. protected _emissiveIntensity: number;
  98751. /**
  98752. * Intensity of the environment e.g. how much the environment will light the object
  98753. * either through harmonics for rough material or through the refelction for shiny ones.
  98754. */
  98755. protected _environmentIntensity: number;
  98756. /**
  98757. * This is a special control allowing the reduction of the specular highlights coming from the
  98758. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98759. */
  98760. protected _specularIntensity: number;
  98761. /**
  98762. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98763. */
  98764. private _lightingInfos;
  98765. /**
  98766. * Debug Control allowing disabling the bump map on this material.
  98767. */
  98768. protected _disableBumpMap: boolean;
  98769. /**
  98770. * AKA Diffuse Texture in standard nomenclature.
  98771. */
  98772. protected _albedoTexture: BaseTexture;
  98773. /**
  98774. * AKA Occlusion Texture in other nomenclature.
  98775. */
  98776. protected _ambientTexture: BaseTexture;
  98777. /**
  98778. * AKA Occlusion Texture Intensity in other nomenclature.
  98779. */
  98780. protected _ambientTextureStrength: number;
  98781. /**
  98782. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98783. * 1 means it completely occludes it
  98784. * 0 mean it has no impact
  98785. */
  98786. protected _ambientTextureImpactOnAnalyticalLights: number;
  98787. /**
  98788. * Stores the alpha values in a texture.
  98789. */
  98790. protected _opacityTexture: BaseTexture;
  98791. /**
  98792. * Stores the reflection values in a texture.
  98793. */
  98794. protected _reflectionTexture: BaseTexture;
  98795. /**
  98796. * Stores the refraction values in a texture.
  98797. */
  98798. protected _refractionTexture: BaseTexture;
  98799. /**
  98800. * Stores the emissive values in a texture.
  98801. */
  98802. protected _emissiveTexture: BaseTexture;
  98803. /**
  98804. * AKA Specular texture in other nomenclature.
  98805. */
  98806. protected _reflectivityTexture: BaseTexture;
  98807. /**
  98808. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98809. */
  98810. protected _metallicTexture: BaseTexture;
  98811. /**
  98812. * Specifies the metallic scalar of the metallic/roughness workflow.
  98813. * Can also be used to scale the metalness values of the metallic texture.
  98814. */
  98815. protected _metallic: Nullable<number>;
  98816. /**
  98817. * Specifies the roughness scalar of the metallic/roughness workflow.
  98818. * Can also be used to scale the roughness values of the metallic texture.
  98819. */
  98820. protected _roughness: Nullable<number>;
  98821. /**
  98822. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98823. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98824. */
  98825. protected _microSurfaceTexture: BaseTexture;
  98826. /**
  98827. * Stores surface normal data used to displace a mesh in a texture.
  98828. */
  98829. protected _bumpTexture: BaseTexture;
  98830. /**
  98831. * Stores the pre-calculated light information of a mesh in a texture.
  98832. */
  98833. protected _lightmapTexture: BaseTexture;
  98834. /**
  98835. * The color of a material in ambient lighting.
  98836. */
  98837. protected _ambientColor: Color3;
  98838. /**
  98839. * AKA Diffuse Color in other nomenclature.
  98840. */
  98841. protected _albedoColor: Color3;
  98842. /**
  98843. * AKA Specular Color in other nomenclature.
  98844. */
  98845. protected _reflectivityColor: Color3;
  98846. /**
  98847. * The color applied when light is reflected from a material.
  98848. */
  98849. protected _reflectionColor: Color3;
  98850. /**
  98851. * The color applied when light is emitted from a material.
  98852. */
  98853. protected _emissiveColor: Color3;
  98854. /**
  98855. * AKA Glossiness in other nomenclature.
  98856. */
  98857. protected _microSurface: number;
  98858. /**
  98859. * source material index of refraction (IOR)' / 'destination material IOR.
  98860. */
  98861. protected _indexOfRefraction: number;
  98862. /**
  98863. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98864. */
  98865. protected _invertRefractionY: boolean;
  98866. /**
  98867. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98868. * Materials half opaque for instance using refraction could benefit from this control.
  98869. */
  98870. protected _linkRefractionWithTransparency: boolean;
  98871. /**
  98872. * Specifies that the material will use the light map as a show map.
  98873. */
  98874. protected _useLightmapAsShadowmap: boolean;
  98875. /**
  98876. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98877. * makes the reflect vector face the model (under horizon).
  98878. */
  98879. protected _useHorizonOcclusion: boolean;
  98880. /**
  98881. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98882. * too much the area relying on ambient texture to define their ambient occlusion.
  98883. */
  98884. protected _useRadianceOcclusion: boolean;
  98885. /**
  98886. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98887. */
  98888. protected _useAlphaFromAlbedoTexture: boolean;
  98889. /**
  98890. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98891. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98892. */
  98893. protected _useSpecularOverAlpha: boolean;
  98894. /**
  98895. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98896. */
  98897. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  98898. /**
  98899. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  98900. */
  98901. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  98902. /**
  98903. * Specifies if the metallic texture contains the roughness information in its green channel.
  98904. */
  98905. protected _useRoughnessFromMetallicTextureGreen: boolean;
  98906. /**
  98907. * Specifies if the metallic texture contains the metallness information in its blue channel.
  98908. */
  98909. protected _useMetallnessFromMetallicTextureBlue: boolean;
  98910. /**
  98911. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  98912. */
  98913. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  98914. /**
  98915. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  98916. */
  98917. protected _useAmbientInGrayScale: boolean;
  98918. /**
  98919. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  98920. * The material will try to infer what glossiness each pixel should be.
  98921. */
  98922. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  98923. /**
  98924. * Defines the falloff type used in this material.
  98925. * It by default is Physical.
  98926. */
  98927. protected _lightFalloff: number;
  98928. /**
  98929. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98930. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98931. */
  98932. protected _useRadianceOverAlpha: boolean;
  98933. /**
  98934. * Allows using an object space normal map (instead of tangent space).
  98935. */
  98936. protected _useObjectSpaceNormalMap: boolean;
  98937. /**
  98938. * Allows using the bump map in parallax mode.
  98939. */
  98940. protected _useParallax: boolean;
  98941. /**
  98942. * Allows using the bump map in parallax occlusion mode.
  98943. */
  98944. protected _useParallaxOcclusion: boolean;
  98945. /**
  98946. * Controls the scale bias of the parallax mode.
  98947. */
  98948. protected _parallaxScaleBias: number;
  98949. /**
  98950. * If sets to true, disables all the lights affecting the material.
  98951. */
  98952. protected _disableLighting: boolean;
  98953. /**
  98954. * Number of Simultaneous lights allowed on the material.
  98955. */
  98956. protected _maxSimultaneousLights: number;
  98957. /**
  98958. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  98959. */
  98960. protected _invertNormalMapX: boolean;
  98961. /**
  98962. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  98963. */
  98964. protected _invertNormalMapY: boolean;
  98965. /**
  98966. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98967. */
  98968. protected _twoSidedLighting: boolean;
  98969. /**
  98970. * Defines the alpha limits in alpha test mode.
  98971. */
  98972. protected _alphaCutOff: number;
  98973. /**
  98974. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  98975. */
  98976. protected _forceAlphaTest: boolean;
  98977. /**
  98978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98979. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  98980. */
  98981. protected _useAlphaFresnel: boolean;
  98982. /**
  98983. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98984. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  98985. */
  98986. protected _useLinearAlphaFresnel: boolean;
  98987. /**
  98988. * The transparency mode of the material.
  98989. */
  98990. protected _transparencyMode: Nullable<number>;
  98991. /**
  98992. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  98993. * from cos thetav and roughness:
  98994. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  98995. */
  98996. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  98997. /**
  98998. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  98999. */
  99000. protected _forceIrradianceInFragment: boolean;
  99001. /**
  99002. * Force normal to face away from face.
  99003. */
  99004. protected _forceNormalForward: boolean;
  99005. /**
  99006. * Enables specular anti aliasing in the PBR shader.
  99007. * It will both interacts on the Geometry for analytical and IBL lighting.
  99008. * It also prefilter the roughness map based on the bump values.
  99009. */
  99010. protected _enableSpecularAntiAliasing: boolean;
  99011. /**
  99012. * Default configuration related to image processing available in the PBR Material.
  99013. */
  99014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99015. /**
  99016. * Keep track of the image processing observer to allow dispose and replace.
  99017. */
  99018. private _imageProcessingObserver;
  99019. /**
  99020. * Attaches a new image processing configuration to the PBR Material.
  99021. * @param configuration
  99022. */
  99023. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99024. /**
  99025. * Stores the available render targets.
  99026. */
  99027. private _renderTargets;
  99028. /**
  99029. * Sets the global ambient color for the material used in lighting calculations.
  99030. */
  99031. private _globalAmbientColor;
  99032. /**
  99033. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99034. */
  99035. private _useLogarithmicDepth;
  99036. /**
  99037. * If set to true, no lighting calculations will be applied.
  99038. */
  99039. private _unlit;
  99040. /**
  99041. * Instantiates a new PBRMaterial instance.
  99042. *
  99043. * @param name The material name
  99044. * @param scene The scene the material will be use in.
  99045. */
  99046. constructor(name: string, scene: Scene);
  99047. /**
  99048. * Gets a boolean indicating that current material needs to register RTT
  99049. */
  99050. readonly hasRenderTargetTextures: boolean;
  99051. /**
  99052. * Gets the name of the material class.
  99053. */
  99054. getClassName(): string;
  99055. /**
  99056. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99057. */
  99058. /**
  99059. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99060. */
  99061. useLogarithmicDepth: boolean;
  99062. /**
  99063. * Gets the current transparency mode.
  99064. */
  99065. /**
  99066. * Sets the transparency mode of the material.
  99067. *
  99068. * | Value | Type | Description |
  99069. * | ----- | ----------------------------------- | ----------- |
  99070. * | 0 | OPAQUE | |
  99071. * | 1 | ALPHATEST | |
  99072. * | 2 | ALPHABLEND | |
  99073. * | 3 | ALPHATESTANDBLEND | |
  99074. *
  99075. */
  99076. transparencyMode: Nullable<number>;
  99077. /**
  99078. * Returns true if alpha blending should be disabled.
  99079. */
  99080. private readonly _disableAlphaBlending;
  99081. /**
  99082. * Specifies whether or not this material should be rendered in alpha blend mode.
  99083. */
  99084. needAlphaBlending(): boolean;
  99085. /**
  99086. * Specifies if the mesh will require alpha blending.
  99087. * @param mesh - BJS mesh.
  99088. */
  99089. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99090. /**
  99091. * Specifies whether or not this material should be rendered in alpha test mode.
  99092. */
  99093. needAlphaTesting(): boolean;
  99094. /**
  99095. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99096. */
  99097. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99098. /**
  99099. * Gets the texture used for the alpha test.
  99100. */
  99101. getAlphaTestTexture(): BaseTexture;
  99102. /**
  99103. * Specifies that the submesh is ready to be used.
  99104. * @param mesh - BJS mesh.
  99105. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99106. * @param useInstances - Specifies that instances should be used.
  99107. * @returns - boolean indicating that the submesh is ready or not.
  99108. */
  99109. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99110. /**
  99111. * Specifies if the material uses metallic roughness workflow.
  99112. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99113. */
  99114. isMetallicWorkflow(): boolean;
  99115. private _prepareEffect;
  99116. private _prepareDefines;
  99117. /**
  99118. * Force shader compilation
  99119. */
  99120. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99121. clipPlane: boolean;
  99122. }>): void;
  99123. /**
  99124. * Initializes the uniform buffer layout for the shader.
  99125. */
  99126. buildUniformLayout(): void;
  99127. /**
  99128. * Unbinds the textures.
  99129. */
  99130. unbind(): void;
  99131. /**
  99132. * Binds the submesh data.
  99133. * @param world - The world matrix.
  99134. * @param mesh - The BJS mesh.
  99135. * @param subMesh - A submesh of the BJS mesh.
  99136. */
  99137. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99138. /**
  99139. * Returns the animatable textures.
  99140. * @returns - Array of animatable textures.
  99141. */
  99142. getAnimatables(): IAnimatable[];
  99143. /**
  99144. * Returns the texture used for reflections.
  99145. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99146. */
  99147. private _getReflectionTexture;
  99148. /**
  99149. * Returns the texture used for refraction or null if none is used.
  99150. * @returns - Refection texture if present. If no refraction texture and refraction
  99151. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99152. */
  99153. private _getRefractionTexture;
  99154. /**
  99155. * Disposes the resources of the material.
  99156. * @param forceDisposeEffect - Forces the disposal of effects.
  99157. * @param forceDisposeTextures - Forces the disposal of all textures.
  99158. */
  99159. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99160. }
  99161. }
  99162. declare module BABYLON {
  99163. /**
  99164. * The Physically based material of BJS.
  99165. *
  99166. * This offers the main features of a standard PBR material.
  99167. * For more information, please refer to the documentation :
  99168. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99169. */
  99170. export class PBRMaterial extends PBRBaseMaterial {
  99171. /**
  99172. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99173. */
  99174. static readonly PBRMATERIAL_OPAQUE: number;
  99175. /**
  99176. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99177. */
  99178. static readonly PBRMATERIAL_ALPHATEST: number;
  99179. /**
  99180. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99181. */
  99182. static readonly PBRMATERIAL_ALPHABLEND: number;
  99183. /**
  99184. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99185. * They are also discarded below the alpha cutoff threshold to improve performances.
  99186. */
  99187. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99188. /**
  99189. * Defines the default value of how much AO map is occluding the analytical lights
  99190. * (point spot...).
  99191. */
  99192. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99193. /**
  99194. * Intensity of the direct lights e.g. the four lights available in your scene.
  99195. * This impacts both the direct diffuse and specular highlights.
  99196. */
  99197. directIntensity: number;
  99198. /**
  99199. * Intensity of the emissive part of the material.
  99200. * This helps controlling the emissive effect without modifying the emissive color.
  99201. */
  99202. emissiveIntensity: number;
  99203. /**
  99204. * Intensity of the environment e.g. how much the environment will light the object
  99205. * either through harmonics for rough material or through the refelction for shiny ones.
  99206. */
  99207. environmentIntensity: number;
  99208. /**
  99209. * This is a special control allowing the reduction of the specular highlights coming from the
  99210. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99211. */
  99212. specularIntensity: number;
  99213. /**
  99214. * Debug Control allowing disabling the bump map on this material.
  99215. */
  99216. disableBumpMap: boolean;
  99217. /**
  99218. * AKA Diffuse Texture in standard nomenclature.
  99219. */
  99220. albedoTexture: BaseTexture;
  99221. /**
  99222. * AKA Occlusion Texture in other nomenclature.
  99223. */
  99224. ambientTexture: BaseTexture;
  99225. /**
  99226. * AKA Occlusion Texture Intensity in other nomenclature.
  99227. */
  99228. ambientTextureStrength: number;
  99229. /**
  99230. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99231. * 1 means it completely occludes it
  99232. * 0 mean it has no impact
  99233. */
  99234. ambientTextureImpactOnAnalyticalLights: number;
  99235. /**
  99236. * Stores the alpha values in a texture.
  99237. */
  99238. opacityTexture: BaseTexture;
  99239. /**
  99240. * Stores the reflection values in a texture.
  99241. */
  99242. reflectionTexture: Nullable<BaseTexture>;
  99243. /**
  99244. * Stores the emissive values in a texture.
  99245. */
  99246. emissiveTexture: BaseTexture;
  99247. /**
  99248. * AKA Specular texture in other nomenclature.
  99249. */
  99250. reflectivityTexture: BaseTexture;
  99251. /**
  99252. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99253. */
  99254. metallicTexture: BaseTexture;
  99255. /**
  99256. * Specifies the metallic scalar of the metallic/roughness workflow.
  99257. * Can also be used to scale the metalness values of the metallic texture.
  99258. */
  99259. metallic: Nullable<number>;
  99260. /**
  99261. * Specifies the roughness scalar of the metallic/roughness workflow.
  99262. * Can also be used to scale the roughness values of the metallic texture.
  99263. */
  99264. roughness: Nullable<number>;
  99265. /**
  99266. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99267. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99268. */
  99269. microSurfaceTexture: BaseTexture;
  99270. /**
  99271. * Stores surface normal data used to displace a mesh in a texture.
  99272. */
  99273. bumpTexture: BaseTexture;
  99274. /**
  99275. * Stores the pre-calculated light information of a mesh in a texture.
  99276. */
  99277. lightmapTexture: BaseTexture;
  99278. /**
  99279. * Stores the refracted light information in a texture.
  99280. */
  99281. refractionTexture: BaseTexture;
  99282. /**
  99283. * The color of a material in ambient lighting.
  99284. */
  99285. ambientColor: Color3;
  99286. /**
  99287. * AKA Diffuse Color in other nomenclature.
  99288. */
  99289. albedoColor: Color3;
  99290. /**
  99291. * AKA Specular Color in other nomenclature.
  99292. */
  99293. reflectivityColor: Color3;
  99294. /**
  99295. * The color reflected from the material.
  99296. */
  99297. reflectionColor: Color3;
  99298. /**
  99299. * The color emitted from the material.
  99300. */
  99301. emissiveColor: Color3;
  99302. /**
  99303. * AKA Glossiness in other nomenclature.
  99304. */
  99305. microSurface: number;
  99306. /**
  99307. * source material index of refraction (IOR)' / 'destination material IOR.
  99308. */
  99309. indexOfRefraction: number;
  99310. /**
  99311. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99312. */
  99313. invertRefractionY: boolean;
  99314. /**
  99315. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99316. * Materials half opaque for instance using refraction could benefit from this control.
  99317. */
  99318. linkRefractionWithTransparency: boolean;
  99319. /**
  99320. * If true, the light map contains occlusion information instead of lighting info.
  99321. */
  99322. useLightmapAsShadowmap: boolean;
  99323. /**
  99324. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99325. */
  99326. useAlphaFromAlbedoTexture: boolean;
  99327. /**
  99328. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99329. */
  99330. forceAlphaTest: boolean;
  99331. /**
  99332. * Defines the alpha limits in alpha test mode.
  99333. */
  99334. alphaCutOff: number;
  99335. /**
  99336. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99337. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99338. */
  99339. useSpecularOverAlpha: boolean;
  99340. /**
  99341. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99342. */
  99343. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99344. /**
  99345. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99346. */
  99347. useRoughnessFromMetallicTextureAlpha: boolean;
  99348. /**
  99349. * Specifies if the metallic texture contains the roughness information in its green channel.
  99350. */
  99351. useRoughnessFromMetallicTextureGreen: boolean;
  99352. /**
  99353. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99354. */
  99355. useMetallnessFromMetallicTextureBlue: boolean;
  99356. /**
  99357. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99358. */
  99359. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99360. /**
  99361. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99362. */
  99363. useAmbientInGrayScale: boolean;
  99364. /**
  99365. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99366. * The material will try to infer what glossiness each pixel should be.
  99367. */
  99368. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99369. /**
  99370. * BJS is using an harcoded light falloff based on a manually sets up range.
  99371. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99372. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99373. */
  99374. /**
  99375. * BJS is using an harcoded light falloff based on a manually sets up range.
  99376. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99377. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99378. */
  99379. usePhysicalLightFalloff: boolean;
  99380. /**
  99381. * In order to support the falloff compatibility with gltf, a special mode has been added
  99382. * to reproduce the gltf light falloff.
  99383. */
  99384. /**
  99385. * In order to support the falloff compatibility with gltf, a special mode has been added
  99386. * to reproduce the gltf light falloff.
  99387. */
  99388. useGLTFLightFalloff: boolean;
  99389. /**
  99390. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99391. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99392. */
  99393. useRadianceOverAlpha: boolean;
  99394. /**
  99395. * Allows using an object space normal map (instead of tangent space).
  99396. */
  99397. useObjectSpaceNormalMap: boolean;
  99398. /**
  99399. * Allows using the bump map in parallax mode.
  99400. */
  99401. useParallax: boolean;
  99402. /**
  99403. * Allows using the bump map in parallax occlusion mode.
  99404. */
  99405. useParallaxOcclusion: boolean;
  99406. /**
  99407. * Controls the scale bias of the parallax mode.
  99408. */
  99409. parallaxScaleBias: number;
  99410. /**
  99411. * If sets to true, disables all the lights affecting the material.
  99412. */
  99413. disableLighting: boolean;
  99414. /**
  99415. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99416. */
  99417. forceIrradianceInFragment: boolean;
  99418. /**
  99419. * Number of Simultaneous lights allowed on the material.
  99420. */
  99421. maxSimultaneousLights: number;
  99422. /**
  99423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99424. */
  99425. invertNormalMapX: boolean;
  99426. /**
  99427. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99428. */
  99429. invertNormalMapY: boolean;
  99430. /**
  99431. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99432. */
  99433. twoSidedLighting: boolean;
  99434. /**
  99435. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99436. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99437. */
  99438. useAlphaFresnel: boolean;
  99439. /**
  99440. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99441. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99442. */
  99443. useLinearAlphaFresnel: boolean;
  99444. /**
  99445. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99446. * And/Or occlude the blended part.
  99447. */
  99448. environmentBRDFTexture: Nullable<BaseTexture>;
  99449. /**
  99450. * Force normal to face away from face.
  99451. */
  99452. forceNormalForward: boolean;
  99453. /**
  99454. * Enables specular anti aliasing in the PBR shader.
  99455. * It will both interacts on the Geometry for analytical and IBL lighting.
  99456. * It also prefilter the roughness map based on the bump values.
  99457. */
  99458. enableSpecularAntiAliasing: boolean;
  99459. /**
  99460. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99461. * makes the reflect vector face the model (under horizon).
  99462. */
  99463. useHorizonOcclusion: boolean;
  99464. /**
  99465. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99466. * too much the area relying on ambient texture to define their ambient occlusion.
  99467. */
  99468. useRadianceOcclusion: boolean;
  99469. /**
  99470. * If set to true, no lighting calculations will be applied.
  99471. */
  99472. unlit: boolean;
  99473. /**
  99474. * Gets the image processing configuration used either in this material.
  99475. */
  99476. /**
  99477. * Sets the Default image processing configuration used either in the this material.
  99478. *
  99479. * If sets to null, the scene one is in use.
  99480. */
  99481. imageProcessingConfiguration: ImageProcessingConfiguration;
  99482. /**
  99483. * Gets wether the color curves effect is enabled.
  99484. */
  99485. /**
  99486. * Sets wether the color curves effect is enabled.
  99487. */
  99488. cameraColorCurvesEnabled: boolean;
  99489. /**
  99490. * Gets wether the color grading effect is enabled.
  99491. */
  99492. /**
  99493. * Gets wether the color grading effect is enabled.
  99494. */
  99495. cameraColorGradingEnabled: boolean;
  99496. /**
  99497. * Gets wether tonemapping is enabled or not.
  99498. */
  99499. /**
  99500. * Sets wether tonemapping is enabled or not
  99501. */
  99502. cameraToneMappingEnabled: boolean;
  99503. /**
  99504. * The camera exposure used on this material.
  99505. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99506. * This corresponds to a photographic exposure.
  99507. */
  99508. /**
  99509. * The camera exposure used on this material.
  99510. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99511. * This corresponds to a photographic exposure.
  99512. */
  99513. cameraExposure: number;
  99514. /**
  99515. * Gets The camera contrast used on this material.
  99516. */
  99517. /**
  99518. * Sets The camera contrast used on this material.
  99519. */
  99520. cameraContrast: number;
  99521. /**
  99522. * Gets the Color Grading 2D Lookup Texture.
  99523. */
  99524. /**
  99525. * Sets the Color Grading 2D Lookup Texture.
  99526. */
  99527. cameraColorGradingTexture: Nullable<BaseTexture>;
  99528. /**
  99529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99531. * 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;
  99532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99533. */
  99534. /**
  99535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99537. * 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;
  99538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99539. */
  99540. cameraColorCurves: Nullable<ColorCurves>;
  99541. /**
  99542. * Instantiates a new PBRMaterial instance.
  99543. *
  99544. * @param name The material name
  99545. * @param scene The scene the material will be use in.
  99546. */
  99547. constructor(name: string, scene: Scene);
  99548. /**
  99549. * Returns the name of this material class.
  99550. */
  99551. getClassName(): string;
  99552. /**
  99553. * Returns an array of the actively used textures.
  99554. * @returns - Array of BaseTextures
  99555. */
  99556. getActiveTextures(): BaseTexture[];
  99557. /**
  99558. * Checks to see if a texture is used in the material.
  99559. * @param texture - Base texture to use.
  99560. * @returns - Boolean specifying if a texture is used in the material.
  99561. */
  99562. hasTexture(texture: BaseTexture): boolean;
  99563. /**
  99564. * Makes a duplicate of the current material.
  99565. * @param name - name to use for the new material.
  99566. */
  99567. clone(name: string): PBRMaterial;
  99568. /**
  99569. * Serializes this PBR Material.
  99570. * @returns - An object with the serialized material.
  99571. */
  99572. serialize(): any;
  99573. /**
  99574. * Parses a PBR Material from a serialized object.
  99575. * @param source - Serialized object.
  99576. * @param scene - BJS scene instance.
  99577. * @param rootUrl - url for the scene object
  99578. * @returns - PBRMaterial
  99579. */
  99580. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99581. }
  99582. }
  99583. declare module BABYLON {
  99584. /** @hidden */
  99585. export var _forceSceneHelpersToBundle: boolean;
  99586. interface Scene {
  99587. /**
  99588. * Creates a default light for the scene.
  99589. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99590. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99591. */
  99592. createDefaultLight(replace?: boolean): void;
  99593. /**
  99594. * Creates a default camera for the scene.
  99595. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99596. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99597. * @param replace has default false, when true replaces the active camera in the scene
  99598. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99599. */
  99600. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99601. /**
  99602. * Creates a default camera and a default light.
  99603. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99604. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99605. * @param replace has the default false, when true replaces the active camera/light in the scene
  99606. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99607. */
  99608. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99609. /**
  99610. * Creates a new sky box
  99611. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99612. * @param environmentTexture defines the texture to use as environment texture
  99613. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99614. * @param scale defines the overall scale of the skybox
  99615. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99616. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99617. * @returns a new mesh holding the sky box
  99618. */
  99619. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99620. /**
  99621. * Creates a new environment
  99622. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99623. * @param options defines the options you can use to configure the environment
  99624. * @returns the new EnvironmentHelper
  99625. */
  99626. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99627. /**
  99628. * Creates a new VREXperienceHelper
  99629. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99630. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99631. * @returns a new VREXperienceHelper
  99632. */
  99633. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99634. /**
  99635. * Creates a new XREXperienceHelper
  99636. * @see http://doc.babylonjs.com/how_to/webxr
  99637. * @returns a promise for a new XREXperienceHelper
  99638. */
  99639. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99640. }
  99641. }
  99642. declare module BABYLON {
  99643. /**
  99644. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99645. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99646. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99648. */
  99649. export class VideoDome extends TransformNode {
  99650. private _useDirectMapping;
  99651. /**
  99652. * The video texture being displayed on the sphere
  99653. */
  99654. protected _videoTexture: VideoTexture;
  99655. /**
  99656. * Gets the video texture being displayed on the sphere
  99657. */
  99658. readonly videoTexture: VideoTexture;
  99659. /**
  99660. * The skybox material
  99661. */
  99662. protected _material: BackgroundMaterial;
  99663. /**
  99664. * The surface used for the skybox
  99665. */
  99666. protected _mesh: Mesh;
  99667. /**
  99668. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99669. * Also see the options.resolution property.
  99670. */
  99671. fovMultiplier: number;
  99672. /**
  99673. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99674. * @param name Element's name, child elements will append suffixes for their own names.
  99675. * @param urlsOrVideo defines the url(s) or the video element to use
  99676. * @param options An object containing optional or exposed sub element properties
  99677. */
  99678. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99679. resolution?: number;
  99680. clickToPlay?: boolean;
  99681. autoPlay?: boolean;
  99682. loop?: boolean;
  99683. size?: number;
  99684. poster?: string;
  99685. useDirectMapping?: boolean;
  99686. }, scene: Scene);
  99687. /**
  99688. * Releases resources associated with this node.
  99689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99691. */
  99692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99693. }
  99694. }
  99695. declare module BABYLON {
  99696. /**
  99697. * This class can be used to get instrumentation data from a Babylon engine
  99698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99699. */
  99700. export class EngineInstrumentation implements IDisposable {
  99701. /**
  99702. * Define the instrumented engine.
  99703. */
  99704. engine: Engine;
  99705. private _captureGPUFrameTime;
  99706. private _gpuFrameTimeToken;
  99707. private _gpuFrameTime;
  99708. private _captureShaderCompilationTime;
  99709. private _shaderCompilationTime;
  99710. private _onBeginFrameObserver;
  99711. private _onEndFrameObserver;
  99712. private _onBeforeShaderCompilationObserver;
  99713. private _onAfterShaderCompilationObserver;
  99714. /**
  99715. * Gets the perf counter used for GPU frame time
  99716. */
  99717. readonly gpuFrameTimeCounter: PerfCounter;
  99718. /**
  99719. * Gets the GPU frame time capture status
  99720. */
  99721. /**
  99722. * Enable or disable the GPU frame time capture
  99723. */
  99724. captureGPUFrameTime: boolean;
  99725. /**
  99726. * Gets the perf counter used for shader compilation time
  99727. */
  99728. readonly shaderCompilationTimeCounter: PerfCounter;
  99729. /**
  99730. * Gets the shader compilation time capture status
  99731. */
  99732. /**
  99733. * Enable or disable the shader compilation time capture
  99734. */
  99735. captureShaderCompilationTime: boolean;
  99736. /**
  99737. * Instantiates a new engine instrumentation.
  99738. * This class can be used to get instrumentation data from a Babylon engine
  99739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99740. * @param engine Defines the engine to instrument
  99741. */
  99742. constructor(
  99743. /**
  99744. * Define the instrumented engine.
  99745. */
  99746. engine: Engine);
  99747. /**
  99748. * Dispose and release associated resources.
  99749. */
  99750. dispose(): void;
  99751. }
  99752. }
  99753. declare module BABYLON {
  99754. /**
  99755. * This class can be used to get instrumentation data from a Babylon engine
  99756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99757. */
  99758. export class SceneInstrumentation implements IDisposable {
  99759. /**
  99760. * Defines the scene to instrument
  99761. */
  99762. scene: Scene;
  99763. private _captureActiveMeshesEvaluationTime;
  99764. private _activeMeshesEvaluationTime;
  99765. private _captureRenderTargetsRenderTime;
  99766. private _renderTargetsRenderTime;
  99767. private _captureFrameTime;
  99768. private _frameTime;
  99769. private _captureRenderTime;
  99770. private _renderTime;
  99771. private _captureInterFrameTime;
  99772. private _interFrameTime;
  99773. private _captureParticlesRenderTime;
  99774. private _particlesRenderTime;
  99775. private _captureSpritesRenderTime;
  99776. private _spritesRenderTime;
  99777. private _capturePhysicsTime;
  99778. private _physicsTime;
  99779. private _captureAnimationsTime;
  99780. private _animationsTime;
  99781. private _captureCameraRenderTime;
  99782. private _cameraRenderTime;
  99783. private _onBeforeActiveMeshesEvaluationObserver;
  99784. private _onAfterActiveMeshesEvaluationObserver;
  99785. private _onBeforeRenderTargetsRenderObserver;
  99786. private _onAfterRenderTargetsRenderObserver;
  99787. private _onAfterRenderObserver;
  99788. private _onBeforeDrawPhaseObserver;
  99789. private _onAfterDrawPhaseObserver;
  99790. private _onBeforeAnimationsObserver;
  99791. private _onBeforeParticlesRenderingObserver;
  99792. private _onAfterParticlesRenderingObserver;
  99793. private _onBeforeSpritesRenderingObserver;
  99794. private _onAfterSpritesRenderingObserver;
  99795. private _onBeforePhysicsObserver;
  99796. private _onAfterPhysicsObserver;
  99797. private _onAfterAnimationsObserver;
  99798. private _onBeforeCameraRenderObserver;
  99799. private _onAfterCameraRenderObserver;
  99800. /**
  99801. * Gets the perf counter used for active meshes evaluation time
  99802. */
  99803. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99804. /**
  99805. * Gets the active meshes evaluation time capture status
  99806. */
  99807. /**
  99808. * Enable or disable the active meshes evaluation time capture
  99809. */
  99810. captureActiveMeshesEvaluationTime: boolean;
  99811. /**
  99812. * Gets the perf counter used for render targets render time
  99813. */
  99814. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99815. /**
  99816. * Gets the render targets render time capture status
  99817. */
  99818. /**
  99819. * Enable or disable the render targets render time capture
  99820. */
  99821. captureRenderTargetsRenderTime: boolean;
  99822. /**
  99823. * Gets the perf counter used for particles render time
  99824. */
  99825. readonly particlesRenderTimeCounter: PerfCounter;
  99826. /**
  99827. * Gets the particles render time capture status
  99828. */
  99829. /**
  99830. * Enable or disable the particles render time capture
  99831. */
  99832. captureParticlesRenderTime: boolean;
  99833. /**
  99834. * Gets the perf counter used for sprites render time
  99835. */
  99836. readonly spritesRenderTimeCounter: PerfCounter;
  99837. /**
  99838. * Gets the sprites render time capture status
  99839. */
  99840. /**
  99841. * Enable or disable the sprites render time capture
  99842. */
  99843. captureSpritesRenderTime: boolean;
  99844. /**
  99845. * Gets the perf counter used for physics time
  99846. */
  99847. readonly physicsTimeCounter: PerfCounter;
  99848. /**
  99849. * Gets the physics time capture status
  99850. */
  99851. /**
  99852. * Enable or disable the physics time capture
  99853. */
  99854. capturePhysicsTime: boolean;
  99855. /**
  99856. * Gets the perf counter used for animations time
  99857. */
  99858. readonly animationsTimeCounter: PerfCounter;
  99859. /**
  99860. * Gets the animations time capture status
  99861. */
  99862. /**
  99863. * Enable or disable the animations time capture
  99864. */
  99865. captureAnimationsTime: boolean;
  99866. /**
  99867. * Gets the perf counter used for frame time capture
  99868. */
  99869. readonly frameTimeCounter: PerfCounter;
  99870. /**
  99871. * Gets the frame time capture status
  99872. */
  99873. /**
  99874. * Enable or disable the frame time capture
  99875. */
  99876. captureFrameTime: boolean;
  99877. /**
  99878. * Gets the perf counter used for inter-frames time capture
  99879. */
  99880. readonly interFrameTimeCounter: PerfCounter;
  99881. /**
  99882. * Gets the inter-frames time capture status
  99883. */
  99884. /**
  99885. * Enable or disable the inter-frames time capture
  99886. */
  99887. captureInterFrameTime: boolean;
  99888. /**
  99889. * Gets the perf counter used for render time capture
  99890. */
  99891. readonly renderTimeCounter: PerfCounter;
  99892. /**
  99893. * Gets the render time capture status
  99894. */
  99895. /**
  99896. * Enable or disable the render time capture
  99897. */
  99898. captureRenderTime: boolean;
  99899. /**
  99900. * Gets the perf counter used for camera render time capture
  99901. */
  99902. readonly cameraRenderTimeCounter: PerfCounter;
  99903. /**
  99904. * Gets the camera render time capture status
  99905. */
  99906. /**
  99907. * Enable or disable the camera render time capture
  99908. */
  99909. captureCameraRenderTime: boolean;
  99910. /**
  99911. * Gets the perf counter used for draw calls
  99912. */
  99913. readonly drawCallsCounter: PerfCounter;
  99914. /**
  99915. * Gets the perf counter used for texture collisions
  99916. */
  99917. readonly textureCollisionsCounter: PerfCounter;
  99918. /**
  99919. * Instantiates a new scene instrumentation.
  99920. * This class can be used to get instrumentation data from a Babylon engine
  99921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99922. * @param scene Defines the scene to instrument
  99923. */
  99924. constructor(
  99925. /**
  99926. * Defines the scene to instrument
  99927. */
  99928. scene: Scene);
  99929. /**
  99930. * Dispose and release associated resources.
  99931. */
  99932. dispose(): void;
  99933. }
  99934. }
  99935. declare module BABYLON {
  99936. /** @hidden */
  99937. export var glowMapGenerationPixelShader: {
  99938. name: string;
  99939. shader: string;
  99940. };
  99941. }
  99942. declare module BABYLON {
  99943. /** @hidden */
  99944. export var glowMapGenerationVertexShader: {
  99945. name: string;
  99946. shader: string;
  99947. };
  99948. }
  99949. declare module BABYLON {
  99950. /**
  99951. * Effect layer options. This helps customizing the behaviour
  99952. * of the effect layer.
  99953. */
  99954. export interface IEffectLayerOptions {
  99955. /**
  99956. * Multiplication factor apply to the canvas size to compute the render target size
  99957. * used to generated the objects (the smaller the faster).
  99958. */
  99959. mainTextureRatio: number;
  99960. /**
  99961. * Enforces a fixed size texture to ensure effect stability across devices.
  99962. */
  99963. mainTextureFixedSize?: number;
  99964. /**
  99965. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  99966. */
  99967. alphaBlendingMode: number;
  99968. /**
  99969. * The camera attached to the layer.
  99970. */
  99971. camera: Nullable<Camera>;
  99972. /**
  99973. * The rendering group to draw the layer in.
  99974. */
  99975. renderingGroupId: number;
  99976. }
  99977. /**
  99978. * The effect layer Helps adding post process effect blended with the main pass.
  99979. *
  99980. * This can be for instance use to generate glow or higlight effects on the scene.
  99981. *
  99982. * The effect layer class can not be used directly and is intented to inherited from to be
  99983. * customized per effects.
  99984. */
  99985. export abstract class EffectLayer {
  99986. private _vertexBuffers;
  99987. private _indexBuffer;
  99988. private _cachedDefines;
  99989. private _effectLayerMapGenerationEffect;
  99990. private _effectLayerOptions;
  99991. private _mergeEffect;
  99992. protected _scene: Scene;
  99993. protected _engine: Engine;
  99994. protected _maxSize: number;
  99995. protected _mainTextureDesiredSize: ISize;
  99996. protected _mainTexture: RenderTargetTexture;
  99997. protected _shouldRender: boolean;
  99998. protected _postProcesses: PostProcess[];
  99999. protected _textures: BaseTexture[];
  100000. protected _emissiveTextureAndColor: {
  100001. texture: Nullable<BaseTexture>;
  100002. color: Color4;
  100003. };
  100004. /**
  100005. * The name of the layer
  100006. */
  100007. name: string;
  100008. /**
  100009. * The clear color of the texture used to generate the glow map.
  100010. */
  100011. neutralColor: Color4;
  100012. /**
  100013. * Specifies wether the highlight layer is enabled or not.
  100014. */
  100015. isEnabled: boolean;
  100016. /**
  100017. * Gets the camera attached to the layer.
  100018. */
  100019. readonly camera: Nullable<Camera>;
  100020. /**
  100021. * Gets the rendering group id the layer should render in.
  100022. */
  100023. readonly renderingGroupId: number;
  100024. /**
  100025. * An event triggered when the effect layer has been disposed.
  100026. */
  100027. onDisposeObservable: Observable<EffectLayer>;
  100028. /**
  100029. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100030. */
  100031. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100032. /**
  100033. * An event triggered when the generated texture is being merged in the scene.
  100034. */
  100035. onBeforeComposeObservable: Observable<EffectLayer>;
  100036. /**
  100037. * An event triggered when the generated texture has been merged in the scene.
  100038. */
  100039. onAfterComposeObservable: Observable<EffectLayer>;
  100040. /**
  100041. * An event triggered when the efffect layer changes its size.
  100042. */
  100043. onSizeChangedObservable: Observable<EffectLayer>;
  100044. /** @hidden */
  100045. static _SceneComponentInitialization: (scene: Scene) => void;
  100046. /**
  100047. * Instantiates a new effect Layer and references it in the scene.
  100048. * @param name The name of the layer
  100049. * @param scene The scene to use the layer in
  100050. */
  100051. constructor(
  100052. /** The Friendly of the effect in the scene */
  100053. name: string, scene: Scene);
  100054. /**
  100055. * Get the effect name of the layer.
  100056. * @return The effect name
  100057. */
  100058. abstract getEffectName(): string;
  100059. /**
  100060. * Checks for the readiness of the element composing the layer.
  100061. * @param subMesh the mesh to check for
  100062. * @param useInstances specify wether or not to use instances to render the mesh
  100063. * @return true if ready otherwise, false
  100064. */
  100065. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100066. /**
  100067. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100068. * @returns true if the effect requires stencil during the main canvas render pass.
  100069. */
  100070. abstract needStencil(): boolean;
  100071. /**
  100072. * Create the merge effect. This is the shader use to blit the information back
  100073. * to the main canvas at the end of the scene rendering.
  100074. * @returns The effect containing the shader used to merge the effect on the main canvas
  100075. */
  100076. protected abstract _createMergeEffect(): Effect;
  100077. /**
  100078. * Creates the render target textures and post processes used in the effect layer.
  100079. */
  100080. protected abstract _createTextureAndPostProcesses(): void;
  100081. /**
  100082. * Implementation specific of rendering the generating effect on the main canvas.
  100083. * @param effect The effect used to render through
  100084. */
  100085. protected abstract _internalRender(effect: Effect): void;
  100086. /**
  100087. * Sets the required values for both the emissive texture and and the main color.
  100088. */
  100089. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100090. /**
  100091. * Free any resources and references associated to a mesh.
  100092. * Internal use
  100093. * @param mesh The mesh to free.
  100094. */
  100095. abstract _disposeMesh(mesh: Mesh): void;
  100096. /**
  100097. * Serializes this layer (Glow or Highlight for example)
  100098. * @returns a serialized layer object
  100099. */
  100100. abstract serialize?(): any;
  100101. /**
  100102. * Initializes the effect layer with the required options.
  100103. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100104. */
  100105. protected _init(options: Partial<IEffectLayerOptions>): void;
  100106. /**
  100107. * Generates the index buffer of the full screen quad blending to the main canvas.
  100108. */
  100109. private _generateIndexBuffer;
  100110. /**
  100111. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100112. */
  100113. private _genrateVertexBuffer;
  100114. /**
  100115. * Sets the main texture desired size which is the closest power of two
  100116. * of the engine canvas size.
  100117. */
  100118. private _setMainTextureSize;
  100119. /**
  100120. * Creates the main texture for the effect layer.
  100121. */
  100122. protected _createMainTexture(): void;
  100123. /**
  100124. * Adds specific effects defines.
  100125. * @param defines The defines to add specifics to.
  100126. */
  100127. protected _addCustomEffectDefines(defines: string[]): void;
  100128. /**
  100129. * Checks for the readiness of the element composing the layer.
  100130. * @param subMesh the mesh to check for
  100131. * @param useInstances specify wether or not to use instances to render the mesh
  100132. * @param emissiveTexture the associated emissive texture used to generate the glow
  100133. * @return true if ready otherwise, false
  100134. */
  100135. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100136. /**
  100137. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100138. */
  100139. render(): void;
  100140. /**
  100141. * Determine if a given mesh will be used in the current effect.
  100142. * @param mesh mesh to test
  100143. * @returns true if the mesh will be used
  100144. */
  100145. hasMesh(mesh: AbstractMesh): boolean;
  100146. /**
  100147. * Returns true if the layer contains information to display, otherwise false.
  100148. * @returns true if the glow layer should be rendered
  100149. */
  100150. shouldRender(): boolean;
  100151. /**
  100152. * Returns true if the mesh should render, otherwise false.
  100153. * @param mesh The mesh to render
  100154. * @returns true if it should render otherwise false
  100155. */
  100156. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100157. /**
  100158. * Returns true if the mesh can be rendered, otherwise false.
  100159. * @param mesh The mesh to render
  100160. * @param material The material used on the mesh
  100161. * @returns true if it can be rendered otherwise false
  100162. */
  100163. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100164. /**
  100165. * Returns true if the mesh should render, otherwise false.
  100166. * @param mesh The mesh to render
  100167. * @returns true if it should render otherwise false
  100168. */
  100169. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100170. /**
  100171. * Renders the submesh passed in parameter to the generation map.
  100172. */
  100173. protected _renderSubMesh(subMesh: SubMesh): void;
  100174. /**
  100175. * Rebuild the required buffers.
  100176. * @hidden Internal use only.
  100177. */
  100178. _rebuild(): void;
  100179. /**
  100180. * Dispose only the render target textures and post process.
  100181. */
  100182. private _disposeTextureAndPostProcesses;
  100183. /**
  100184. * Dispose the highlight layer and free resources.
  100185. */
  100186. dispose(): void;
  100187. /**
  100188. * Gets the class name of the effect layer
  100189. * @returns the string with the class name of the effect layer
  100190. */
  100191. getClassName(): string;
  100192. /**
  100193. * Creates an effect layer from parsed effect layer data
  100194. * @param parsedEffectLayer defines effect layer data
  100195. * @param scene defines the current scene
  100196. * @param rootUrl defines the root URL containing the effect layer information
  100197. * @returns a parsed effect Layer
  100198. */
  100199. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100200. }
  100201. }
  100202. declare module BABYLON {
  100203. interface AbstractScene {
  100204. /**
  100205. * The list of effect layers (highlights/glow) added to the scene
  100206. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100207. * @see http://doc.babylonjs.com/how_to/glow_layer
  100208. */
  100209. effectLayers: Array<EffectLayer>;
  100210. /**
  100211. * Removes the given effect layer from this scene.
  100212. * @param toRemove defines the effect layer to remove
  100213. * @returns the index of the removed effect layer
  100214. */
  100215. removeEffectLayer(toRemove: EffectLayer): number;
  100216. /**
  100217. * Adds the given effect layer to this scene
  100218. * @param newEffectLayer defines the effect layer to add
  100219. */
  100220. addEffectLayer(newEffectLayer: EffectLayer): void;
  100221. }
  100222. /**
  100223. * Defines the layer scene component responsible to manage any effect layers
  100224. * in a given scene.
  100225. */
  100226. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100227. /**
  100228. * The component name helpfull to identify the component in the list of scene components.
  100229. */
  100230. readonly name: string;
  100231. /**
  100232. * The scene the component belongs to.
  100233. */
  100234. scene: Scene;
  100235. private _engine;
  100236. private _renderEffects;
  100237. private _needStencil;
  100238. private _previousStencilState;
  100239. /**
  100240. * Creates a new instance of the component for the given scene
  100241. * @param scene Defines the scene to register the component in
  100242. */
  100243. constructor(scene: Scene);
  100244. /**
  100245. * Registers the component in a given scene
  100246. */
  100247. register(): void;
  100248. /**
  100249. * Rebuilds the elements related to this component in case of
  100250. * context lost for instance.
  100251. */
  100252. rebuild(): void;
  100253. /**
  100254. * Serializes the component data to the specified json object
  100255. * @param serializationObject The object to serialize to
  100256. */
  100257. serialize(serializationObject: any): void;
  100258. /**
  100259. * Adds all the element from the container to the scene
  100260. * @param container the container holding the elements
  100261. */
  100262. addFromContainer(container: AbstractScene): void;
  100263. /**
  100264. * Removes all the elements in the container from the scene
  100265. * @param container contains the elements to remove
  100266. */
  100267. removeFromContainer(container: AbstractScene): void;
  100268. /**
  100269. * Disposes the component and the associated ressources.
  100270. */
  100271. dispose(): void;
  100272. private _isReadyForMesh;
  100273. private _renderMainTexture;
  100274. private _setStencil;
  100275. private _setStencilBack;
  100276. private _draw;
  100277. private _drawCamera;
  100278. private _drawRenderingGroup;
  100279. }
  100280. }
  100281. declare module BABYLON {
  100282. /** @hidden */
  100283. export var glowMapMergePixelShader: {
  100284. name: string;
  100285. shader: string;
  100286. };
  100287. }
  100288. declare module BABYLON {
  100289. /** @hidden */
  100290. export var glowMapMergeVertexShader: {
  100291. name: string;
  100292. shader: string;
  100293. };
  100294. }
  100295. declare module BABYLON {
  100296. interface AbstractScene {
  100297. /**
  100298. * Return a the first highlight layer of the scene with a given name.
  100299. * @param name The name of the highlight layer to look for.
  100300. * @return The highlight layer if found otherwise null.
  100301. */
  100302. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100303. }
  100304. /**
  100305. * Glow layer options. This helps customizing the behaviour
  100306. * of the glow layer.
  100307. */
  100308. export interface IGlowLayerOptions {
  100309. /**
  100310. * Multiplication factor apply to the canvas size to compute the render target size
  100311. * used to generated the glowing objects (the smaller the faster).
  100312. */
  100313. mainTextureRatio: number;
  100314. /**
  100315. * Enforces a fixed size texture to ensure resize independant blur.
  100316. */
  100317. mainTextureFixedSize?: number;
  100318. /**
  100319. * How big is the kernel of the blur texture.
  100320. */
  100321. blurKernelSize: number;
  100322. /**
  100323. * The camera attached to the layer.
  100324. */
  100325. camera: Nullable<Camera>;
  100326. /**
  100327. * Enable MSAA by chosing the number of samples.
  100328. */
  100329. mainTextureSamples?: number;
  100330. /**
  100331. * The rendering group to draw the layer in.
  100332. */
  100333. renderingGroupId: number;
  100334. }
  100335. /**
  100336. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100337. *
  100338. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100339. * glowy meshes to your scene.
  100340. *
  100341. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100342. */
  100343. export class GlowLayer extends EffectLayer {
  100344. /**
  100345. * Effect Name of the layer.
  100346. */
  100347. static readonly EffectName: string;
  100348. /**
  100349. * The default blur kernel size used for the glow.
  100350. */
  100351. static DefaultBlurKernelSize: number;
  100352. /**
  100353. * The default texture size ratio used for the glow.
  100354. */
  100355. static DefaultTextureRatio: number;
  100356. /**
  100357. * Sets the kernel size of the blur.
  100358. */
  100359. /**
  100360. * Gets the kernel size of the blur.
  100361. */
  100362. blurKernelSize: number;
  100363. /**
  100364. * Sets the glow intensity.
  100365. */
  100366. /**
  100367. * Gets the glow intensity.
  100368. */
  100369. intensity: number;
  100370. private _options;
  100371. private _intensity;
  100372. private _horizontalBlurPostprocess1;
  100373. private _verticalBlurPostprocess1;
  100374. private _horizontalBlurPostprocess2;
  100375. private _verticalBlurPostprocess2;
  100376. private _blurTexture1;
  100377. private _blurTexture2;
  100378. private _postProcesses1;
  100379. private _postProcesses2;
  100380. private _includedOnlyMeshes;
  100381. private _excludedMeshes;
  100382. /**
  100383. * Callback used to let the user override the color selection on a per mesh basis
  100384. */
  100385. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100386. /**
  100387. * Callback used to let the user override the texture selection on a per mesh basis
  100388. */
  100389. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100390. /**
  100391. * Instantiates a new glow Layer and references it to the scene.
  100392. * @param name The name of the layer
  100393. * @param scene The scene to use the layer in
  100394. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100395. */
  100396. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100397. /**
  100398. * Get the effect name of the layer.
  100399. * @return The effect name
  100400. */
  100401. getEffectName(): string;
  100402. /**
  100403. * Create the merge effect. This is the shader use to blit the information back
  100404. * to the main canvas at the end of the scene rendering.
  100405. */
  100406. protected _createMergeEffect(): Effect;
  100407. /**
  100408. * Creates the render target textures and post processes used in the glow layer.
  100409. */
  100410. protected _createTextureAndPostProcesses(): void;
  100411. /**
  100412. * Checks for the readiness of the element composing the layer.
  100413. * @param subMesh the mesh to check for
  100414. * @param useInstances specify wether or not to use instances to render the mesh
  100415. * @param emissiveTexture the associated emissive texture used to generate the glow
  100416. * @return true if ready otherwise, false
  100417. */
  100418. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100419. /**
  100420. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100421. */
  100422. needStencil(): boolean;
  100423. /**
  100424. * Returns true if the mesh can be rendered, otherwise false.
  100425. * @param mesh The mesh to render
  100426. * @param material The material used on the mesh
  100427. * @returns true if it can be rendered otherwise false
  100428. */
  100429. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100430. /**
  100431. * Implementation specific of rendering the generating effect on the main canvas.
  100432. * @param effect The effect used to render through
  100433. */
  100434. protected _internalRender(effect: Effect): void;
  100435. /**
  100436. * Sets the required values for both the emissive texture and and the main color.
  100437. */
  100438. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100439. /**
  100440. * Returns true if the mesh should render, otherwise false.
  100441. * @param mesh The mesh to render
  100442. * @returns true if it should render otherwise false
  100443. */
  100444. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100445. /**
  100446. * Adds specific effects defines.
  100447. * @param defines The defines to add specifics to.
  100448. */
  100449. protected _addCustomEffectDefines(defines: string[]): void;
  100450. /**
  100451. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100452. * @param mesh The mesh to exclude from the glow layer
  100453. */
  100454. addExcludedMesh(mesh: Mesh): void;
  100455. /**
  100456. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100457. * @param mesh The mesh to remove
  100458. */
  100459. removeExcludedMesh(mesh: Mesh): void;
  100460. /**
  100461. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100462. * @param mesh The mesh to include in the glow layer
  100463. */
  100464. addIncludedOnlyMesh(mesh: Mesh): void;
  100465. /**
  100466. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100467. * @param mesh The mesh to remove
  100468. */
  100469. removeIncludedOnlyMesh(mesh: Mesh): void;
  100470. /**
  100471. * Determine if a given mesh will be used in the glow layer
  100472. * @param mesh The mesh to test
  100473. * @returns true if the mesh will be highlighted by the current glow layer
  100474. */
  100475. hasMesh(mesh: AbstractMesh): boolean;
  100476. /**
  100477. * Free any resources and references associated to a mesh.
  100478. * Internal use
  100479. * @param mesh The mesh to free.
  100480. * @hidden
  100481. */
  100482. _disposeMesh(mesh: Mesh): void;
  100483. /**
  100484. * Gets the class name of the effect layer
  100485. * @returns the string with the class name of the effect layer
  100486. */
  100487. getClassName(): string;
  100488. /**
  100489. * Serializes this glow layer
  100490. * @returns a serialized glow layer object
  100491. */
  100492. serialize(): any;
  100493. /**
  100494. * Creates a Glow Layer from parsed glow layer data
  100495. * @param parsedGlowLayer defines glow layer data
  100496. * @param scene defines the current scene
  100497. * @param rootUrl defines the root URL containing the glow layer information
  100498. * @returns a parsed Glow Layer
  100499. */
  100500. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100501. }
  100502. }
  100503. declare module BABYLON {
  100504. /** @hidden */
  100505. export var glowBlurPostProcessPixelShader: {
  100506. name: string;
  100507. shader: string;
  100508. };
  100509. }
  100510. declare module BABYLON {
  100511. interface AbstractScene {
  100512. /**
  100513. * Return a the first highlight layer of the scene with a given name.
  100514. * @param name The name of the highlight layer to look for.
  100515. * @return The highlight layer if found otherwise null.
  100516. */
  100517. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100518. }
  100519. /**
  100520. * Highlight layer options. This helps customizing the behaviour
  100521. * of the highlight layer.
  100522. */
  100523. export interface IHighlightLayerOptions {
  100524. /**
  100525. * Multiplication factor apply to the canvas size to compute the render target size
  100526. * used to generated the glowing objects (the smaller the faster).
  100527. */
  100528. mainTextureRatio: number;
  100529. /**
  100530. * Enforces a fixed size texture to ensure resize independant blur.
  100531. */
  100532. mainTextureFixedSize?: number;
  100533. /**
  100534. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100535. * of the picture to blur (the smaller the faster).
  100536. */
  100537. blurTextureSizeRatio: number;
  100538. /**
  100539. * How big in texel of the blur texture is the vertical blur.
  100540. */
  100541. blurVerticalSize: number;
  100542. /**
  100543. * How big in texel of the blur texture is the horizontal blur.
  100544. */
  100545. blurHorizontalSize: number;
  100546. /**
  100547. * Alpha blending mode used to apply the blur. Default is combine.
  100548. */
  100549. alphaBlendingMode: number;
  100550. /**
  100551. * The camera attached to the layer.
  100552. */
  100553. camera: Nullable<Camera>;
  100554. /**
  100555. * Should we display highlight as a solid stroke?
  100556. */
  100557. isStroke?: boolean;
  100558. /**
  100559. * The rendering group to draw the layer in.
  100560. */
  100561. renderingGroupId: number;
  100562. }
  100563. /**
  100564. * The highlight layer Helps adding a glow effect around a mesh.
  100565. *
  100566. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100567. * glowy meshes to your scene.
  100568. *
  100569. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100570. */
  100571. export class HighlightLayer extends EffectLayer {
  100572. name: string;
  100573. /**
  100574. * Effect Name of the highlight layer.
  100575. */
  100576. static readonly EffectName: string;
  100577. /**
  100578. * The neutral color used during the preparation of the glow effect.
  100579. * This is black by default as the blend operation is a blend operation.
  100580. */
  100581. static NeutralColor: Color4;
  100582. /**
  100583. * Stencil value used for glowing meshes.
  100584. */
  100585. static GlowingMeshStencilReference: number;
  100586. /**
  100587. * Stencil value used for the other meshes in the scene.
  100588. */
  100589. static NormalMeshStencilReference: number;
  100590. /**
  100591. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100592. */
  100593. innerGlow: boolean;
  100594. /**
  100595. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100596. */
  100597. outerGlow: boolean;
  100598. /**
  100599. * Specifies the horizontal size of the blur.
  100600. */
  100601. /**
  100602. * Gets the horizontal size of the blur.
  100603. */
  100604. blurHorizontalSize: number;
  100605. /**
  100606. * Specifies the vertical size of the blur.
  100607. */
  100608. /**
  100609. * Gets the vertical size of the blur.
  100610. */
  100611. blurVerticalSize: number;
  100612. /**
  100613. * An event triggered when the highlight layer is being blurred.
  100614. */
  100615. onBeforeBlurObservable: Observable<HighlightLayer>;
  100616. /**
  100617. * An event triggered when the highlight layer has been blurred.
  100618. */
  100619. onAfterBlurObservable: Observable<HighlightLayer>;
  100620. private _instanceGlowingMeshStencilReference;
  100621. private _options;
  100622. private _downSamplePostprocess;
  100623. private _horizontalBlurPostprocess;
  100624. private _verticalBlurPostprocess;
  100625. private _blurTexture;
  100626. private _meshes;
  100627. private _excludedMeshes;
  100628. /**
  100629. * Instantiates a new highlight Layer and references it to the scene..
  100630. * @param name The name of the layer
  100631. * @param scene The scene to use the layer in
  100632. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100633. */
  100634. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100635. /**
  100636. * Get the effect name of the layer.
  100637. * @return The effect name
  100638. */
  100639. getEffectName(): string;
  100640. /**
  100641. * Create the merge effect. This is the shader use to blit the information back
  100642. * to the main canvas at the end of the scene rendering.
  100643. */
  100644. protected _createMergeEffect(): Effect;
  100645. /**
  100646. * Creates the render target textures and post processes used in the highlight layer.
  100647. */
  100648. protected _createTextureAndPostProcesses(): void;
  100649. /**
  100650. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100651. */
  100652. needStencil(): boolean;
  100653. /**
  100654. * Checks for the readiness of the element composing the layer.
  100655. * @param subMesh the mesh to check for
  100656. * @param useInstances specify wether or not to use instances to render the mesh
  100657. * @param emissiveTexture the associated emissive texture used to generate the glow
  100658. * @return true if ready otherwise, false
  100659. */
  100660. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100661. /**
  100662. * Implementation specific of rendering the generating effect on the main canvas.
  100663. * @param effect The effect used to render through
  100664. */
  100665. protected _internalRender(effect: Effect): void;
  100666. /**
  100667. * Returns true if the layer contains information to display, otherwise false.
  100668. */
  100669. shouldRender(): boolean;
  100670. /**
  100671. * Returns true if the mesh should render, otherwise false.
  100672. * @param mesh The mesh to render
  100673. * @returns true if it should render otherwise false
  100674. */
  100675. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100676. /**
  100677. * Sets the required values for both the emissive texture and and the main color.
  100678. */
  100679. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100680. /**
  100681. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100682. * @param mesh The mesh to exclude from the highlight layer
  100683. */
  100684. addExcludedMesh(mesh: Mesh): void;
  100685. /**
  100686. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100687. * @param mesh The mesh to highlight
  100688. */
  100689. removeExcludedMesh(mesh: Mesh): void;
  100690. /**
  100691. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100692. * @param mesh mesh to test
  100693. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100694. */
  100695. hasMesh(mesh: AbstractMesh): boolean;
  100696. /**
  100697. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100698. * @param mesh The mesh to highlight
  100699. * @param color The color of the highlight
  100700. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100701. */
  100702. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100703. /**
  100704. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100705. * @param mesh The mesh to highlight
  100706. */
  100707. removeMesh(mesh: Mesh): void;
  100708. /**
  100709. * Force the stencil to the normal expected value for none glowing parts
  100710. */
  100711. private _defaultStencilReference;
  100712. /**
  100713. * Free any resources and references associated to a mesh.
  100714. * Internal use
  100715. * @param mesh The mesh to free.
  100716. * @hidden
  100717. */
  100718. _disposeMesh(mesh: Mesh): void;
  100719. /**
  100720. * Dispose the highlight layer and free resources.
  100721. */
  100722. dispose(): void;
  100723. /**
  100724. * Gets the class name of the effect layer
  100725. * @returns the string with the class name of the effect layer
  100726. */
  100727. getClassName(): string;
  100728. /**
  100729. * Serializes this Highlight layer
  100730. * @returns a serialized Highlight layer object
  100731. */
  100732. serialize(): any;
  100733. /**
  100734. * Creates a Highlight layer from parsed Highlight layer data
  100735. * @param parsedHightlightLayer defines the Highlight layer data
  100736. * @param scene defines the current scene
  100737. * @param rootUrl defines the root URL containing the Highlight layer information
  100738. * @returns a parsed Highlight layer
  100739. */
  100740. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100741. }
  100742. }
  100743. declare module BABYLON {
  100744. /** @hidden */
  100745. export var lensFlarePixelShader: {
  100746. name: string;
  100747. shader: string;
  100748. };
  100749. }
  100750. declare module BABYLON {
  100751. /** @hidden */
  100752. export var lensFlareVertexShader: {
  100753. name: string;
  100754. shader: string;
  100755. };
  100756. }
  100757. declare module BABYLON {
  100758. /**
  100759. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100760. * It is usually composed of several `lensFlare`.
  100761. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100762. */
  100763. export class LensFlareSystem {
  100764. /**
  100765. * Define the name of the lens flare system
  100766. */
  100767. name: string;
  100768. /**
  100769. * List of lens flares used in this system.
  100770. */
  100771. lensFlares: LensFlare[];
  100772. /**
  100773. * Define a limit from the border the lens flare can be visible.
  100774. */
  100775. borderLimit: number;
  100776. /**
  100777. * Define a viewport border we do not want to see the lens flare in.
  100778. */
  100779. viewportBorder: number;
  100780. /**
  100781. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100782. */
  100783. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100784. /**
  100785. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100786. */
  100787. layerMask: number;
  100788. /**
  100789. * Define the id of the lens flare system in the scene.
  100790. * (equal to name by default)
  100791. */
  100792. id: string;
  100793. private _scene;
  100794. private _emitter;
  100795. private _vertexBuffers;
  100796. private _indexBuffer;
  100797. private _effect;
  100798. private _positionX;
  100799. private _positionY;
  100800. private _isEnabled;
  100801. /** @hidden */
  100802. static _SceneComponentInitialization: (scene: Scene) => void;
  100803. /**
  100804. * Instantiates a lens flare system.
  100805. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100806. * It is usually composed of several `lensFlare`.
  100807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100808. * @param name Define the name of the lens flare system in the scene
  100809. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100810. * @param scene Define the scene the lens flare system belongs to
  100811. */
  100812. constructor(
  100813. /**
  100814. * Define the name of the lens flare system
  100815. */
  100816. name: string, emitter: any, scene: Scene);
  100817. /**
  100818. * Define if the lens flare system is enabled.
  100819. */
  100820. isEnabled: boolean;
  100821. /**
  100822. * Get the scene the effects belongs to.
  100823. * @returns the scene holding the lens flare system
  100824. */
  100825. getScene(): Scene;
  100826. /**
  100827. * Get the emitter of the lens flare system.
  100828. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100829. * @returns the emitter of the lens flare system
  100830. */
  100831. getEmitter(): any;
  100832. /**
  100833. * Set the emitter of the lens flare system.
  100834. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100835. * @param newEmitter Define the new emitter of the system
  100836. */
  100837. setEmitter(newEmitter: any): void;
  100838. /**
  100839. * Get the lens flare system emitter position.
  100840. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100841. * @returns the position
  100842. */
  100843. getEmitterPosition(): Vector3;
  100844. /**
  100845. * @hidden
  100846. */
  100847. computeEffectivePosition(globalViewport: Viewport): boolean;
  100848. /** @hidden */
  100849. _isVisible(): boolean;
  100850. /**
  100851. * @hidden
  100852. */
  100853. render(): boolean;
  100854. /**
  100855. * Dispose and release the lens flare with its associated resources.
  100856. */
  100857. dispose(): void;
  100858. /**
  100859. * Parse a lens flare system from a JSON repressentation
  100860. * @param parsedLensFlareSystem Define the JSON to parse
  100861. * @param scene Define the scene the parsed system should be instantiated in
  100862. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100863. * @returns the parsed system
  100864. */
  100865. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100866. /**
  100867. * Serialize the current Lens Flare System into a JSON representation.
  100868. * @returns the serialized JSON
  100869. */
  100870. serialize(): any;
  100871. }
  100872. }
  100873. declare module BABYLON {
  100874. /**
  100875. * This represents one of the lens effect in a `lensFlareSystem`.
  100876. * It controls one of the indiviual texture used in the effect.
  100877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100878. */
  100879. export class LensFlare {
  100880. /**
  100881. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100882. */
  100883. size: number;
  100884. /**
  100885. * 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.
  100886. */
  100887. position: number;
  100888. /**
  100889. * Define the lens color.
  100890. */
  100891. color: Color3;
  100892. /**
  100893. * Define the lens texture.
  100894. */
  100895. texture: Nullable<Texture>;
  100896. /**
  100897. * Define the alpha mode to render this particular lens.
  100898. */
  100899. alphaMode: number;
  100900. private _system;
  100901. /**
  100902. * Creates a new Lens Flare.
  100903. * This represents one of the lens effect in a `lensFlareSystem`.
  100904. * It controls one of the indiviual texture used in the effect.
  100905. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100906. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  100907. * @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.
  100908. * @param color Define the lens color
  100909. * @param imgUrl Define the lens texture url
  100910. * @param system Define the `lensFlareSystem` this flare is part of
  100911. * @returns The newly created Lens Flare
  100912. */
  100913. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  100914. /**
  100915. * Instantiates a new Lens Flare.
  100916. * This represents one of the lens effect in a `lensFlareSystem`.
  100917. * It controls one of the indiviual texture used in the effect.
  100918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100919. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  100920. * @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.
  100921. * @param color Define the lens color
  100922. * @param imgUrl Define the lens texture url
  100923. * @param system Define the `lensFlareSystem` this flare is part of
  100924. */
  100925. constructor(
  100926. /**
  100927. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100928. */
  100929. size: number,
  100930. /**
  100931. * 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.
  100932. */
  100933. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  100934. /**
  100935. * Dispose and release the lens flare with its associated resources.
  100936. */
  100937. dispose(): void;
  100938. }
  100939. }
  100940. declare module BABYLON {
  100941. interface AbstractScene {
  100942. /**
  100943. * The list of lens flare system added to the scene
  100944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100945. */
  100946. lensFlareSystems: Array<LensFlareSystem>;
  100947. /**
  100948. * Removes the given lens flare system from this scene.
  100949. * @param toRemove The lens flare system to remove
  100950. * @returns The index of the removed lens flare system
  100951. */
  100952. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  100953. /**
  100954. * Adds the given lens flare system to this scene
  100955. * @param newLensFlareSystem The lens flare system to add
  100956. */
  100957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  100958. /**
  100959. * Gets a lens flare system using its name
  100960. * @param name defines the name to look for
  100961. * @returns the lens flare system or null if not found
  100962. */
  100963. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  100964. /**
  100965. * Gets a lens flare system using its id
  100966. * @param id defines the id to look for
  100967. * @returns the lens flare system or null if not found
  100968. */
  100969. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  100970. }
  100971. /**
  100972. * Defines the lens flare scene component responsible to manage any lens flares
  100973. * in a given scene.
  100974. */
  100975. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  100976. /**
  100977. * The component name helpfull to identify the component in the list of scene components.
  100978. */
  100979. readonly name: string;
  100980. /**
  100981. * The scene the component belongs to.
  100982. */
  100983. scene: Scene;
  100984. /**
  100985. * Creates a new instance of the component for the given scene
  100986. * @param scene Defines the scene to register the component in
  100987. */
  100988. constructor(scene: Scene);
  100989. /**
  100990. * Registers the component in a given scene
  100991. */
  100992. register(): void;
  100993. /**
  100994. * Rebuilds the elements related to this component in case of
  100995. * context lost for instance.
  100996. */
  100997. rebuild(): void;
  100998. /**
  100999. * Adds all the element from the container to the scene
  101000. * @param container the container holding the elements
  101001. */
  101002. addFromContainer(container: AbstractScene): void;
  101003. /**
  101004. * Removes all the elements in the container from the scene
  101005. * @param container contains the elements to remove
  101006. */
  101007. removeFromContainer(container: AbstractScene): void;
  101008. /**
  101009. * Serializes the component data to the specified json object
  101010. * @param serializationObject The object to serialize to
  101011. */
  101012. serialize(serializationObject: any): void;
  101013. /**
  101014. * Disposes the component and the associated ressources.
  101015. */
  101016. dispose(): void;
  101017. private _draw;
  101018. }
  101019. }
  101020. declare module BABYLON {
  101021. /**
  101022. * Defines the shadow generator component responsible to manage any shadow generators
  101023. * in a given scene.
  101024. */
  101025. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101026. /**
  101027. * The component name helpfull to identify the component in the list of scene components.
  101028. */
  101029. readonly name: string;
  101030. /**
  101031. * The scene the component belongs to.
  101032. */
  101033. scene: Scene;
  101034. /**
  101035. * Creates a new instance of the component for the given scene
  101036. * @param scene Defines the scene to register the component in
  101037. */
  101038. constructor(scene: Scene);
  101039. /**
  101040. * Registers the component in a given scene
  101041. */
  101042. register(): void;
  101043. /**
  101044. * Rebuilds the elements related to this component in case of
  101045. * context lost for instance.
  101046. */
  101047. rebuild(): void;
  101048. /**
  101049. * Serializes the component data to the specified json object
  101050. * @param serializationObject The object to serialize to
  101051. */
  101052. serialize(serializationObject: any): void;
  101053. /**
  101054. * Adds all the element from the container to the scene
  101055. * @param container the container holding the elements
  101056. */
  101057. addFromContainer(container: AbstractScene): void;
  101058. /**
  101059. * Removes all the elements in the container from the scene
  101060. * @param container contains the elements to remove
  101061. */
  101062. removeFromContainer(container: AbstractScene): void;
  101063. /**
  101064. * Rebuilds the elements related to this component in case of
  101065. * context lost for instance.
  101066. */
  101067. dispose(): void;
  101068. private _gatherRenderTargets;
  101069. }
  101070. }
  101071. declare module BABYLON {
  101072. /**
  101073. * A directional light is defined by a direction (what a surprise!).
  101074. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101075. * 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.
  101076. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101077. */
  101078. export class DirectionalLight extends ShadowLight {
  101079. private _shadowFrustumSize;
  101080. /**
  101081. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101082. */
  101083. /**
  101084. * Specifies a fix frustum size for the shadow generation.
  101085. */
  101086. shadowFrustumSize: number;
  101087. private _shadowOrthoScale;
  101088. /**
  101089. * Gets the shadow projection scale against the optimal computed one.
  101090. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101091. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101092. */
  101093. /**
  101094. * Sets the shadow projection scale against the optimal computed one.
  101095. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101096. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101097. */
  101098. shadowOrthoScale: number;
  101099. /**
  101100. * Automatically compute the projection matrix to best fit (including all the casters)
  101101. * on each frame.
  101102. */
  101103. autoUpdateExtends: boolean;
  101104. private _orthoLeft;
  101105. private _orthoRight;
  101106. private _orthoTop;
  101107. private _orthoBottom;
  101108. /**
  101109. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101110. * The directional light is emitted from everywhere in the given direction.
  101111. * It can cast shadows.
  101112. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101113. * @param name The friendly name of the light
  101114. * @param direction The direction of the light
  101115. * @param scene The scene the light belongs to
  101116. */
  101117. constructor(name: string, direction: Vector3, scene: Scene);
  101118. /**
  101119. * Returns the string "DirectionalLight".
  101120. * @return The class name
  101121. */
  101122. getClassName(): string;
  101123. /**
  101124. * Returns the integer 1.
  101125. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101126. */
  101127. getTypeID(): number;
  101128. /**
  101129. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101130. * Returns the DirectionalLight Shadow projection matrix.
  101131. */
  101132. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101133. /**
  101134. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101135. * Returns the DirectionalLight Shadow projection matrix.
  101136. */
  101137. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101138. /**
  101139. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101140. * Returns the DirectionalLight Shadow projection matrix.
  101141. */
  101142. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101143. protected _buildUniformLayout(): void;
  101144. /**
  101145. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101146. * @param effect The effect to update
  101147. * @param lightIndex The index of the light in the effect to update
  101148. * @returns The directional light
  101149. */
  101150. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101151. /**
  101152. * Gets the minZ used for shadow according to both the scene and the light.
  101153. *
  101154. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101155. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101156. * @param activeCamera The camera we are returning the min for
  101157. * @returns the depth min z
  101158. */
  101159. getDepthMinZ(activeCamera: Camera): number;
  101160. /**
  101161. * Gets the maxZ used for shadow according to both the scene and the light.
  101162. *
  101163. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101164. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101165. * @param activeCamera The camera we are returning the max for
  101166. * @returns the depth max z
  101167. */
  101168. getDepthMaxZ(activeCamera: Camera): number;
  101169. /**
  101170. * Prepares the list of defines specific to the light type.
  101171. * @param defines the list of defines
  101172. * @param lightIndex defines the index of the light for the effect
  101173. */
  101174. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101175. }
  101176. }
  101177. declare module BABYLON {
  101178. /**
  101179. * A point light is a light defined by an unique point in world space.
  101180. * The light is emitted in every direction from this point.
  101181. * A good example of a point light is a standard light bulb.
  101182. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101183. */
  101184. export class PointLight extends ShadowLight {
  101185. private _shadowAngle;
  101186. /**
  101187. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101188. * This specifies what angle the shadow will use to be created.
  101189. *
  101190. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101191. */
  101192. /**
  101193. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101194. * This specifies what angle the shadow will use to be created.
  101195. *
  101196. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101197. */
  101198. shadowAngle: number;
  101199. /**
  101200. * Gets the direction if it has been set.
  101201. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101202. */
  101203. /**
  101204. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101205. */
  101206. direction: Vector3;
  101207. /**
  101208. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101209. * A PointLight emits the light in every direction.
  101210. * It can cast shadows.
  101211. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101212. * ```javascript
  101213. * var pointLight = new PointLight("pl", camera.position, scene);
  101214. * ```
  101215. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101216. * @param name The light friendly name
  101217. * @param position The position of the point light in the scene
  101218. * @param scene The scene the lights belongs to
  101219. */
  101220. constructor(name: string, position: Vector3, scene: Scene);
  101221. /**
  101222. * Returns the string "PointLight"
  101223. * @returns the class name
  101224. */
  101225. getClassName(): string;
  101226. /**
  101227. * Returns the integer 0.
  101228. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101229. */
  101230. getTypeID(): number;
  101231. /**
  101232. * Specifies wether or not the shadowmap should be a cube texture.
  101233. * @returns true if the shadowmap needs to be a cube texture.
  101234. */
  101235. needCube(): boolean;
  101236. /**
  101237. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101238. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101239. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101240. */
  101241. getShadowDirection(faceIndex?: number): Vector3;
  101242. /**
  101243. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101244. * - fov = PI / 2
  101245. * - aspect ratio : 1.0
  101246. * - z-near and far equal to the active camera minZ and maxZ.
  101247. * Returns the PointLight.
  101248. */
  101249. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101250. protected _buildUniformLayout(): void;
  101251. /**
  101252. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101253. * @param effect The effect to update
  101254. * @param lightIndex The index of the light in the effect to update
  101255. * @returns The point light
  101256. */
  101257. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101258. /**
  101259. * Prepares the list of defines specific to the light type.
  101260. * @param defines the list of defines
  101261. * @param lightIndex defines the index of the light for the effect
  101262. */
  101263. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101264. }
  101265. }
  101266. declare module BABYLON {
  101267. /**
  101268. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101269. * These values define a cone of light starting from the position, emitting toward the direction.
  101270. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101271. * and the exponent defines the speed of the decay of the light with distance (reach).
  101272. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101273. */
  101274. export class SpotLight extends ShadowLight {
  101275. private _angle;
  101276. private _innerAngle;
  101277. private _cosHalfAngle;
  101278. private _lightAngleScale;
  101279. private _lightAngleOffset;
  101280. /**
  101281. * Gets the cone angle of the spot light in Radians.
  101282. */
  101283. /**
  101284. * Sets the cone angle of the spot light in Radians.
  101285. */
  101286. angle: number;
  101287. /**
  101288. * Only used in gltf falloff mode, this defines the angle where
  101289. * the directional falloff will start before cutting at angle which could be seen
  101290. * as outer angle.
  101291. */
  101292. /**
  101293. * Only used in gltf falloff mode, this defines the angle where
  101294. * the directional falloff will start before cutting at angle which could be seen
  101295. * as outer angle.
  101296. */
  101297. innerAngle: number;
  101298. private _shadowAngleScale;
  101299. /**
  101300. * Allows scaling the angle of the light for shadow generation only.
  101301. */
  101302. /**
  101303. * Allows scaling the angle of the light for shadow generation only.
  101304. */
  101305. shadowAngleScale: number;
  101306. /**
  101307. * The light decay speed with the distance from the emission spot.
  101308. */
  101309. exponent: number;
  101310. private _projectionTextureMatrix;
  101311. /**
  101312. * Allows reading the projecton texture
  101313. */
  101314. readonly projectionTextureMatrix: Matrix;
  101315. protected _projectionTextureLightNear: number;
  101316. /**
  101317. * Gets the near clip of the Spotlight for texture projection.
  101318. */
  101319. /**
  101320. * Sets the near clip of the Spotlight for texture projection.
  101321. */
  101322. projectionTextureLightNear: number;
  101323. protected _projectionTextureLightFar: number;
  101324. /**
  101325. * Gets the far clip of the Spotlight for texture projection.
  101326. */
  101327. /**
  101328. * Sets the far clip of the Spotlight for texture projection.
  101329. */
  101330. projectionTextureLightFar: number;
  101331. protected _projectionTextureUpDirection: Vector3;
  101332. /**
  101333. * Gets the Up vector of the Spotlight for texture projection.
  101334. */
  101335. /**
  101336. * Sets the Up vector of the Spotlight for texture projection.
  101337. */
  101338. projectionTextureUpDirection: Vector3;
  101339. private _projectionTexture;
  101340. /**
  101341. * Gets the projection texture of the light.
  101342. */
  101343. /**
  101344. * Sets the projection texture of the light.
  101345. */
  101346. projectionTexture: Nullable<BaseTexture>;
  101347. private _projectionTextureViewLightDirty;
  101348. private _projectionTextureProjectionLightDirty;
  101349. private _projectionTextureDirty;
  101350. private _projectionTextureViewTargetVector;
  101351. private _projectionTextureViewLightMatrix;
  101352. private _projectionTextureProjectionLightMatrix;
  101353. private _projectionTextureScalingMatrix;
  101354. /**
  101355. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101356. * It can cast shadows.
  101357. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101358. * @param name The light friendly name
  101359. * @param position The position of the spot light in the scene
  101360. * @param direction The direction of the light in the scene
  101361. * @param angle The cone angle of the light in Radians
  101362. * @param exponent The light decay speed with the distance from the emission spot
  101363. * @param scene The scene the lights belongs to
  101364. */
  101365. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101366. /**
  101367. * Returns the string "SpotLight".
  101368. * @returns the class name
  101369. */
  101370. getClassName(): string;
  101371. /**
  101372. * Returns the integer 2.
  101373. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101374. */
  101375. getTypeID(): number;
  101376. /**
  101377. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101378. */
  101379. protected _setDirection(value: Vector3): void;
  101380. /**
  101381. * Overrides the position setter to recompute the projection texture view light Matrix.
  101382. */
  101383. protected _setPosition(value: Vector3): void;
  101384. /**
  101385. * 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.
  101386. * Returns the SpotLight.
  101387. */
  101388. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101389. protected _computeProjectionTextureViewLightMatrix(): void;
  101390. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101391. /**
  101392. * Main function for light texture projection matrix computing.
  101393. */
  101394. protected _computeProjectionTextureMatrix(): void;
  101395. protected _buildUniformLayout(): void;
  101396. private _computeAngleValues;
  101397. /**
  101398. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101399. * @param effect The effect to update
  101400. * @param lightIndex The index of the light in the effect to update
  101401. * @returns The spot light
  101402. */
  101403. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101404. /**
  101405. * Disposes the light and the associated resources.
  101406. */
  101407. dispose(): void;
  101408. /**
  101409. * Prepares the list of defines specific to the light type.
  101410. * @param defines the list of defines
  101411. * @param lightIndex defines the index of the light for the effect
  101412. */
  101413. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101414. }
  101415. }
  101416. declare module BABYLON {
  101417. /**
  101418. * Header information of HDR texture files.
  101419. */
  101420. export interface HDRInfo {
  101421. /**
  101422. * The height of the texture in pixels.
  101423. */
  101424. height: number;
  101425. /**
  101426. * The width of the texture in pixels.
  101427. */
  101428. width: number;
  101429. /**
  101430. * The index of the beginning of the data in the binary file.
  101431. */
  101432. dataPosition: number;
  101433. }
  101434. /**
  101435. * This groups tools to convert HDR texture to native colors array.
  101436. */
  101437. export class HDRTools {
  101438. private static Ldexp;
  101439. private static Rgbe2float;
  101440. private static readStringLine;
  101441. /**
  101442. * Reads header information from an RGBE texture stored in a native array.
  101443. * More information on this format are available here:
  101444. * https://en.wikipedia.org/wiki/RGBE_image_format
  101445. *
  101446. * @param uint8array The binary file stored in native array.
  101447. * @return The header information.
  101448. */
  101449. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101450. /**
  101451. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101452. * This RGBE texture needs to store the information as a panorama.
  101453. *
  101454. * More information on this format are available here:
  101455. * https://en.wikipedia.org/wiki/RGBE_image_format
  101456. *
  101457. * @param buffer The binary file stored in an array buffer.
  101458. * @param size The expected size of the extracted cubemap.
  101459. * @return The Cube Map information.
  101460. */
  101461. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101462. /**
  101463. * Returns the pixels data extracted from an RGBE texture.
  101464. * This pixels will be stored left to right up to down in the R G B order in one array.
  101465. *
  101466. * More information on this format are available here:
  101467. * https://en.wikipedia.org/wiki/RGBE_image_format
  101468. *
  101469. * @param uint8array The binary file stored in an array buffer.
  101470. * @param hdrInfo The header information of the file.
  101471. * @return The pixels data in RGB right to left up to down order.
  101472. */
  101473. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101474. private static RGBE_ReadPixels_RLE;
  101475. }
  101476. }
  101477. declare module BABYLON {
  101478. /**
  101479. * This represents a texture coming from an HDR input.
  101480. *
  101481. * The only supported format is currently panorama picture stored in RGBE format.
  101482. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101483. */
  101484. export class HDRCubeTexture extends BaseTexture {
  101485. private static _facesMapping;
  101486. private _generateHarmonics;
  101487. private _noMipmap;
  101488. private _textureMatrix;
  101489. private _size;
  101490. private _onLoad;
  101491. private _onError;
  101492. /**
  101493. * The texture URL.
  101494. */
  101495. url: string;
  101496. /**
  101497. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101498. */
  101499. coordinatesMode: number;
  101500. protected _isBlocking: boolean;
  101501. /**
  101502. * Sets wether or not the texture is blocking during loading.
  101503. */
  101504. /**
  101505. * Gets wether or not the texture is blocking during loading.
  101506. */
  101507. isBlocking: boolean;
  101508. protected _rotationY: number;
  101509. /**
  101510. * Sets texture matrix rotation angle around Y axis in radians.
  101511. */
  101512. /**
  101513. * Gets texture matrix rotation angle around Y axis radians.
  101514. */
  101515. rotationY: number;
  101516. /**
  101517. * Gets or sets the center of the bounding box associated with the cube texture
  101518. * It must define where the camera used to render the texture was set
  101519. */
  101520. boundingBoxPosition: Vector3;
  101521. private _boundingBoxSize;
  101522. /**
  101523. * Gets or sets the size of the bounding box associated with the cube texture
  101524. * When defined, the cubemap will switch to local mode
  101525. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101526. * @example https://www.babylonjs-playground.com/#RNASML
  101527. */
  101528. boundingBoxSize: Vector3;
  101529. /**
  101530. * Instantiates an HDRTexture from the following parameters.
  101531. *
  101532. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101533. * @param scene The scene the texture will be used in
  101534. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101535. * @param noMipmap Forces to not generate the mipmap if true
  101536. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101537. * @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)
  101538. * @param reserved Reserved flag for internal use.
  101539. */
  101540. 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>);
  101541. /**
  101542. * Get the current class name of the texture useful for serialization or dynamic coding.
  101543. * @returns "HDRCubeTexture"
  101544. */
  101545. getClassName(): string;
  101546. /**
  101547. * Occurs when the file is raw .hdr file.
  101548. */
  101549. private loadTexture;
  101550. clone(): HDRCubeTexture;
  101551. delayLoad(): void;
  101552. /**
  101553. * Get the texture reflection matrix used to rotate/transform the reflection.
  101554. * @returns the reflection matrix
  101555. */
  101556. getReflectionTextureMatrix(): Matrix;
  101557. /**
  101558. * Set the texture reflection matrix used to rotate/transform the reflection.
  101559. * @param value Define the reflection matrix to set
  101560. */
  101561. setReflectionTextureMatrix(value: Matrix): void;
  101562. /**
  101563. * Parses a JSON representation of an HDR Texture in order to create the texture
  101564. * @param parsedTexture Define the JSON representation
  101565. * @param scene Define the scene the texture should be created in
  101566. * @param rootUrl Define the root url in case we need to load relative dependencies
  101567. * @returns the newly created texture after parsing
  101568. */
  101569. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101570. serialize(): any;
  101571. }
  101572. }
  101573. declare module BABYLON {
  101574. /**
  101575. * Class used to control physics engine
  101576. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101577. */
  101578. export class PhysicsEngine implements IPhysicsEngine {
  101579. private _physicsPlugin;
  101580. /**
  101581. * Global value used to control the smallest number supported by the simulation
  101582. */
  101583. static Epsilon: number;
  101584. private _impostors;
  101585. private _joints;
  101586. /**
  101587. * Gets the gravity vector used by the simulation
  101588. */
  101589. gravity: Vector3;
  101590. /**
  101591. * Factory used to create the default physics plugin.
  101592. * @returns The default physics plugin
  101593. */
  101594. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101595. /**
  101596. * Creates a new Physics Engine
  101597. * @param gravity defines the gravity vector used by the simulation
  101598. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101599. */
  101600. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101601. /**
  101602. * Sets the gravity vector used by the simulation
  101603. * @param gravity defines the gravity vector to use
  101604. */
  101605. setGravity(gravity: Vector3): void;
  101606. /**
  101607. * Set the time step of the physics engine.
  101608. * Default is 1/60.
  101609. * To slow it down, enter 1/600 for example.
  101610. * To speed it up, 1/30
  101611. * @param newTimeStep defines the new timestep to apply to this world.
  101612. */
  101613. setTimeStep(newTimeStep?: number): void;
  101614. /**
  101615. * Get the time step of the physics engine.
  101616. * @returns the current time step
  101617. */
  101618. getTimeStep(): number;
  101619. /**
  101620. * Release all resources
  101621. */
  101622. dispose(): void;
  101623. /**
  101624. * Gets the name of the current physics plugin
  101625. * @returns the name of the plugin
  101626. */
  101627. getPhysicsPluginName(): string;
  101628. /**
  101629. * Adding a new impostor for the impostor tracking.
  101630. * This will be done by the impostor itself.
  101631. * @param impostor the impostor to add
  101632. */
  101633. addImpostor(impostor: PhysicsImpostor): void;
  101634. /**
  101635. * Remove an impostor from the engine.
  101636. * This impostor and its mesh will not longer be updated by the physics engine.
  101637. * @param impostor the impostor to remove
  101638. */
  101639. removeImpostor(impostor: PhysicsImpostor): void;
  101640. /**
  101641. * Add a joint to the physics engine
  101642. * @param mainImpostor defines the main impostor to which the joint is added.
  101643. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101644. * @param joint defines the joint that will connect both impostors.
  101645. */
  101646. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101647. /**
  101648. * Removes a joint from the simulation
  101649. * @param mainImpostor defines the impostor used with the joint
  101650. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101651. * @param joint defines the joint to remove
  101652. */
  101653. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101654. /**
  101655. * Called by the scene. No need to call it.
  101656. * @param delta defines the timespam between frames
  101657. */
  101658. _step(delta: number): void;
  101659. /**
  101660. * Gets the current plugin used to run the simulation
  101661. * @returns current plugin
  101662. */
  101663. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101664. /**
  101665. * Gets the list of physic impostors
  101666. * @returns an array of PhysicsImpostor
  101667. */
  101668. getImpostors(): Array<PhysicsImpostor>;
  101669. /**
  101670. * Gets the impostor for a physics enabled object
  101671. * @param object defines the object impersonated by the impostor
  101672. * @returns the PhysicsImpostor or null if not found
  101673. */
  101674. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101675. /**
  101676. * Gets the impostor for a physics body object
  101677. * @param body defines physics body used by the impostor
  101678. * @returns the PhysicsImpostor or null if not found
  101679. */
  101680. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101681. }
  101682. }
  101683. declare module BABYLON {
  101684. /** @hidden */
  101685. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101686. private _useDeltaForWorldStep;
  101687. world: any;
  101688. name: string;
  101689. private _physicsMaterials;
  101690. private _fixedTimeStep;
  101691. BJSCANNON: any;
  101692. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101693. setGravity(gravity: Vector3): void;
  101694. setTimeStep(timeStep: number): void;
  101695. getTimeStep(): number;
  101696. executeStep(delta: number): void;
  101697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101700. private _processChildMeshes;
  101701. removePhysicsBody(impostor: PhysicsImpostor): void;
  101702. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101703. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101704. private _addMaterial;
  101705. private _checkWithEpsilon;
  101706. private _createShape;
  101707. private _createHeightmap;
  101708. private _minus90X;
  101709. private _plus90X;
  101710. private _tmpPosition;
  101711. private _tmpDeltaPosition;
  101712. private _tmpUnityRotation;
  101713. private _updatePhysicsBodyTransformation;
  101714. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101715. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101716. isSupported(): boolean;
  101717. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101718. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101722. getBodyMass(impostor: PhysicsImpostor): number;
  101723. getBodyFriction(impostor: PhysicsImpostor): number;
  101724. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101725. getBodyRestitution(impostor: PhysicsImpostor): number;
  101726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101727. sleepBody(impostor: PhysicsImpostor): void;
  101728. wakeUpBody(impostor: PhysicsImpostor): void;
  101729. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101730. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101733. getRadius(impostor: PhysicsImpostor): number;
  101734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101735. dispose(): void;
  101736. private _extendNamespace;
  101737. }
  101738. }
  101739. declare module BABYLON {
  101740. /** @hidden */
  101741. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101742. world: any;
  101743. name: string;
  101744. BJSOIMO: any;
  101745. constructor(iterations?: number, oimoInjection?: any);
  101746. setGravity(gravity: Vector3): void;
  101747. setTimeStep(timeStep: number): void;
  101748. getTimeStep(): number;
  101749. private _tmpImpostorsArray;
  101750. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101751. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101752. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101753. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101754. private _tmpPositionVector;
  101755. removePhysicsBody(impostor: PhysicsImpostor): void;
  101756. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101757. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101758. isSupported(): boolean;
  101759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101760. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101763. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101764. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101766. getBodyMass(impostor: PhysicsImpostor): number;
  101767. getBodyFriction(impostor: PhysicsImpostor): number;
  101768. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101769. getBodyRestitution(impostor: PhysicsImpostor): number;
  101770. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101771. sleepBody(impostor: PhysicsImpostor): void;
  101772. wakeUpBody(impostor: PhysicsImpostor): void;
  101773. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101774. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101775. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101776. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101777. getRadius(impostor: PhysicsImpostor): number;
  101778. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101779. dispose(): void;
  101780. }
  101781. }
  101782. declare module BABYLON {
  101783. interface AbstractScene {
  101784. /**
  101785. * The list of reflection probes added to the scene
  101786. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101787. */
  101788. reflectionProbes: Array<ReflectionProbe>;
  101789. /**
  101790. * Removes the given reflection probe from this scene.
  101791. * @param toRemove The reflection probe to remove
  101792. * @returns The index of the removed reflection probe
  101793. */
  101794. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101795. /**
  101796. * Adds the given reflection probe to this scene.
  101797. * @param newReflectionProbe The reflection probe to add
  101798. */
  101799. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101800. }
  101801. /**
  101802. * Class used to generate realtime reflection / refraction cube textures
  101803. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101804. */
  101805. export class ReflectionProbe {
  101806. /** defines the name of the probe */
  101807. name: string;
  101808. private _scene;
  101809. private _renderTargetTexture;
  101810. private _projectionMatrix;
  101811. private _viewMatrix;
  101812. private _target;
  101813. private _add;
  101814. private _attachedMesh;
  101815. private _invertYAxis;
  101816. /** Gets or sets probe position (center of the cube map) */
  101817. position: Vector3;
  101818. /**
  101819. * Creates a new reflection probe
  101820. * @param name defines the name of the probe
  101821. * @param size defines the texture resolution (for each face)
  101822. * @param scene defines the hosting scene
  101823. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101824. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101825. */
  101826. constructor(
  101827. /** defines the name of the probe */
  101828. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101829. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101830. samples: number;
  101831. /** Gets or sets the refresh rate to use (on every frame by default) */
  101832. refreshRate: number;
  101833. /**
  101834. * Gets the hosting scene
  101835. * @returns a Scene
  101836. */
  101837. getScene(): Scene;
  101838. /** Gets the internal CubeTexture used to render to */
  101839. readonly cubeTexture: RenderTargetTexture;
  101840. /** Gets the list of meshes to render */
  101841. readonly renderList: Nullable<AbstractMesh[]>;
  101842. /**
  101843. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101844. * @param mesh defines the mesh to attach to
  101845. */
  101846. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101847. /**
  101848. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101849. * @param renderingGroupId The rendering group id corresponding to its index
  101850. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101851. */
  101852. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101853. /**
  101854. * Clean all associated resources
  101855. */
  101856. dispose(): void;
  101857. /**
  101858. * Converts the reflection probe information to a readable string for debug purpose.
  101859. * @param fullDetails Supports for multiple levels of logging within scene loading
  101860. * @returns the human readable reflection probe info
  101861. */
  101862. toString(fullDetails?: boolean): string;
  101863. /**
  101864. * Get the class name of the relfection probe.
  101865. * @returns "ReflectionProbe"
  101866. */
  101867. getClassName(): string;
  101868. /**
  101869. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101870. * @returns The JSON representation of the texture
  101871. */
  101872. serialize(): any;
  101873. /**
  101874. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101875. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101876. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101877. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101878. * @returns The parsed reflection probe if successful
  101879. */
  101880. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101881. }
  101882. }
  101883. declare module BABYLON {
  101884. /** @hidden */
  101885. export var _BabylonLoaderRegistered: boolean;
  101886. }
  101887. declare module BABYLON {
  101888. /**
  101889. * The Physically based simple base material of BJS.
  101890. *
  101891. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101892. * It is used as the base class for both the specGloss and metalRough conventions.
  101893. */
  101894. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101895. /**
  101896. * Number of Simultaneous lights allowed on the material.
  101897. */
  101898. maxSimultaneousLights: number;
  101899. /**
  101900. * If sets to true, disables all the lights affecting the material.
  101901. */
  101902. disableLighting: boolean;
  101903. /**
  101904. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  101905. */
  101906. environmentTexture: BaseTexture;
  101907. /**
  101908. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101909. */
  101910. invertNormalMapX: boolean;
  101911. /**
  101912. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101913. */
  101914. invertNormalMapY: boolean;
  101915. /**
  101916. * Normal map used in the model.
  101917. */
  101918. normalTexture: BaseTexture;
  101919. /**
  101920. * Emissivie color used to self-illuminate the model.
  101921. */
  101922. emissiveColor: Color3;
  101923. /**
  101924. * Emissivie texture used to self-illuminate the model.
  101925. */
  101926. emissiveTexture: BaseTexture;
  101927. /**
  101928. * Occlusion Channel Strenght.
  101929. */
  101930. occlusionStrength: number;
  101931. /**
  101932. * Occlusion Texture of the material (adding extra occlusion effects).
  101933. */
  101934. occlusionTexture: BaseTexture;
  101935. /**
  101936. * Defines the alpha limits in alpha test mode.
  101937. */
  101938. alphaCutOff: number;
  101939. /**
  101940. * Gets the current double sided mode.
  101941. */
  101942. /**
  101943. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101944. */
  101945. doubleSided: boolean;
  101946. /**
  101947. * Stores the pre-calculated light information of a mesh in a texture.
  101948. */
  101949. lightmapTexture: BaseTexture;
  101950. /**
  101951. * If true, the light map contains occlusion information instead of lighting info.
  101952. */
  101953. useLightmapAsShadowmap: boolean;
  101954. /**
  101955. * Return the active textures of the material.
  101956. */
  101957. getActiveTextures(): BaseTexture[];
  101958. hasTexture(texture: BaseTexture): boolean;
  101959. /**
  101960. * Instantiates a new PBRMaterial instance.
  101961. *
  101962. * @param name The material name
  101963. * @param scene The scene the material will be use in.
  101964. */
  101965. constructor(name: string, scene: Scene);
  101966. getClassName(): string;
  101967. }
  101968. }
  101969. declare module BABYLON {
  101970. /**
  101971. * The PBR material of BJS following the metal roughness convention.
  101972. *
  101973. * This fits to the PBR convention in the GLTF definition:
  101974. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  101975. */
  101976. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  101977. /**
  101978. * The base color has two different interpretations depending on the value of metalness.
  101979. * When the material is a metal, the base color is the specific measured reflectance value
  101980. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  101981. * of the material.
  101982. */
  101983. baseColor: Color3;
  101984. /**
  101985. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  101986. * well as opacity information in the alpha channel.
  101987. */
  101988. baseTexture: BaseTexture;
  101989. /**
  101990. * Specifies the metallic scalar value of the material.
  101991. * Can also be used to scale the metalness values of the metallic texture.
  101992. */
  101993. metallic: number;
  101994. /**
  101995. * Specifies the roughness scalar value of the material.
  101996. * Can also be used to scale the roughness values of the metallic texture.
  101997. */
  101998. roughness: number;
  101999. /**
  102000. * Texture containing both the metallic value in the B channel and the
  102001. * roughness value in the G channel to keep better precision.
  102002. */
  102003. metallicRoughnessTexture: BaseTexture;
  102004. /**
  102005. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102006. *
  102007. * @param name The material name
  102008. * @param scene The scene the material will be use in.
  102009. */
  102010. constructor(name: string, scene: Scene);
  102011. /**
  102012. * Return the currrent class name of the material.
  102013. */
  102014. getClassName(): string;
  102015. /**
  102016. * Return the active textures of the material.
  102017. */
  102018. getActiveTextures(): BaseTexture[];
  102019. /**
  102020. * Checks to see if a texture is used in the material.
  102021. * @param texture - Base texture to use.
  102022. * @returns - Boolean specifying if a texture is used in the material.
  102023. */
  102024. hasTexture(texture: BaseTexture): boolean;
  102025. /**
  102026. * Makes a duplicate of the current material.
  102027. * @param name - name to use for the new material.
  102028. */
  102029. clone(name: string): PBRMetallicRoughnessMaterial;
  102030. /**
  102031. * Serialize the material to a parsable JSON object.
  102032. */
  102033. serialize(): any;
  102034. /**
  102035. * Parses a JSON object correponding to the serialize function.
  102036. */
  102037. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102038. }
  102039. }
  102040. declare module BABYLON {
  102041. /**
  102042. * The PBR material of BJS following the specular glossiness convention.
  102043. *
  102044. * This fits to the PBR convention in the GLTF definition:
  102045. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102046. */
  102047. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102048. /**
  102049. * Specifies the diffuse color of the material.
  102050. */
  102051. diffuseColor: Color3;
  102052. /**
  102053. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102054. * channel.
  102055. */
  102056. diffuseTexture: BaseTexture;
  102057. /**
  102058. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102059. */
  102060. specularColor: Color3;
  102061. /**
  102062. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102063. */
  102064. glossiness: number;
  102065. /**
  102066. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102067. */
  102068. specularGlossinessTexture: BaseTexture;
  102069. /**
  102070. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102071. *
  102072. * @param name The material name
  102073. * @param scene The scene the material will be use in.
  102074. */
  102075. constructor(name: string, scene: Scene);
  102076. /**
  102077. * Return the currrent class name of the material.
  102078. */
  102079. getClassName(): string;
  102080. /**
  102081. * Return the active textures of the material.
  102082. */
  102083. getActiveTextures(): BaseTexture[];
  102084. /**
  102085. * Checks to see if a texture is used in the material.
  102086. * @param texture - Base texture to use.
  102087. * @returns - Boolean specifying if a texture is used in the material.
  102088. */
  102089. hasTexture(texture: BaseTexture): boolean;
  102090. /**
  102091. * Makes a duplicate of the current material.
  102092. * @param name - name to use for the new material.
  102093. */
  102094. clone(name: string): PBRSpecularGlossinessMaterial;
  102095. /**
  102096. * Serialize the material to a parsable JSON object.
  102097. */
  102098. serialize(): any;
  102099. /**
  102100. * Parses a JSON object correponding to the serialize function.
  102101. */
  102102. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102103. }
  102104. }
  102105. declare module BABYLON {
  102106. /**
  102107. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102108. * It can help converting any input color in a desired output one. This can then be used to create effects
  102109. * from sepia, black and white to sixties or futuristic rendering...
  102110. *
  102111. * The only supported format is currently 3dl.
  102112. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102113. */
  102114. export class ColorGradingTexture extends BaseTexture {
  102115. /**
  102116. * The current texture matrix. (will always be identity in color grading texture)
  102117. */
  102118. private _textureMatrix;
  102119. /**
  102120. * The texture URL.
  102121. */
  102122. url: string;
  102123. /**
  102124. * Empty line regex stored for GC.
  102125. */
  102126. private static _noneEmptyLineRegex;
  102127. private _engine;
  102128. /**
  102129. * Instantiates a ColorGradingTexture from the following parameters.
  102130. *
  102131. * @param url The location of the color gradind data (currently only supporting 3dl)
  102132. * @param scene The scene the texture will be used in
  102133. */
  102134. constructor(url: string, scene: Scene);
  102135. /**
  102136. * Returns the texture matrix used in most of the material.
  102137. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102138. */
  102139. getTextureMatrix(): Matrix;
  102140. /**
  102141. * Occurs when the file being loaded is a .3dl LUT file.
  102142. */
  102143. private load3dlTexture;
  102144. /**
  102145. * Starts the loading process of the texture.
  102146. */
  102147. private loadTexture;
  102148. /**
  102149. * Clones the color gradind texture.
  102150. */
  102151. clone(): ColorGradingTexture;
  102152. /**
  102153. * Called during delayed load for textures.
  102154. */
  102155. delayLoad(): void;
  102156. /**
  102157. * Parses a color grading texture serialized by Babylon.
  102158. * @param parsedTexture The texture information being parsedTexture
  102159. * @param scene The scene to load the texture in
  102160. * @param rootUrl The root url of the data assets to load
  102161. * @return A color gradind texture
  102162. */
  102163. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102164. /**
  102165. * Serializes the LUT texture to json format.
  102166. */
  102167. serialize(): any;
  102168. }
  102169. }
  102170. declare module BABYLON {
  102171. /**
  102172. * Direct draw surface info
  102173. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102174. */
  102175. export interface DDSInfo {
  102176. /**
  102177. * Width of the texture
  102178. */
  102179. width: number;
  102180. /**
  102181. * Width of the texture
  102182. */
  102183. height: number;
  102184. /**
  102185. * Number of Mipmaps for the texture
  102186. * @see https://en.wikipedia.org/wiki/Mipmap
  102187. */
  102188. mipmapCount: number;
  102189. /**
  102190. * If the textures format is a known fourCC format
  102191. * @see https://www.fourcc.org/
  102192. */
  102193. isFourCC: boolean;
  102194. /**
  102195. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102196. */
  102197. isRGB: boolean;
  102198. /**
  102199. * If the texture is a lumincance format
  102200. */
  102201. isLuminance: boolean;
  102202. /**
  102203. * If this is a cube texture
  102204. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102205. */
  102206. isCube: boolean;
  102207. /**
  102208. * If the texture is a compressed format eg. FOURCC_DXT1
  102209. */
  102210. isCompressed: boolean;
  102211. /**
  102212. * The dxgiFormat of the texture
  102213. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102214. */
  102215. dxgiFormat: number;
  102216. /**
  102217. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102218. */
  102219. textureType: number;
  102220. /**
  102221. * Sphericle polynomial created for the dds texture
  102222. */
  102223. sphericalPolynomial?: SphericalPolynomial;
  102224. }
  102225. /**
  102226. * Class used to provide DDS decompression tools
  102227. */
  102228. export class DDSTools {
  102229. /**
  102230. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102231. */
  102232. static StoreLODInAlphaChannel: boolean;
  102233. /**
  102234. * Gets DDS information from an array buffer
  102235. * @param arrayBuffer defines the array buffer to read data from
  102236. * @returns the DDS information
  102237. */
  102238. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102239. private static _FloatView;
  102240. private static _Int32View;
  102241. private static _ToHalfFloat;
  102242. private static _FromHalfFloat;
  102243. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102244. private static _GetHalfFloatRGBAArrayBuffer;
  102245. private static _GetFloatRGBAArrayBuffer;
  102246. private static _GetFloatAsUIntRGBAArrayBuffer;
  102247. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102248. private static _GetRGBAArrayBuffer;
  102249. private static _ExtractLongWordOrder;
  102250. private static _GetRGBArrayBuffer;
  102251. private static _GetLuminanceArrayBuffer;
  102252. /**
  102253. * Uploads DDS Levels to a Babylon Texture
  102254. * @hidden
  102255. */
  102256. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102257. }
  102258. interface Engine {
  102259. /**
  102260. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102261. * @param rootUrl defines the url where the file to load is located
  102262. * @param scene defines the current scene
  102263. * @param lodScale defines scale to apply to the mip map selection
  102264. * @param lodOffset defines offset to apply to the mip map selection
  102265. * @param onLoad defines an optional callback raised when the texture is loaded
  102266. * @param onError defines an optional callback raised if there is an issue to load the texture
  102267. * @param format defines the format of the data
  102268. * @param forcedExtension defines the extension to use to pick the right loader
  102269. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102270. * @returns the cube texture as an InternalTexture
  102271. */
  102272. 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;
  102273. }
  102274. }
  102275. declare module BABYLON {
  102276. /**
  102277. * Implementation of the DDS Texture Loader.
  102278. * @hidden
  102279. */
  102280. export class _DDSTextureLoader implements IInternalTextureLoader {
  102281. /**
  102282. * Defines wether the loader supports cascade loading the different faces.
  102283. */
  102284. readonly supportCascades: boolean;
  102285. /**
  102286. * This returns if the loader support the current file information.
  102287. * @param extension defines the file extension of the file being loaded
  102288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102289. * @param fallback defines the fallback internal texture if any
  102290. * @param isBase64 defines whether the texture is encoded as a base64
  102291. * @param isBuffer defines whether the texture data are stored as a buffer
  102292. * @returns true if the loader can load the specified file
  102293. */
  102294. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102295. /**
  102296. * Transform the url before loading if required.
  102297. * @param rootUrl the url of the texture
  102298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102299. * @returns the transformed texture
  102300. */
  102301. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102302. /**
  102303. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102304. * @param rootUrl the url of the texture
  102305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102306. * @returns the fallback texture
  102307. */
  102308. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102309. /**
  102310. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102311. * @param data contains the texture data
  102312. * @param texture defines the BabylonJS internal texture
  102313. * @param createPolynomials will be true if polynomials have been requested
  102314. * @param onLoad defines the callback to trigger once the texture is ready
  102315. * @param onError defines the callback to trigger in case of error
  102316. */
  102317. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102318. /**
  102319. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102320. * @param data contains the texture data
  102321. * @param texture defines the BabylonJS internal texture
  102322. * @param callback defines the method to call once ready to upload
  102323. */
  102324. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102325. }
  102326. }
  102327. declare module BABYLON {
  102328. /** @hidden */
  102329. export var rgbdEncodePixelShader: {
  102330. name: string;
  102331. shader: string;
  102332. };
  102333. }
  102334. declare module BABYLON {
  102335. /** @hidden */
  102336. export var rgbdDecodePixelShader: {
  102337. name: string;
  102338. shader: string;
  102339. };
  102340. }
  102341. declare module BABYLON {
  102342. /**
  102343. * Raw texture data and descriptor sufficient for WebGL texture upload
  102344. */
  102345. export interface EnvironmentTextureInfo {
  102346. /**
  102347. * Version of the environment map
  102348. */
  102349. version: number;
  102350. /**
  102351. * Width of image
  102352. */
  102353. width: number;
  102354. /**
  102355. * Irradiance information stored in the file.
  102356. */
  102357. irradiance: any;
  102358. /**
  102359. * Specular information stored in the file.
  102360. */
  102361. specular: any;
  102362. }
  102363. /**
  102364. * Sets of helpers addressing the serialization and deserialization of environment texture
  102365. * stored in a BabylonJS env file.
  102366. * Those files are usually stored as .env files.
  102367. */
  102368. export class EnvironmentTextureTools {
  102369. /**
  102370. * Magic number identifying the env file.
  102371. */
  102372. private static _MagicBytes;
  102373. /**
  102374. * Gets the environment info from an env file.
  102375. * @param data The array buffer containing the .env bytes.
  102376. * @returns the environment file info (the json header) if successfully parsed.
  102377. */
  102378. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102379. /**
  102380. * Creates an environment texture from a loaded cube texture.
  102381. * @param texture defines the cube texture to convert in env file
  102382. * @return a promise containing the environment data if succesfull.
  102383. */
  102384. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102385. /**
  102386. * Creates a JSON representation of the spherical data.
  102387. * @param texture defines the texture containing the polynomials
  102388. * @return the JSON representation of the spherical info
  102389. */
  102390. private static _CreateEnvTextureIrradiance;
  102391. /**
  102392. * Uploads the texture info contained in the env file to the GPU.
  102393. * @param texture defines the internal texture to upload to
  102394. * @param arrayBuffer defines the buffer cotaining the data to load
  102395. * @param info defines the texture info retrieved through the GetEnvInfo method
  102396. * @returns a promise
  102397. */
  102398. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102399. /**
  102400. * Uploads the levels of image data to the GPU.
  102401. * @param texture defines the internal texture to upload to
  102402. * @param imageData defines the array buffer views of image data [mipmap][face]
  102403. * @returns a promise
  102404. */
  102405. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102406. /**
  102407. * Uploads spherical polynomials information to the texture.
  102408. * @param texture defines the texture we are trying to upload the information to
  102409. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102410. */
  102411. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102412. /** @hidden */
  102413. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102414. }
  102415. }
  102416. declare module BABYLON {
  102417. /**
  102418. * Implementation of the ENV Texture Loader.
  102419. * @hidden
  102420. */
  102421. export class _ENVTextureLoader implements IInternalTextureLoader {
  102422. /**
  102423. * Defines wether the loader supports cascade loading the different faces.
  102424. */
  102425. readonly supportCascades: boolean;
  102426. /**
  102427. * This returns if the loader support the current file information.
  102428. * @param extension defines the file extension of the file being loaded
  102429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102430. * @param fallback defines the fallback internal texture if any
  102431. * @param isBase64 defines whether the texture is encoded as a base64
  102432. * @param isBuffer defines whether the texture data are stored as a buffer
  102433. * @returns true if the loader can load the specified file
  102434. */
  102435. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102436. /**
  102437. * Transform the url before loading if required.
  102438. * @param rootUrl the url of the texture
  102439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102440. * @returns the transformed texture
  102441. */
  102442. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102443. /**
  102444. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102445. * @param rootUrl the url of the texture
  102446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102447. * @returns the fallback texture
  102448. */
  102449. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102450. /**
  102451. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102452. * @param data contains the texture data
  102453. * @param texture defines the BabylonJS internal texture
  102454. * @param createPolynomials will be true if polynomials have been requested
  102455. * @param onLoad defines the callback to trigger once the texture is ready
  102456. * @param onError defines the callback to trigger in case of error
  102457. */
  102458. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102459. /**
  102460. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102461. * @param data contains the texture data
  102462. * @param texture defines the BabylonJS internal texture
  102463. * @param callback defines the method to call once ready to upload
  102464. */
  102465. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102466. }
  102467. }
  102468. declare module BABYLON {
  102469. /**
  102470. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102471. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102472. */
  102473. export class KhronosTextureContainer {
  102474. /** contents of the KTX container file */
  102475. arrayBuffer: any;
  102476. private static HEADER_LEN;
  102477. private static COMPRESSED_2D;
  102478. private static COMPRESSED_3D;
  102479. private static TEX_2D;
  102480. private static TEX_3D;
  102481. /**
  102482. * Gets the openGL type
  102483. */
  102484. glType: number;
  102485. /**
  102486. * Gets the openGL type size
  102487. */
  102488. glTypeSize: number;
  102489. /**
  102490. * Gets the openGL format
  102491. */
  102492. glFormat: number;
  102493. /**
  102494. * Gets the openGL internal format
  102495. */
  102496. glInternalFormat: number;
  102497. /**
  102498. * Gets the base internal format
  102499. */
  102500. glBaseInternalFormat: number;
  102501. /**
  102502. * Gets image width in pixel
  102503. */
  102504. pixelWidth: number;
  102505. /**
  102506. * Gets image height in pixel
  102507. */
  102508. pixelHeight: number;
  102509. /**
  102510. * Gets image depth in pixels
  102511. */
  102512. pixelDepth: number;
  102513. /**
  102514. * Gets the number of array elements
  102515. */
  102516. numberOfArrayElements: number;
  102517. /**
  102518. * Gets the number of faces
  102519. */
  102520. numberOfFaces: number;
  102521. /**
  102522. * Gets the number of mipmap levels
  102523. */
  102524. numberOfMipmapLevels: number;
  102525. /**
  102526. * Gets the bytes of key value data
  102527. */
  102528. bytesOfKeyValueData: number;
  102529. /**
  102530. * Gets the load type
  102531. */
  102532. loadType: number;
  102533. /**
  102534. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102535. */
  102536. isInvalid: boolean;
  102537. /**
  102538. * Creates a new KhronosTextureContainer
  102539. * @param arrayBuffer contents of the KTX container file
  102540. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102541. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102542. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102543. */
  102544. constructor(
  102545. /** contents of the KTX container file */
  102546. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102547. /**
  102548. * Uploads KTX content to a Babylon Texture.
  102549. * It is assumed that the texture has already been created & is currently bound
  102550. * @hidden
  102551. */
  102552. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102553. private _upload2DCompressedLevels;
  102554. }
  102555. }
  102556. declare module BABYLON {
  102557. /**
  102558. * Implementation of the KTX Texture Loader.
  102559. * @hidden
  102560. */
  102561. export class _KTXTextureLoader implements IInternalTextureLoader {
  102562. /**
  102563. * Defines wether the loader supports cascade loading the different faces.
  102564. */
  102565. readonly supportCascades: boolean;
  102566. /**
  102567. * This returns if the loader support the current file information.
  102568. * @param extension defines the file extension of the file being loaded
  102569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102570. * @param fallback defines the fallback internal texture if any
  102571. * @param isBase64 defines whether the texture is encoded as a base64
  102572. * @param isBuffer defines whether the texture data are stored as a buffer
  102573. * @returns true if the loader can load the specified file
  102574. */
  102575. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102576. /**
  102577. * Transform the url before loading if required.
  102578. * @param rootUrl the url of the texture
  102579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102580. * @returns the transformed texture
  102581. */
  102582. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102583. /**
  102584. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102585. * @param rootUrl the url of the texture
  102586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102587. * @returns the fallback texture
  102588. */
  102589. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102590. /**
  102591. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102592. * @param data contains the texture data
  102593. * @param texture defines the BabylonJS internal texture
  102594. * @param createPolynomials will be true if polynomials have been requested
  102595. * @param onLoad defines the callback to trigger once the texture is ready
  102596. * @param onError defines the callback to trigger in case of error
  102597. */
  102598. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102599. /**
  102600. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102601. * @param data contains the texture data
  102602. * @param texture defines the BabylonJS internal texture
  102603. * @param callback defines the method to call once ready to upload
  102604. */
  102605. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102606. }
  102607. }
  102608. declare module BABYLON {
  102609. /**
  102610. * Based on jsTGALoader - Javascript loader for TGA file
  102611. * By Vincent Thibault
  102612. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102613. */
  102614. export class TGATools {
  102615. private static _TYPE_INDEXED;
  102616. private static _TYPE_RGB;
  102617. private static _TYPE_GREY;
  102618. private static _TYPE_RLE_INDEXED;
  102619. private static _TYPE_RLE_RGB;
  102620. private static _TYPE_RLE_GREY;
  102621. private static _ORIGIN_MASK;
  102622. private static _ORIGIN_SHIFT;
  102623. private static _ORIGIN_BL;
  102624. private static _ORIGIN_BR;
  102625. private static _ORIGIN_UL;
  102626. private static _ORIGIN_UR;
  102627. /**
  102628. * Gets the header of a TGA file
  102629. * @param data defines the TGA data
  102630. * @returns the header
  102631. */
  102632. static GetTGAHeader(data: Uint8Array): any;
  102633. /**
  102634. * Uploads TGA content to a Babylon Texture
  102635. * @hidden
  102636. */
  102637. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102638. /** @hidden */
  102639. 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;
  102640. /** @hidden */
  102641. 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;
  102642. /** @hidden */
  102643. 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;
  102644. /** @hidden */
  102645. 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;
  102646. /** @hidden */
  102647. 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;
  102648. /** @hidden */
  102649. 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;
  102650. }
  102651. }
  102652. declare module BABYLON {
  102653. /**
  102654. * Implementation of the TGA Texture Loader.
  102655. * @hidden
  102656. */
  102657. export class _TGATextureLoader implements IInternalTextureLoader {
  102658. /**
  102659. * Defines wether the loader supports cascade loading the different faces.
  102660. */
  102661. readonly supportCascades: boolean;
  102662. /**
  102663. * This returns if the loader support the current file information.
  102664. * @param extension defines the file extension of the file being loaded
  102665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102666. * @param fallback defines the fallback internal texture if any
  102667. * @param isBase64 defines whether the texture is encoded as a base64
  102668. * @param isBuffer defines whether the texture data are stored as a buffer
  102669. * @returns true if the loader can load the specified file
  102670. */
  102671. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102672. /**
  102673. * Transform the url before loading if required.
  102674. * @param rootUrl the url of the texture
  102675. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102676. * @returns the transformed texture
  102677. */
  102678. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102679. /**
  102680. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102681. * @param rootUrl the url of the texture
  102682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102683. * @returns the fallback texture
  102684. */
  102685. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102686. /**
  102687. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102688. * @param data contains the texture data
  102689. * @param texture defines the BabylonJS internal texture
  102690. * @param createPolynomials will be true if polynomials have been requested
  102691. * @param onLoad defines the callback to trigger once the texture is ready
  102692. * @param onError defines the callback to trigger in case of error
  102693. */
  102694. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102695. /**
  102696. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102697. * @param data contains the texture data
  102698. * @param texture defines the BabylonJS internal texture
  102699. * @param callback defines the method to call once ready to upload
  102700. */
  102701. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102702. }
  102703. }
  102704. declare module BABYLON {
  102705. /**
  102706. * 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.
  102707. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102708. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102709. */
  102710. export class CustomProceduralTexture extends ProceduralTexture {
  102711. private _animate;
  102712. private _time;
  102713. private _config;
  102714. private _texturePath;
  102715. /**
  102716. * Instantiates a new Custom Procedural Texture.
  102717. * 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.
  102718. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102719. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102720. * @param name Define the name of the texture
  102721. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102722. * @param size Define the size of the texture to create
  102723. * @param scene Define the scene the texture belongs to
  102724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102725. * @param generateMipMaps Define if the texture should creates mip maps or not
  102726. */
  102727. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102728. private _loadJson;
  102729. /**
  102730. * Is the texture ready to be used ? (rendered at least once)
  102731. * @returns true if ready, otherwise, false.
  102732. */
  102733. isReady(): boolean;
  102734. /**
  102735. * Render the texture to its associated render target.
  102736. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102737. */
  102738. render(useCameraPostProcess?: boolean): void;
  102739. /**
  102740. * Update the list of dependant textures samplers in the shader.
  102741. */
  102742. updateTextures(): void;
  102743. /**
  102744. * Update the uniform values of the procedural texture in the shader.
  102745. */
  102746. updateShaderUniforms(): void;
  102747. /**
  102748. * Define if the texture animates or not.
  102749. */
  102750. animate: boolean;
  102751. }
  102752. }
  102753. declare module BABYLON {
  102754. /** @hidden */
  102755. export var noisePixelShader: {
  102756. name: string;
  102757. shader: string;
  102758. };
  102759. }
  102760. declare module BABYLON {
  102761. /**
  102762. * Class used to generate noise procedural textures
  102763. */
  102764. export class NoiseProceduralTexture extends ProceduralTexture {
  102765. private _time;
  102766. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102767. brightness: number;
  102768. /** Defines the number of octaves to process */
  102769. octaves: number;
  102770. /** Defines the level of persistence (0.8 by default) */
  102771. persistence: number;
  102772. /** Gets or sets animation speed factor (default is 1) */
  102773. animationSpeedFactor: number;
  102774. /**
  102775. * Creates a new NoiseProceduralTexture
  102776. * @param name defines the name fo the texture
  102777. * @param size defines the size of the texture (default is 256)
  102778. * @param scene defines the hosting scene
  102779. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102780. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102781. */
  102782. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102783. private _updateShaderUniforms;
  102784. protected _getDefines(): string;
  102785. /** Generate the current state of the procedural texture */
  102786. render(useCameraPostProcess?: boolean): void;
  102787. /**
  102788. * Serializes this noise procedural texture
  102789. * @returns a serialized noise procedural texture object
  102790. */
  102791. serialize(): any;
  102792. /**
  102793. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102794. * @param parsedTexture defines parsed texture data
  102795. * @param scene defines the current scene
  102796. * @param rootUrl defines the root URL containing noise procedural texture information
  102797. * @returns a parsed NoiseProceduralTexture
  102798. */
  102799. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102800. }
  102801. }
  102802. declare module BABYLON {
  102803. /**
  102804. * Raw cube texture where the raw buffers are passed in
  102805. */
  102806. export class RawCubeTexture extends CubeTexture {
  102807. /**
  102808. * Creates a cube texture where the raw buffers are passed in.
  102809. * @param scene defines the scene the texture is attached to
  102810. * @param data defines the array of data to use to create each face
  102811. * @param size defines the size of the textures
  102812. * @param format defines the format of the data
  102813. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102814. * @param generateMipMaps defines if the engine should generate the mip levels
  102815. * @param invertY defines if data must be stored with Y axis inverted
  102816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102817. * @param compression defines the compression used (null by default)
  102818. */
  102819. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102820. /**
  102821. * Updates the raw cube texture.
  102822. * @param data defines the data to store
  102823. * @param format defines the data format
  102824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102825. * @param invertY defines if data must be stored with Y axis inverted
  102826. * @param compression defines the compression used (null by default)
  102827. * @param level defines which level of the texture to update
  102828. */
  102829. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102830. /**
  102831. * Updates a raw cube texture with RGBD encoded data.
  102832. * @param data defines the array of data [mipmap][face] to use to create each face
  102833. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102836. * @returns a promsie that resolves when the operation is complete
  102837. */
  102838. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102839. /**
  102840. * Clones the raw cube texture.
  102841. * @return a new cube texture
  102842. */
  102843. clone(): CubeTexture;
  102844. /** @hidden */
  102845. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102846. }
  102847. }
  102848. declare module BABYLON {
  102849. /**
  102850. * Class used to store 3D textures containing user data
  102851. */
  102852. export class RawTexture3D extends Texture {
  102853. /** Gets or sets the texture format to use */
  102854. format: number;
  102855. private _engine;
  102856. /**
  102857. * Create a new RawTexture3D
  102858. * @param data defines the data of the texture
  102859. * @param width defines the width of the texture
  102860. * @param height defines the height of the texture
  102861. * @param depth defines the depth of the texture
  102862. * @param format defines the texture format to use
  102863. * @param scene defines the hosting scene
  102864. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102865. * @param invertY defines if texture must be stored with Y axis inverted
  102866. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102867. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102868. */
  102869. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102870. /** Gets or sets the texture format to use */
  102871. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102872. /**
  102873. * Update the texture with new data
  102874. * @param data defines the data to store in the texture
  102875. */
  102876. update(data: ArrayBufferView): void;
  102877. }
  102878. }
  102879. declare module BABYLON {
  102880. /**
  102881. * Creates a refraction texture used by refraction channel of the standard material.
  102882. * It is like a mirror but to see through a material.
  102883. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102884. */
  102885. export class RefractionTexture extends RenderTargetTexture {
  102886. /**
  102887. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102888. * 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.
  102889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102890. */
  102891. refractionPlane: Plane;
  102892. /**
  102893. * Define how deep under the surface we should see.
  102894. */
  102895. depth: number;
  102896. /**
  102897. * Creates a refraction texture used by refraction channel of the standard material.
  102898. * It is like a mirror but to see through a material.
  102899. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102900. * @param name Define the texture name
  102901. * @param size Define the size of the underlying texture
  102902. * @param scene Define the scene the refraction belongs to
  102903. * @param generateMipMaps Define if we need to generate mips level for the refraction
  102904. */
  102905. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  102906. /**
  102907. * Clone the refraction texture.
  102908. * @returns the cloned texture
  102909. */
  102910. clone(): RefractionTexture;
  102911. /**
  102912. * Serialize the texture to a JSON representation you could use in Parse later on
  102913. * @returns the serialized JSON representation
  102914. */
  102915. serialize(): any;
  102916. }
  102917. }
  102918. declare module BABYLON {
  102919. /**
  102920. * Configuration for Draco compression
  102921. */
  102922. export interface IDracoCompressionConfiguration {
  102923. /**
  102924. * Configuration for the decoder.
  102925. */
  102926. decoder?: {
  102927. /**
  102928. * The url to the WebAssembly module.
  102929. */
  102930. wasmUrl?: string;
  102931. /**
  102932. * The url to the WebAssembly binary.
  102933. */
  102934. wasmBinaryUrl?: string;
  102935. /**
  102936. * The url to the fallback JavaScript module.
  102937. */
  102938. fallbackUrl?: string;
  102939. };
  102940. }
  102941. /**
  102942. * Draco compression (https://google.github.io/draco/)
  102943. *
  102944. * This class wraps the Draco module.
  102945. *
  102946. * **Encoder**
  102947. *
  102948. * The encoder is not currently implemented.
  102949. *
  102950. * **Decoder**
  102951. *
  102952. * 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.
  102953. *
  102954. * To update the configuration, use the following code:
  102955. * ```javascript
  102956. * DracoCompression.Configuration = {
  102957. * decoder: {
  102958. * wasmUrl: "<url to the WebAssembly library>",
  102959. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  102960. * fallbackUrl: "<url to the fallback JavaScript library>",
  102961. * }
  102962. * };
  102963. * ```
  102964. *
  102965. * 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.
  102966. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  102967. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  102968. *
  102969. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  102970. * ```javascript
  102971. * var dracoCompression = new DracoCompression();
  102972. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  102973. * [VertexBuffer.PositionKind]: 0
  102974. * });
  102975. * ```
  102976. *
  102977. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  102978. */
  102979. export class DracoCompression implements IDisposable {
  102980. private static _DecoderModulePromise;
  102981. /**
  102982. * The configuration. Defaults to the following urls:
  102983. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  102984. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  102985. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  102986. */
  102987. static Configuration: IDracoCompressionConfiguration;
  102988. /**
  102989. * Returns true if the decoder is available.
  102990. */
  102991. static readonly DecoderAvailable: boolean;
  102992. /**
  102993. * Constructor
  102994. */
  102995. constructor();
  102996. /**
  102997. * Stop all async operations and release resources.
  102998. */
  102999. dispose(): void;
  103000. /**
  103001. * Decode Draco compressed mesh data to vertex data.
  103002. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103003. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103004. * @returns A promise that resolves with the decoded vertex data
  103005. */
  103006. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103007. [kind: string]: number;
  103008. }): Promise<VertexData>;
  103009. private static _GetDecoderModule;
  103010. private static _LoadScriptAsync;
  103011. private static _LoadFileAsync;
  103012. }
  103013. }
  103014. declare module BABYLON {
  103015. /**
  103016. * Class for building Constructive Solid Geometry
  103017. */
  103018. export class CSG {
  103019. private polygons;
  103020. /**
  103021. * The world matrix
  103022. */
  103023. matrix: Matrix;
  103024. /**
  103025. * Stores the position
  103026. */
  103027. position: Vector3;
  103028. /**
  103029. * Stores the rotation
  103030. */
  103031. rotation: Vector3;
  103032. /**
  103033. * Stores the rotation quaternion
  103034. */
  103035. rotationQuaternion: Nullable<Quaternion>;
  103036. /**
  103037. * Stores the scaling vector
  103038. */
  103039. scaling: Vector3;
  103040. /**
  103041. * Convert the Mesh to CSG
  103042. * @param mesh The Mesh to convert to CSG
  103043. * @returns A new CSG from the Mesh
  103044. */
  103045. static FromMesh(mesh: Mesh): CSG;
  103046. /**
  103047. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103048. * @param polygons Polygons used to construct a CSG solid
  103049. */
  103050. private static FromPolygons;
  103051. /**
  103052. * Clones, or makes a deep copy, of the CSG
  103053. * @returns A new CSG
  103054. */
  103055. clone(): CSG;
  103056. /**
  103057. * Unions this CSG with another CSG
  103058. * @param csg The CSG to union against this CSG
  103059. * @returns The unioned CSG
  103060. */
  103061. union(csg: CSG): CSG;
  103062. /**
  103063. * Unions this CSG with another CSG in place
  103064. * @param csg The CSG to union against this CSG
  103065. */
  103066. unionInPlace(csg: CSG): void;
  103067. /**
  103068. * Subtracts this CSG with another CSG
  103069. * @param csg The CSG to subtract against this CSG
  103070. * @returns A new CSG
  103071. */
  103072. subtract(csg: CSG): CSG;
  103073. /**
  103074. * Subtracts this CSG with another CSG in place
  103075. * @param csg The CSG to subtact against this CSG
  103076. */
  103077. subtractInPlace(csg: CSG): void;
  103078. /**
  103079. * Intersect this CSG with another CSG
  103080. * @param csg The CSG to intersect against this CSG
  103081. * @returns A new CSG
  103082. */
  103083. intersect(csg: CSG): CSG;
  103084. /**
  103085. * Intersects this CSG with another CSG in place
  103086. * @param csg The CSG to intersect against this CSG
  103087. */
  103088. intersectInPlace(csg: CSG): void;
  103089. /**
  103090. * Return a new CSG solid with solid and empty space switched. This solid is
  103091. * not modified.
  103092. * @returns A new CSG solid with solid and empty space switched
  103093. */
  103094. inverse(): CSG;
  103095. /**
  103096. * Inverses the CSG in place
  103097. */
  103098. inverseInPlace(): void;
  103099. /**
  103100. * This is used to keep meshes transformations so they can be restored
  103101. * when we build back a Babylon Mesh
  103102. * NB : All CSG operations are performed in world coordinates
  103103. * @param csg The CSG to copy the transform attributes from
  103104. * @returns This CSG
  103105. */
  103106. copyTransformAttributes(csg: CSG): CSG;
  103107. /**
  103108. * Build Raw mesh from CSG
  103109. * Coordinates here are in world space
  103110. * @param name The name of the mesh geometry
  103111. * @param scene The Scene
  103112. * @param keepSubMeshes Specifies if the submeshes should be kept
  103113. * @returns A new Mesh
  103114. */
  103115. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103116. /**
  103117. * Build Mesh from CSG taking material and transforms into account
  103118. * @param name The name of the Mesh
  103119. * @param material The material of the Mesh
  103120. * @param scene The Scene
  103121. * @param keepSubMeshes Specifies if submeshes should be kept
  103122. * @returns The new Mesh
  103123. */
  103124. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103125. }
  103126. }
  103127. declare module BABYLON {
  103128. /**
  103129. * Class containing static functions to help procedurally build meshes
  103130. */
  103131. export class RibbonBuilder {
  103132. /**
  103133. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103134. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103135. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103136. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103137. * * 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
  103138. * * 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
  103139. * * 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
  103140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103143. * * 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
  103144. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103145. * * 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
  103146. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103148. * @param name defines the name of the mesh
  103149. * @param options defines the options used to create the mesh
  103150. * @param scene defines the hosting scene
  103151. * @returns the ribbon mesh
  103152. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103154. */
  103155. static CreateRibbon(name: string, options: {
  103156. pathArray: Vector3[][];
  103157. closeArray?: boolean;
  103158. closePath?: boolean;
  103159. offset?: number;
  103160. updatable?: boolean;
  103161. sideOrientation?: number;
  103162. frontUVs?: Vector4;
  103163. backUVs?: Vector4;
  103164. instance?: Mesh;
  103165. invertUV?: boolean;
  103166. uvs?: Vector2[];
  103167. colors?: Color4[];
  103168. }, scene?: Nullable<Scene>): Mesh;
  103169. }
  103170. }
  103171. declare module BABYLON {
  103172. /**
  103173. * Class containing static functions to help procedurally build meshes
  103174. */
  103175. export class TorusKnotBuilder {
  103176. /**
  103177. * Creates a torus knot mesh
  103178. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103179. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103180. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103181. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103185. * @param name defines the name of the mesh
  103186. * @param options defines the options used to create the mesh
  103187. * @param scene defines the hosting scene
  103188. * @returns the torus knot mesh
  103189. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103190. */
  103191. static CreateTorusKnot(name: string, options: {
  103192. radius?: number;
  103193. tube?: number;
  103194. radialSegments?: number;
  103195. tubularSegments?: number;
  103196. p?: number;
  103197. q?: number;
  103198. updatable?: boolean;
  103199. sideOrientation?: number;
  103200. frontUVs?: Vector4;
  103201. backUVs?: Vector4;
  103202. }, scene: any): Mesh;
  103203. }
  103204. }
  103205. declare module BABYLON {
  103206. /**
  103207. * Polygon
  103208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103209. */
  103210. export class Polygon {
  103211. /**
  103212. * Creates a rectangle
  103213. * @param xmin bottom X coord
  103214. * @param ymin bottom Y coord
  103215. * @param xmax top X coord
  103216. * @param ymax top Y coord
  103217. * @returns points that make the resulting rectation
  103218. */
  103219. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103220. /**
  103221. * Creates a circle
  103222. * @param radius radius of circle
  103223. * @param cx scale in x
  103224. * @param cy scale in y
  103225. * @param numberOfSides number of sides that make up the circle
  103226. * @returns points that make the resulting circle
  103227. */
  103228. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103229. /**
  103230. * Creates a polygon from input string
  103231. * @param input Input polygon data
  103232. * @returns the parsed points
  103233. */
  103234. static Parse(input: string): Vector2[];
  103235. /**
  103236. * Starts building a polygon from x and y coordinates
  103237. * @param x x coordinate
  103238. * @param y y coordinate
  103239. * @returns the started path2
  103240. */
  103241. static StartingAt(x: number, y: number): Path2;
  103242. }
  103243. /**
  103244. * Builds a polygon
  103245. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103246. */
  103247. export class PolygonMeshBuilder {
  103248. private _points;
  103249. private _outlinepoints;
  103250. private _holes;
  103251. private _name;
  103252. private _scene;
  103253. private _epoints;
  103254. private _eholes;
  103255. private _addToepoint;
  103256. /**
  103257. * Babylon reference to the earcut plugin.
  103258. */
  103259. bjsEarcut: any;
  103260. /**
  103261. * Creates a PolygonMeshBuilder
  103262. * @param name name of the builder
  103263. * @param contours Path of the polygon
  103264. * @param scene scene to add to
  103265. * @param earcutInjection can be used to inject your own earcut reference
  103266. */
  103267. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103268. /**
  103269. * Adds a whole within the polygon
  103270. * @param hole Array of points defining the hole
  103271. * @returns this
  103272. */
  103273. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103274. /**
  103275. * Creates the polygon
  103276. * @param updatable If the mesh should be updatable
  103277. * @param depth The depth of the mesh created
  103278. * @returns the created mesh
  103279. */
  103280. build(updatable?: boolean, depth?: number): Mesh;
  103281. /**
  103282. * Adds a side to the polygon
  103283. * @param positions points that make the polygon
  103284. * @param normals normals of the polygon
  103285. * @param uvs uvs of the polygon
  103286. * @param indices indices of the polygon
  103287. * @param bounds bounds of the polygon
  103288. * @param points points of the polygon
  103289. * @param depth depth of the polygon
  103290. * @param flip flip of the polygon
  103291. */
  103292. private addSide;
  103293. }
  103294. }
  103295. declare module BABYLON {
  103296. /**
  103297. * Class containing static functions to help procedurally build meshes
  103298. */
  103299. export class PolygonBuilder {
  103300. /**
  103301. * Creates a polygon mesh
  103302. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103303. * * 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
  103304. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103307. * * Remember you can only change the shape positions, not their number when updating a polygon
  103308. * @param name defines the name of the mesh
  103309. * @param options defines the options used to create the mesh
  103310. * @param scene defines the hosting scene
  103311. * @param earcutInjection can be used to inject your own earcut reference
  103312. * @returns the polygon mesh
  103313. */
  103314. static CreatePolygon(name: string, options: {
  103315. shape: Vector3[];
  103316. holes?: Vector3[][];
  103317. depth?: number;
  103318. faceUV?: Vector4[];
  103319. faceColors?: Color4[];
  103320. updatable?: boolean;
  103321. sideOrientation?: number;
  103322. frontUVs?: Vector4;
  103323. backUVs?: Vector4;
  103324. }, scene: Scene, earcutInjection?: any): Mesh;
  103325. /**
  103326. * Creates an extruded polygon mesh, with depth in the Y direction.
  103327. * * 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)
  103328. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103329. * @param name defines the name of the mesh
  103330. * @param options defines the options used to create the mesh
  103331. * @param scene defines the hosting scene
  103332. * @param earcutInjection can be used to inject your own earcut reference
  103333. * @returns the polygon mesh
  103334. */
  103335. static ExtrudePolygon(name: string, options: {
  103336. shape: Vector3[];
  103337. holes?: Vector3[][];
  103338. depth?: number;
  103339. faceUV?: Vector4[];
  103340. faceColors?: Color4[];
  103341. updatable?: boolean;
  103342. sideOrientation?: number;
  103343. frontUVs?: Vector4;
  103344. backUVs?: Vector4;
  103345. }, scene: Scene, earcutInjection?: any): Mesh;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /**
  103350. * Class containing static functions to help procedurally build meshes
  103351. */
  103352. export class ShapeBuilder {
  103353. /**
  103354. * 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.
  103355. * * 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.
  103356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103357. * * 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.
  103358. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103359. * * 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
  103360. * * 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
  103361. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103366. * @param name defines the name of the mesh
  103367. * @param options defines the options used to create the mesh
  103368. * @param scene defines the hosting scene
  103369. * @returns the extruded shape mesh
  103370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103372. */
  103373. static ExtrudeShape(name: string, options: {
  103374. shape: Vector3[];
  103375. path: Vector3[];
  103376. scale?: number;
  103377. rotation?: number;
  103378. cap?: number;
  103379. updatable?: boolean;
  103380. sideOrientation?: number;
  103381. frontUVs?: Vector4;
  103382. backUVs?: Vector4;
  103383. instance?: Mesh;
  103384. invertUV?: boolean;
  103385. }, scene?: Nullable<Scene>): Mesh;
  103386. /**
  103387. * Creates an custom extruded shape mesh.
  103388. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103389. * * 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.
  103390. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103391. * * 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
  103392. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103393. * * 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
  103394. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103395. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103396. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103397. * * 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
  103398. * * 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
  103399. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103404. * @param name defines the name of the mesh
  103405. * @param options defines the options used to create the mesh
  103406. * @param scene defines the hosting scene
  103407. * @returns the custom extruded shape mesh
  103408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103409. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103411. */
  103412. static ExtrudeShapeCustom(name: string, options: {
  103413. shape: Vector3[];
  103414. path: Vector3[];
  103415. scaleFunction?: any;
  103416. rotationFunction?: any;
  103417. ribbonCloseArray?: boolean;
  103418. ribbonClosePath?: boolean;
  103419. cap?: number;
  103420. updatable?: boolean;
  103421. sideOrientation?: number;
  103422. frontUVs?: Vector4;
  103423. backUVs?: Vector4;
  103424. instance?: Mesh;
  103425. invertUV?: boolean;
  103426. }, scene: Scene): Mesh;
  103427. private static _ExtrudeShapeGeneric;
  103428. }
  103429. }
  103430. declare module BABYLON {
  103431. /**
  103432. * Class containing static functions to help procedurally build meshes
  103433. */
  103434. export class LatheBuilder {
  103435. /**
  103436. * Creates lathe mesh.
  103437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103438. * * 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
  103439. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103440. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103441. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103442. * * 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
  103443. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103444. * * 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
  103445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103449. * @param name defines the name of the mesh
  103450. * @param options defines the options used to create the mesh
  103451. * @param scene defines the hosting scene
  103452. * @returns the lathe mesh
  103453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103454. */
  103455. static CreateLathe(name: string, options: {
  103456. shape: Vector3[];
  103457. radius?: number;
  103458. tessellation?: number;
  103459. clip?: number;
  103460. arc?: number;
  103461. closed?: boolean;
  103462. updatable?: boolean;
  103463. sideOrientation?: number;
  103464. frontUVs?: Vector4;
  103465. backUVs?: Vector4;
  103466. cap?: number;
  103467. invertUV?: boolean;
  103468. }, scene: Scene): Mesh;
  103469. }
  103470. }
  103471. declare module BABYLON {
  103472. /**
  103473. * Class containing static functions to help procedurally build meshes
  103474. */
  103475. export class TubeBuilder {
  103476. /**
  103477. * Creates a tube mesh.
  103478. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103479. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103480. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103481. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103482. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103483. * * 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)
  103484. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103485. * * 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
  103486. * * 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
  103487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103491. * @param name defines the name of the mesh
  103492. * @param options defines the options used to create the mesh
  103493. * @param scene defines the hosting scene
  103494. * @returns the tube mesh
  103495. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103496. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103497. */
  103498. static CreateTube(name: string, options: {
  103499. path: Vector3[];
  103500. radius?: number;
  103501. tessellation?: number;
  103502. radiusFunction?: {
  103503. (i: number, distance: number): number;
  103504. };
  103505. cap?: number;
  103506. arc?: number;
  103507. updatable?: boolean;
  103508. sideOrientation?: number;
  103509. frontUVs?: Vector4;
  103510. backUVs?: Vector4;
  103511. instance?: Mesh;
  103512. invertUV?: boolean;
  103513. }, scene: Scene): Mesh;
  103514. }
  103515. }
  103516. declare module BABYLON {
  103517. /**
  103518. * Class containing static functions to help procedurally build meshes
  103519. */
  103520. export class IcoSphereBuilder {
  103521. /**
  103522. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103523. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103524. * * 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`)
  103525. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103526. * * 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
  103527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103530. * @param name defines the name of the mesh
  103531. * @param options defines the options used to create the mesh
  103532. * @param scene defines the hosting scene
  103533. * @returns the icosahedron mesh
  103534. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103535. */
  103536. static CreateIcoSphere(name: string, options: {
  103537. radius?: number;
  103538. radiusX?: number;
  103539. radiusY?: number;
  103540. radiusZ?: number;
  103541. flat?: boolean;
  103542. subdivisions?: number;
  103543. sideOrientation?: number;
  103544. frontUVs?: Vector4;
  103545. backUVs?: Vector4;
  103546. updatable?: boolean;
  103547. }, scene: Scene): Mesh;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. /**
  103552. * Class containing static functions to help procedurally build meshes
  103553. */
  103554. export class DecalBuilder {
  103555. /**
  103556. * Creates a decal mesh.
  103557. * 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
  103558. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103559. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103560. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103561. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103562. * @param name defines the name of the mesh
  103563. * @param sourceMesh defines the mesh where the decal must be applied
  103564. * @param options defines the options used to create the mesh
  103565. * @param scene defines the hosting scene
  103566. * @returns the decal mesh
  103567. * @see https://doc.babylonjs.com/how_to/decals
  103568. */
  103569. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103570. position?: Vector3;
  103571. normal?: Vector3;
  103572. size?: Vector3;
  103573. angle?: number;
  103574. }): Mesh;
  103575. }
  103576. }
  103577. declare module BABYLON {
  103578. /**
  103579. * Class containing static functions to help procedurally build meshes
  103580. */
  103581. export class MeshBuilder {
  103582. /**
  103583. * Creates a box mesh
  103584. * * The parameter `size` sets the size (float) of each box side (default 1)
  103585. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103586. * * 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)
  103587. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103591. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103592. * @param name defines the name of the mesh
  103593. * @param options defines the options used to create the mesh
  103594. * @param scene defines the hosting scene
  103595. * @returns the box mesh
  103596. */
  103597. static CreateBox(name: string, options: {
  103598. size?: number;
  103599. width?: number;
  103600. height?: number;
  103601. depth?: number;
  103602. faceUV?: Vector4[];
  103603. faceColors?: Color4[];
  103604. sideOrientation?: number;
  103605. frontUVs?: Vector4;
  103606. backUVs?: Vector4;
  103607. updatable?: boolean;
  103608. }, scene?: Nullable<Scene>): Mesh;
  103609. /**
  103610. * Creates a sphere mesh
  103611. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103612. * * 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`)
  103613. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103614. * * 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
  103615. * * 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)
  103616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103619. * @param name defines the name of the mesh
  103620. * @param options defines the options used to create the mesh
  103621. * @param scene defines the hosting scene
  103622. * @returns the sphere mesh
  103623. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103624. */
  103625. static CreateSphere(name: string, options: {
  103626. segments?: number;
  103627. diameter?: number;
  103628. diameterX?: number;
  103629. diameterY?: number;
  103630. diameterZ?: number;
  103631. arc?: number;
  103632. slice?: number;
  103633. sideOrientation?: number;
  103634. frontUVs?: Vector4;
  103635. backUVs?: Vector4;
  103636. updatable?: boolean;
  103637. }, scene: any): Mesh;
  103638. /**
  103639. * Creates a plane polygonal mesh. By default, this is a disc
  103640. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103641. * * 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
  103642. * * 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
  103643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103646. * @param name defines the name of the mesh
  103647. * @param options defines the options used to create the mesh
  103648. * @param scene defines the hosting scene
  103649. * @returns the plane polygonal mesh
  103650. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103651. */
  103652. static CreateDisc(name: string, options: {
  103653. radius?: number;
  103654. tessellation?: number;
  103655. arc?: number;
  103656. updatable?: boolean;
  103657. sideOrientation?: number;
  103658. frontUVs?: Vector4;
  103659. backUVs?: Vector4;
  103660. }, scene?: Nullable<Scene>): Mesh;
  103661. /**
  103662. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103663. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103664. * * 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`)
  103665. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103666. * * 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
  103667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103670. * @param name defines the name of the mesh
  103671. * @param options defines the options used to create the mesh
  103672. * @param scene defines the hosting scene
  103673. * @returns the icosahedron mesh
  103674. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103675. */
  103676. static CreateIcoSphere(name: string, options: {
  103677. radius?: number;
  103678. radiusX?: number;
  103679. radiusY?: number;
  103680. radiusZ?: number;
  103681. flat?: boolean;
  103682. subdivisions?: number;
  103683. sideOrientation?: number;
  103684. frontUVs?: Vector4;
  103685. backUVs?: Vector4;
  103686. updatable?: boolean;
  103687. }, scene: Scene): Mesh;
  103688. /**
  103689. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103690. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103691. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103692. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103693. * * 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
  103694. * * 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
  103695. * * 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
  103696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103699. * * 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
  103700. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103701. * * 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
  103702. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103704. * @param name defines the name of the mesh
  103705. * @param options defines the options used to create the mesh
  103706. * @param scene defines the hosting scene
  103707. * @returns the ribbon mesh
  103708. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103710. */
  103711. static CreateRibbon(name: string, options: {
  103712. pathArray: Vector3[][];
  103713. closeArray?: boolean;
  103714. closePath?: boolean;
  103715. offset?: number;
  103716. updatable?: boolean;
  103717. sideOrientation?: number;
  103718. frontUVs?: Vector4;
  103719. backUVs?: Vector4;
  103720. instance?: Mesh;
  103721. invertUV?: boolean;
  103722. uvs?: Vector2[];
  103723. colors?: Color4[];
  103724. }, scene?: Nullable<Scene>): Mesh;
  103725. /**
  103726. * Creates a cylinder or a cone mesh
  103727. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103728. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103729. * * 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.
  103730. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103731. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103732. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103733. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103734. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103735. * * 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).
  103736. * * 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
  103737. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103738. * * 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
  103739. * * 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.
  103740. * * If `enclose` is false, a ring surface is one element.
  103741. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103742. * * 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
  103743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103746. * @param name defines the name of the mesh
  103747. * @param options defines the options used to create the mesh
  103748. * @param scene defines the hosting scene
  103749. * @returns the cylinder mesh
  103750. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103751. */
  103752. static CreateCylinder(name: string, options: {
  103753. height?: number;
  103754. diameterTop?: number;
  103755. diameterBottom?: number;
  103756. diameter?: number;
  103757. tessellation?: number;
  103758. subdivisions?: number;
  103759. arc?: number;
  103760. faceColors?: Color4[];
  103761. faceUV?: Vector4[];
  103762. updatable?: boolean;
  103763. hasRings?: boolean;
  103764. enclose?: boolean;
  103765. sideOrientation?: number;
  103766. frontUVs?: Vector4;
  103767. backUVs?: Vector4;
  103768. }, scene: any): Mesh;
  103769. /**
  103770. * Creates a torus mesh
  103771. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103772. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103773. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103777. * @param name defines the name of the mesh
  103778. * @param options defines the options used to create the mesh
  103779. * @param scene defines the hosting scene
  103780. * @returns the torus mesh
  103781. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103782. */
  103783. static CreateTorus(name: string, options: {
  103784. diameter?: number;
  103785. thickness?: number;
  103786. tessellation?: number;
  103787. updatable?: boolean;
  103788. sideOrientation?: number;
  103789. frontUVs?: Vector4;
  103790. backUVs?: Vector4;
  103791. }, scene: any): Mesh;
  103792. /**
  103793. * Creates a torus knot mesh
  103794. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103795. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103796. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103797. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103801. * @param name defines the name of the mesh
  103802. * @param options defines the options used to create the mesh
  103803. * @param scene defines the hosting scene
  103804. * @returns the torus knot mesh
  103805. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103806. */
  103807. static CreateTorusKnot(name: string, options: {
  103808. radius?: number;
  103809. tube?: number;
  103810. radialSegments?: number;
  103811. tubularSegments?: number;
  103812. p?: number;
  103813. q?: number;
  103814. updatable?: boolean;
  103815. sideOrientation?: number;
  103816. frontUVs?: Vector4;
  103817. backUVs?: Vector4;
  103818. }, scene: any): Mesh;
  103819. /**
  103820. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103821. * * 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
  103822. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103823. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103824. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103825. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103826. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103827. * * 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
  103828. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103831. * @param name defines the name of the new line system
  103832. * @param options defines the options used to create the line system
  103833. * @param scene defines the hosting scene
  103834. * @returns a new line system mesh
  103835. */
  103836. static CreateLineSystem(name: string, options: {
  103837. lines: Vector3[][];
  103838. updatable?: boolean;
  103839. instance?: Nullable<LinesMesh>;
  103840. colors?: Nullable<Color4[][]>;
  103841. useVertexAlpha?: boolean;
  103842. }, scene: Nullable<Scene>): LinesMesh;
  103843. /**
  103844. * Creates a line mesh
  103845. * 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
  103846. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103847. * * The parameter `points` is an array successive Vector3
  103848. * * 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
  103849. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103850. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103851. * * When updating an instance, remember that only point positions can change, not the number of points
  103852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103854. * @param name defines the name of the new line system
  103855. * @param options defines the options used to create the line system
  103856. * @param scene defines the hosting scene
  103857. * @returns a new line mesh
  103858. */
  103859. static CreateLines(name: string, options: {
  103860. points: Vector3[];
  103861. updatable?: boolean;
  103862. instance?: Nullable<LinesMesh>;
  103863. colors?: Color4[];
  103864. useVertexAlpha?: boolean;
  103865. }, scene?: Nullable<Scene>): LinesMesh;
  103866. /**
  103867. * Creates a dashed line mesh
  103868. * * 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
  103869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103870. * * The parameter `points` is an array successive Vector3
  103871. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103872. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103873. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103874. * * 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
  103875. * * When updating an instance, remember that only point positions can change, not the number of points
  103876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103877. * @param name defines the name of the mesh
  103878. * @param options defines the options used to create the mesh
  103879. * @param scene defines the hosting scene
  103880. * @returns the dashed line mesh
  103881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103882. */
  103883. static CreateDashedLines(name: string, options: {
  103884. points: Vector3[];
  103885. dashSize?: number;
  103886. gapSize?: number;
  103887. dashNb?: number;
  103888. updatable?: boolean;
  103889. instance?: LinesMesh;
  103890. }, scene?: Nullable<Scene>): LinesMesh;
  103891. /**
  103892. * 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.
  103893. * * 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.
  103894. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103895. * * 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.
  103896. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103897. * * 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
  103898. * * 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
  103899. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103904. * @param name defines the name of the mesh
  103905. * @param options defines the options used to create the mesh
  103906. * @param scene defines the hosting scene
  103907. * @returns the extruded shape mesh
  103908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103910. */
  103911. static ExtrudeShape(name: string, options: {
  103912. shape: Vector3[];
  103913. path: Vector3[];
  103914. scale?: number;
  103915. rotation?: number;
  103916. cap?: number;
  103917. updatable?: boolean;
  103918. sideOrientation?: number;
  103919. frontUVs?: Vector4;
  103920. backUVs?: Vector4;
  103921. instance?: Mesh;
  103922. invertUV?: boolean;
  103923. }, scene?: Nullable<Scene>): Mesh;
  103924. /**
  103925. * Creates an custom extruded shape mesh.
  103926. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103927. * * 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.
  103928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103929. * * 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
  103930. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103931. * * 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
  103932. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103933. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103934. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103935. * * 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
  103936. * * 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
  103937. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103940. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103942. * @param name defines the name of the mesh
  103943. * @param options defines the options used to create the mesh
  103944. * @param scene defines the hosting scene
  103945. * @returns the custom extruded shape mesh
  103946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103949. */
  103950. static ExtrudeShapeCustom(name: string, options: {
  103951. shape: Vector3[];
  103952. path: Vector3[];
  103953. scaleFunction?: any;
  103954. rotationFunction?: any;
  103955. ribbonCloseArray?: boolean;
  103956. ribbonClosePath?: boolean;
  103957. cap?: number;
  103958. updatable?: boolean;
  103959. sideOrientation?: number;
  103960. frontUVs?: Vector4;
  103961. backUVs?: Vector4;
  103962. instance?: Mesh;
  103963. invertUV?: boolean;
  103964. }, scene: Scene): Mesh;
  103965. /**
  103966. * Creates lathe mesh.
  103967. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103968. * * 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
  103969. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103970. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103971. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103972. * * 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
  103973. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103974. * * 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
  103975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103979. * @param name defines the name of the mesh
  103980. * @param options defines the options used to create the mesh
  103981. * @param scene defines the hosting scene
  103982. * @returns the lathe mesh
  103983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103984. */
  103985. static CreateLathe(name: string, options: {
  103986. shape: Vector3[];
  103987. radius?: number;
  103988. tessellation?: number;
  103989. clip?: number;
  103990. arc?: number;
  103991. closed?: boolean;
  103992. updatable?: boolean;
  103993. sideOrientation?: number;
  103994. frontUVs?: Vector4;
  103995. backUVs?: Vector4;
  103996. cap?: number;
  103997. invertUV?: boolean;
  103998. }, scene: Scene): Mesh;
  103999. /**
  104000. * Creates a plane mesh
  104001. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104002. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104003. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104007. * @param name defines the name of the mesh
  104008. * @param options defines the options used to create the mesh
  104009. * @param scene defines the hosting scene
  104010. * @returns the plane mesh
  104011. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104012. */
  104013. static CreatePlane(name: string, options: {
  104014. size?: number;
  104015. width?: number;
  104016. height?: number;
  104017. sideOrientation?: number;
  104018. frontUVs?: Vector4;
  104019. backUVs?: Vector4;
  104020. updatable?: boolean;
  104021. sourcePlane?: Plane;
  104022. }, scene: Scene): Mesh;
  104023. /**
  104024. * Creates a ground mesh
  104025. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104026. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104028. * @param name defines the name of the mesh
  104029. * @param options defines the options used to create the mesh
  104030. * @param scene defines the hosting scene
  104031. * @returns the ground mesh
  104032. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104033. */
  104034. static CreateGround(name: string, options: {
  104035. width?: number;
  104036. height?: number;
  104037. subdivisions?: number;
  104038. subdivisionsX?: number;
  104039. subdivisionsY?: number;
  104040. updatable?: boolean;
  104041. }, scene: any): Mesh;
  104042. /**
  104043. * Creates a tiled ground mesh
  104044. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104045. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104046. * * 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
  104047. * * 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
  104048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104049. * @param name defines the name of the mesh
  104050. * @param options defines the options used to create the mesh
  104051. * @param scene defines the hosting scene
  104052. * @returns the tiled ground mesh
  104053. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104054. */
  104055. static CreateTiledGround(name: string, options: {
  104056. xmin: number;
  104057. zmin: number;
  104058. xmax: number;
  104059. zmax: number;
  104060. subdivisions?: {
  104061. w: number;
  104062. h: number;
  104063. };
  104064. precision?: {
  104065. w: number;
  104066. h: number;
  104067. };
  104068. updatable?: boolean;
  104069. }, scene: Scene): Mesh;
  104070. /**
  104071. * Creates a ground mesh from a height map
  104072. * * The parameter `url` sets the URL of the height map image resource.
  104073. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104074. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104075. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104076. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104077. * * 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.
  104078. * * 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).
  104079. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104081. * @param name defines the name of the mesh
  104082. * @param url defines the url to the height map
  104083. * @param options defines the options used to create the mesh
  104084. * @param scene defines the hosting scene
  104085. * @returns the ground mesh
  104086. * @see https://doc.babylonjs.com/babylon101/height_map
  104087. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104088. */
  104089. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104090. width?: number;
  104091. height?: number;
  104092. subdivisions?: number;
  104093. minHeight?: number;
  104094. maxHeight?: number;
  104095. colorFilter?: Color3;
  104096. alphaFilter?: number;
  104097. updatable?: boolean;
  104098. onReady?: (mesh: GroundMesh) => void;
  104099. }, scene: Scene): GroundMesh;
  104100. /**
  104101. * Creates a polygon mesh
  104102. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104103. * * 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
  104104. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104107. * * Remember you can only change the shape positions, not their number when updating a polygon
  104108. * @param name defines the name of the mesh
  104109. * @param options defines the options used to create the mesh
  104110. * @param scene defines the hosting scene
  104111. * @param earcutInjection can be used to inject your own earcut reference
  104112. * @returns the polygon mesh
  104113. */
  104114. static CreatePolygon(name: string, options: {
  104115. shape: Vector3[];
  104116. holes?: Vector3[][];
  104117. depth?: number;
  104118. faceUV?: Vector4[];
  104119. faceColors?: Color4[];
  104120. updatable?: boolean;
  104121. sideOrientation?: number;
  104122. frontUVs?: Vector4;
  104123. backUVs?: Vector4;
  104124. }, scene: Scene, earcutInjection?: any): Mesh;
  104125. /**
  104126. * Creates an extruded polygon mesh, with depth in the Y direction.
  104127. * * 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)
  104128. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104129. * @param name defines the name of the mesh
  104130. * @param options defines the options used to create the mesh
  104131. * @param scene defines the hosting scene
  104132. * @param earcutInjection can be used to inject your own earcut reference
  104133. * @returns the polygon mesh
  104134. */
  104135. static ExtrudePolygon(name: string, options: {
  104136. shape: Vector3[];
  104137. holes?: Vector3[][];
  104138. depth?: number;
  104139. faceUV?: Vector4[];
  104140. faceColors?: Color4[];
  104141. updatable?: boolean;
  104142. sideOrientation?: number;
  104143. frontUVs?: Vector4;
  104144. backUVs?: Vector4;
  104145. }, scene: Scene, earcutInjection?: any): Mesh;
  104146. /**
  104147. * Creates a tube mesh.
  104148. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104149. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104150. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104151. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104152. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104153. * * 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)
  104154. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104155. * * 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
  104156. * * 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
  104157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104161. * @param name defines the name of the mesh
  104162. * @param options defines the options used to create the mesh
  104163. * @param scene defines the hosting scene
  104164. * @returns the tube mesh
  104165. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104166. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104167. */
  104168. static CreateTube(name: string, options: {
  104169. path: Vector3[];
  104170. radius?: number;
  104171. tessellation?: number;
  104172. radiusFunction?: {
  104173. (i: number, distance: number): number;
  104174. };
  104175. cap?: number;
  104176. arc?: number;
  104177. updatable?: boolean;
  104178. sideOrientation?: number;
  104179. frontUVs?: Vector4;
  104180. backUVs?: Vector4;
  104181. instance?: Mesh;
  104182. invertUV?: boolean;
  104183. }, scene: Scene): Mesh;
  104184. /**
  104185. * Creates a polyhedron mesh
  104186. * * 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
  104187. * * The parameter `size` (positive float, default 1) sets the polygon size
  104188. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104189. * * 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`
  104190. * * 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
  104191. * * 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)`)
  104192. * * 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
  104193. * * 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
  104194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104197. * @param name defines the name of the mesh
  104198. * @param options defines the options used to create the mesh
  104199. * @param scene defines the hosting scene
  104200. * @returns the polyhedron mesh
  104201. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104202. */
  104203. static CreatePolyhedron(name: string, options: {
  104204. type?: number;
  104205. size?: number;
  104206. sizeX?: number;
  104207. sizeY?: number;
  104208. sizeZ?: number;
  104209. custom?: any;
  104210. faceUV?: Vector4[];
  104211. faceColors?: Color4[];
  104212. flat?: boolean;
  104213. updatable?: boolean;
  104214. sideOrientation?: number;
  104215. frontUVs?: Vector4;
  104216. backUVs?: Vector4;
  104217. }, scene: Scene): Mesh;
  104218. /**
  104219. * Creates a decal mesh.
  104220. * 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
  104221. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104222. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104223. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104224. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104225. * @param name defines the name of the mesh
  104226. * @param sourceMesh defines the mesh where the decal must be applied
  104227. * @param options defines the options used to create the mesh
  104228. * @param scene defines the hosting scene
  104229. * @returns the decal mesh
  104230. * @see https://doc.babylonjs.com/how_to/decals
  104231. */
  104232. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104233. position?: Vector3;
  104234. normal?: Vector3;
  104235. size?: Vector3;
  104236. angle?: number;
  104237. }): Mesh;
  104238. }
  104239. }
  104240. declare module BABYLON {
  104241. /**
  104242. * A simplifier interface for future simplification implementations
  104243. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104244. */
  104245. export interface ISimplifier {
  104246. /**
  104247. * Simplification of a given mesh according to the given settings.
  104248. * Since this requires computation, it is assumed that the function runs async.
  104249. * @param settings The settings of the simplification, including quality and distance
  104250. * @param successCallback A callback that will be called after the mesh was simplified.
  104251. * @param errorCallback in case of an error, this callback will be called. optional.
  104252. */
  104253. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104254. }
  104255. /**
  104256. * Expected simplification settings.
  104257. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104258. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104259. */
  104260. export interface ISimplificationSettings {
  104261. /**
  104262. * Gets or sets the expected quality
  104263. */
  104264. quality: number;
  104265. /**
  104266. * Gets or sets the distance when this optimized version should be used
  104267. */
  104268. distance: number;
  104269. /**
  104270. * Gets an already optimized mesh
  104271. */
  104272. optimizeMesh?: boolean;
  104273. }
  104274. /**
  104275. * Class used to specify simplification options
  104276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104277. */
  104278. export class SimplificationSettings implements ISimplificationSettings {
  104279. /** expected quality */
  104280. quality: number;
  104281. /** distance when this optimized version should be used */
  104282. distance: number;
  104283. /** already optimized mesh */
  104284. optimizeMesh?: boolean | undefined;
  104285. /**
  104286. * Creates a SimplificationSettings
  104287. * @param quality expected quality
  104288. * @param distance distance when this optimized version should be used
  104289. * @param optimizeMesh already optimized mesh
  104290. */
  104291. constructor(
  104292. /** expected quality */
  104293. quality: number,
  104294. /** distance when this optimized version should be used */
  104295. distance: number,
  104296. /** already optimized mesh */
  104297. optimizeMesh?: boolean | undefined);
  104298. }
  104299. /**
  104300. * Interface used to define a simplification task
  104301. */
  104302. export interface ISimplificationTask {
  104303. /**
  104304. * Array of settings
  104305. */
  104306. settings: Array<ISimplificationSettings>;
  104307. /**
  104308. * Simplification type
  104309. */
  104310. simplificationType: SimplificationType;
  104311. /**
  104312. * Mesh to simplify
  104313. */
  104314. mesh: Mesh;
  104315. /**
  104316. * Callback called on success
  104317. */
  104318. successCallback?: () => void;
  104319. /**
  104320. * Defines if parallel processing can be used
  104321. */
  104322. parallelProcessing: boolean;
  104323. }
  104324. /**
  104325. * Queue used to order the simplification tasks
  104326. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104327. */
  104328. export class SimplificationQueue {
  104329. private _simplificationArray;
  104330. /**
  104331. * Gets a boolean indicating that the process is still running
  104332. */
  104333. running: boolean;
  104334. /**
  104335. * Creates a new queue
  104336. */
  104337. constructor();
  104338. /**
  104339. * Adds a new simplification task
  104340. * @param task defines a task to add
  104341. */
  104342. addTask(task: ISimplificationTask): void;
  104343. /**
  104344. * Execute next task
  104345. */
  104346. executeNext(): void;
  104347. /**
  104348. * Execute a simplification task
  104349. * @param task defines the task to run
  104350. */
  104351. runSimplification(task: ISimplificationTask): void;
  104352. private getSimplifier;
  104353. }
  104354. /**
  104355. * The implemented types of simplification
  104356. * At the moment only Quadratic Error Decimation is implemented
  104357. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104358. */
  104359. export enum SimplificationType {
  104360. /** Quadratic error decimation */
  104361. QUADRATIC = 0
  104362. }
  104363. }
  104364. declare module BABYLON {
  104365. interface Scene {
  104366. /** @hidden (Backing field) */
  104367. _simplificationQueue: SimplificationQueue;
  104368. /**
  104369. * Gets or sets the simplification queue attached to the scene
  104370. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104371. */
  104372. simplificationQueue: SimplificationQueue;
  104373. }
  104374. interface Mesh {
  104375. /**
  104376. * Simplify the mesh according to the given array of settings.
  104377. * Function will return immediately and will simplify async
  104378. * @param settings a collection of simplification settings
  104379. * @param parallelProcessing should all levels calculate parallel or one after the other
  104380. * @param simplificationType the type of simplification to run
  104381. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104382. * @returns the current mesh
  104383. */
  104384. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104385. }
  104386. /**
  104387. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104388. * created in a scene
  104389. */
  104390. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104391. /**
  104392. * The component name helpfull to identify the component in the list of scene components.
  104393. */
  104394. readonly name: string;
  104395. /**
  104396. * The scene the component belongs to.
  104397. */
  104398. scene: Scene;
  104399. /**
  104400. * Creates a new instance of the component for the given scene
  104401. * @param scene Defines the scene to register the component in
  104402. */
  104403. constructor(scene: Scene);
  104404. /**
  104405. * Registers the component in a given scene
  104406. */
  104407. register(): void;
  104408. /**
  104409. * Rebuilds the elements related to this component in case of
  104410. * context lost for instance.
  104411. */
  104412. rebuild(): void;
  104413. /**
  104414. * Disposes the component and the associated ressources
  104415. */
  104416. dispose(): void;
  104417. private _beforeCameraUpdate;
  104418. }
  104419. }
  104420. declare module BABYLON {
  104421. /**
  104422. * Class used to enable access to IndexedDB
  104423. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104424. */
  104425. export class Database implements IOfflineProvider {
  104426. private _callbackManifestChecked;
  104427. private _currentSceneUrl;
  104428. private _db;
  104429. private _enableSceneOffline;
  104430. private _enableTexturesOffline;
  104431. private _manifestVersionFound;
  104432. private _mustUpdateRessources;
  104433. private _hasReachedQuota;
  104434. private _isSupported;
  104435. private _idbFactory;
  104436. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104437. private static IsUASupportingBlobStorage;
  104438. /**
  104439. * Gets a boolean indicating if Database storate is enabled (off by default)
  104440. */
  104441. static IDBStorageEnabled: boolean;
  104442. /**
  104443. * Gets a boolean indicating if scene must be saved in the database
  104444. */
  104445. readonly enableSceneOffline: boolean;
  104446. /**
  104447. * Gets a boolean indicating if textures must be saved in the database
  104448. */
  104449. readonly enableTexturesOffline: boolean;
  104450. /**
  104451. * Creates a new Database
  104452. * @param urlToScene defines the url to load the scene
  104453. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104454. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104455. */
  104456. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104457. private static _ParseURL;
  104458. private static _ReturnFullUrlLocation;
  104459. private _checkManifestFile;
  104460. /**
  104461. * Open the database and make it available
  104462. * @param successCallback defines the callback to call on success
  104463. * @param errorCallback defines the callback to call on error
  104464. */
  104465. open(successCallback: () => void, errorCallback: () => void): void;
  104466. /**
  104467. * Loads an image from the database
  104468. * @param url defines the url to load from
  104469. * @param image defines the target DOM image
  104470. */
  104471. loadImage(url: string, image: HTMLImageElement): void;
  104472. private _loadImageFromDBAsync;
  104473. private _saveImageIntoDBAsync;
  104474. private _checkVersionFromDB;
  104475. private _loadVersionFromDBAsync;
  104476. private _saveVersionIntoDBAsync;
  104477. /**
  104478. * Loads a file from database
  104479. * @param url defines the URL to load from
  104480. * @param sceneLoaded defines a callback to call on success
  104481. * @param progressCallBack defines a callback to call when progress changed
  104482. * @param errorCallback defines a callback to call on error
  104483. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104484. */
  104485. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104486. private _loadFileAsync;
  104487. private _saveFileAsync;
  104488. /**
  104489. * Validates if xhr data is correct
  104490. * @param xhr defines the request to validate
  104491. * @param dataType defines the expected data type
  104492. * @returns true if data is correct
  104493. */
  104494. private static _ValidateXHRData;
  104495. }
  104496. }
  104497. declare module BABYLON {
  104498. /** @hidden */
  104499. export var gpuUpdateParticlesPixelShader: {
  104500. name: string;
  104501. shader: string;
  104502. };
  104503. }
  104504. declare module BABYLON {
  104505. /** @hidden */
  104506. export var gpuUpdateParticlesVertexShader: {
  104507. name: string;
  104508. shader: string;
  104509. };
  104510. }
  104511. declare module BABYLON {
  104512. /** @hidden */
  104513. export var clipPlaneFragmentDeclaration2: {
  104514. name: string;
  104515. shader: string;
  104516. };
  104517. }
  104518. declare module BABYLON {
  104519. /** @hidden */
  104520. export var gpuRenderParticlesPixelShader: {
  104521. name: string;
  104522. shader: string;
  104523. };
  104524. }
  104525. declare module BABYLON {
  104526. /** @hidden */
  104527. export var clipPlaneVertexDeclaration2: {
  104528. name: string;
  104529. shader: string;
  104530. };
  104531. }
  104532. declare module BABYLON {
  104533. /** @hidden */
  104534. export var gpuRenderParticlesVertexShader: {
  104535. name: string;
  104536. shader: string;
  104537. };
  104538. }
  104539. declare module BABYLON {
  104540. /**
  104541. * This represents a GPU particle system in Babylon
  104542. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104543. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104544. */
  104545. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104546. /**
  104547. * The layer mask we are rendering the particles through.
  104548. */
  104549. layerMask: number;
  104550. private _capacity;
  104551. private _activeCount;
  104552. private _currentActiveCount;
  104553. private _accumulatedCount;
  104554. private _renderEffect;
  104555. private _updateEffect;
  104556. private _buffer0;
  104557. private _buffer1;
  104558. private _spriteBuffer;
  104559. private _updateVAO;
  104560. private _renderVAO;
  104561. private _targetIndex;
  104562. private _sourceBuffer;
  104563. private _targetBuffer;
  104564. private _engine;
  104565. private _currentRenderId;
  104566. private _started;
  104567. private _stopped;
  104568. private _timeDelta;
  104569. private _randomTexture;
  104570. private _randomTexture2;
  104571. private _attributesStrideSize;
  104572. private _updateEffectOptions;
  104573. private _randomTextureSize;
  104574. private _actualFrame;
  104575. private readonly _rawTextureWidth;
  104576. /**
  104577. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104578. */
  104579. static readonly IsSupported: boolean;
  104580. /**
  104581. * An event triggered when the system is disposed.
  104582. */
  104583. onDisposeObservable: Observable<GPUParticleSystem>;
  104584. /**
  104585. * Gets the maximum number of particles active at the same time.
  104586. * @returns The max number of active particles.
  104587. */
  104588. getCapacity(): number;
  104589. /**
  104590. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104591. * to override the particles.
  104592. */
  104593. forceDepthWrite: boolean;
  104594. /**
  104595. * Gets or set the number of active particles
  104596. */
  104597. activeParticleCount: number;
  104598. private _preWarmDone;
  104599. /**
  104600. * Is this system ready to be used/rendered
  104601. * @return true if the system is ready
  104602. */
  104603. isReady(): boolean;
  104604. /**
  104605. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104606. * @returns True if it has been started, otherwise false.
  104607. */
  104608. isStarted(): boolean;
  104609. /**
  104610. * Starts the particle system and begins to emit
  104611. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104612. */
  104613. start(delay?: number): void;
  104614. /**
  104615. * Stops the particle system.
  104616. */
  104617. stop(): void;
  104618. /**
  104619. * Remove all active particles
  104620. */
  104621. reset(): void;
  104622. /**
  104623. * Returns the string "GPUParticleSystem"
  104624. * @returns a string containing the class name
  104625. */
  104626. getClassName(): string;
  104627. private _colorGradientsTexture;
  104628. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104629. /**
  104630. * Adds a new color gradient
  104631. * @param gradient defines the gradient to use (between 0 and 1)
  104632. * @param color1 defines the color to affect to the specified gradient
  104633. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104634. * @returns the current particle system
  104635. */
  104636. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104637. /**
  104638. * Remove a specific color gradient
  104639. * @param gradient defines the gradient to remove
  104640. * @returns the current particle system
  104641. */
  104642. removeColorGradient(gradient: number): GPUParticleSystem;
  104643. private _angularSpeedGradientsTexture;
  104644. private _sizeGradientsTexture;
  104645. private _velocityGradientsTexture;
  104646. private _limitVelocityGradientsTexture;
  104647. private _dragGradientsTexture;
  104648. private _addFactorGradient;
  104649. /**
  104650. * Adds a new size gradient
  104651. * @param gradient defines the gradient to use (between 0 and 1)
  104652. * @param factor defines the size factor to affect to the specified gradient
  104653. * @returns the current particle system
  104654. */
  104655. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104656. /**
  104657. * Remove a specific size gradient
  104658. * @param gradient defines the gradient to remove
  104659. * @returns the current particle system
  104660. */
  104661. removeSizeGradient(gradient: number): GPUParticleSystem;
  104662. /**
  104663. * Adds a new angular speed gradient
  104664. * @param gradient defines the gradient to use (between 0 and 1)
  104665. * @param factor defines the angular speed to affect to the specified gradient
  104666. * @returns the current particle system
  104667. */
  104668. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104669. /**
  104670. * Remove a specific angular speed gradient
  104671. * @param gradient defines the gradient to remove
  104672. * @returns the current particle system
  104673. */
  104674. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104675. /**
  104676. * Adds a new velocity gradient
  104677. * @param gradient defines the gradient to use (between 0 and 1)
  104678. * @param factor defines the velocity to affect to the specified gradient
  104679. * @returns the current particle system
  104680. */
  104681. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104682. /**
  104683. * Remove a specific velocity gradient
  104684. * @param gradient defines the gradient to remove
  104685. * @returns the current particle system
  104686. */
  104687. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104688. /**
  104689. * Adds a new limit velocity gradient
  104690. * @param gradient defines the gradient to use (between 0 and 1)
  104691. * @param factor defines the limit velocity value to affect to the specified gradient
  104692. * @returns the current particle system
  104693. */
  104694. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104695. /**
  104696. * Remove a specific limit velocity gradient
  104697. * @param gradient defines the gradient to remove
  104698. * @returns the current particle system
  104699. */
  104700. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104701. /**
  104702. * Adds a new drag gradient
  104703. * @param gradient defines the gradient to use (between 0 and 1)
  104704. * @param factor defines the drag value to affect to the specified gradient
  104705. * @returns the current particle system
  104706. */
  104707. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104708. /**
  104709. * Remove a specific drag gradient
  104710. * @param gradient defines the gradient to remove
  104711. * @returns the current particle system
  104712. */
  104713. removeDragGradient(gradient: number): GPUParticleSystem;
  104714. /**
  104715. * Not supported by GPUParticleSystem
  104716. * @param gradient defines the gradient to use (between 0 and 1)
  104717. * @param factor defines the emit rate value to affect to the specified gradient
  104718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104719. * @returns the current particle system
  104720. */
  104721. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104722. /**
  104723. * Not supported by GPUParticleSystem
  104724. * @param gradient defines the gradient to remove
  104725. * @returns the current particle system
  104726. */
  104727. removeEmitRateGradient(gradient: number): IParticleSystem;
  104728. /**
  104729. * Not supported by GPUParticleSystem
  104730. * @param gradient defines the gradient to use (between 0 and 1)
  104731. * @param factor defines the start size value to affect to the specified gradient
  104732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104733. * @returns the current particle system
  104734. */
  104735. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104736. /**
  104737. * Not supported by GPUParticleSystem
  104738. * @param gradient defines the gradient to remove
  104739. * @returns the current particle system
  104740. */
  104741. removeStartSizeGradient(gradient: number): IParticleSystem;
  104742. /**
  104743. * Not supported by GPUParticleSystem
  104744. * @param gradient defines the gradient to use (between 0 and 1)
  104745. * @param min defines the color remap minimal range
  104746. * @param max defines the color remap maximal range
  104747. * @returns the current particle system
  104748. */
  104749. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104750. /**
  104751. * Not supported by GPUParticleSystem
  104752. * @param gradient defines the gradient to remove
  104753. * @returns the current particle system
  104754. */
  104755. removeColorRemapGradient(): IParticleSystem;
  104756. /**
  104757. * Not supported by GPUParticleSystem
  104758. * @param gradient defines the gradient to use (between 0 and 1)
  104759. * @param min defines the alpha remap minimal range
  104760. * @param max defines the alpha remap maximal range
  104761. * @returns the current particle system
  104762. */
  104763. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104764. /**
  104765. * Not supported by GPUParticleSystem
  104766. * @param gradient defines the gradient to remove
  104767. * @returns the current particle system
  104768. */
  104769. removeAlphaRemapGradient(): IParticleSystem;
  104770. /**
  104771. * Not supported by GPUParticleSystem
  104772. * @param gradient defines the gradient to use (between 0 and 1)
  104773. * @param color defines the color to affect to the specified gradient
  104774. * @returns the current particle system
  104775. */
  104776. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104777. /**
  104778. * Not supported by GPUParticleSystem
  104779. * @param gradient defines the gradient to remove
  104780. * @returns the current particle system
  104781. */
  104782. removeRampGradient(): IParticleSystem;
  104783. /**
  104784. * Not supported by GPUParticleSystem
  104785. * @returns the list of ramp gradients
  104786. */
  104787. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104788. /**
  104789. * Not supported by GPUParticleSystem
  104790. * Gets or sets a boolean indicating that ramp gradients must be used
  104791. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104792. */
  104793. useRampGradients: boolean;
  104794. /**
  104795. * Not supported by GPUParticleSystem
  104796. * @param gradient defines the gradient to use (between 0 and 1)
  104797. * @param factor defines the life time factor to affect to the specified gradient
  104798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104799. * @returns the current particle system
  104800. */
  104801. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104802. /**
  104803. * Not supported by GPUParticleSystem
  104804. * @param gradient defines the gradient to remove
  104805. * @returns the current particle system
  104806. */
  104807. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104808. /**
  104809. * Instantiates a GPU particle system.
  104810. * 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.
  104811. * @param name The name of the particle system
  104812. * @param options The options used to create the system
  104813. * @param scene The scene the particle system belongs to
  104814. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104815. */
  104816. constructor(name: string, options: Partial<{
  104817. capacity: number;
  104818. randomTextureSize: number;
  104819. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104820. protected _reset(): void;
  104821. private _createUpdateVAO;
  104822. private _createRenderVAO;
  104823. private _initialize;
  104824. /** @hidden */
  104825. _recreateUpdateEffect(): void;
  104826. /** @hidden */
  104827. _recreateRenderEffect(): void;
  104828. /**
  104829. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104830. * @param preWarm defines if we are in the pre-warmimg phase
  104831. */
  104832. animate(preWarm?: boolean): void;
  104833. private _createFactorGradientTexture;
  104834. private _createSizeGradientTexture;
  104835. private _createAngularSpeedGradientTexture;
  104836. private _createVelocityGradientTexture;
  104837. private _createLimitVelocityGradientTexture;
  104838. private _createDragGradientTexture;
  104839. private _createColorGradientTexture;
  104840. /**
  104841. * Renders the particle system in its current state
  104842. * @param preWarm defines if the system should only update the particles but not render them
  104843. * @returns the current number of particles
  104844. */
  104845. render(preWarm?: boolean): number;
  104846. /**
  104847. * Rebuilds the particle system
  104848. */
  104849. rebuild(): void;
  104850. private _releaseBuffers;
  104851. private _releaseVAOs;
  104852. /**
  104853. * Disposes the particle system and free the associated resources
  104854. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104855. */
  104856. dispose(disposeTexture?: boolean): void;
  104857. /**
  104858. * Clones the particle system.
  104859. * @param name The name of the cloned object
  104860. * @param newEmitter The new emitter to use
  104861. * @returns the cloned particle system
  104862. */
  104863. clone(name: string, newEmitter: any): GPUParticleSystem;
  104864. /**
  104865. * Serializes the particle system to a JSON object.
  104866. * @returns the JSON object
  104867. */
  104868. serialize(): any;
  104869. /**
  104870. * Parses a JSON object to create a GPU particle system.
  104871. * @param parsedParticleSystem The JSON object to parse
  104872. * @param scene The scene to create the particle system in
  104873. * @param rootUrl The root url to use to load external dependencies like texture
  104874. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104875. * @returns the parsed GPU particle system
  104876. */
  104877. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104878. }
  104879. }
  104880. declare module BABYLON {
  104881. /**
  104882. * Represents a set of particle systems working together to create a specific effect
  104883. */
  104884. export class ParticleSystemSet implements IDisposable {
  104885. private _emitterCreationOptions;
  104886. private _emitterNode;
  104887. /**
  104888. * Gets the particle system list
  104889. */
  104890. systems: IParticleSystem[];
  104891. /**
  104892. * Gets the emitter node used with this set
  104893. */
  104894. readonly emitterNode: Nullable<TransformNode>;
  104895. /**
  104896. * Creates a new emitter mesh as a sphere
  104897. * @param options defines the options used to create the sphere
  104898. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104899. * @param scene defines the hosting scene
  104900. */
  104901. setEmitterAsSphere(options: {
  104902. diameter: number;
  104903. segments: number;
  104904. color: Color3;
  104905. }, renderingGroupId: number, scene: Scene): void;
  104906. /**
  104907. * Starts all particle systems of the set
  104908. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104909. */
  104910. start(emitter?: AbstractMesh): void;
  104911. /**
  104912. * Release all associated resources
  104913. */
  104914. dispose(): void;
  104915. /**
  104916. * Serialize the set into a JSON compatible object
  104917. * @returns a JSON compatible representation of the set
  104918. */
  104919. serialize(): any;
  104920. /**
  104921. * Parse a new ParticleSystemSet from a serialized source
  104922. * @param data defines a JSON compatible representation of the set
  104923. * @param scene defines the hosting scene
  104924. * @param gpu defines if we want GPU particles or CPU particles
  104925. * @returns a new ParticleSystemSet
  104926. */
  104927. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104928. }
  104929. }
  104930. declare module BABYLON {
  104931. /**
  104932. * This class is made for on one-liner static method to help creating particle system set.
  104933. */
  104934. export class ParticleHelper {
  104935. /**
  104936. * Gets or sets base Assets URL
  104937. */
  104938. static BaseAssetsUrl: string;
  104939. /**
  104940. * Create a default particle system that you can tweak
  104941. * @param emitter defines the emitter to use
  104942. * @param capacity defines the system capacity (default is 500 particles)
  104943. * @param scene defines the hosting scene
  104944. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104945. * @returns the new Particle system
  104946. */
  104947. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  104948. /**
  104949. * This is the main static method (one-liner) of this helper to create different particle systems
  104950. * @param type This string represents the type to the particle system to create
  104951. * @param scene The scene where the particle system should live
  104952. * @param gpu If the system will use gpu
  104953. * @returns the ParticleSystemSet created
  104954. */
  104955. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  104956. /**
  104957. * Static function used to export a particle system to a ParticleSystemSet variable.
  104958. * Please note that the emitter shape is not exported
  104959. * @param systems defines the particle systems to export
  104960. * @returns the created particle system set
  104961. */
  104962. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  104963. }
  104964. }
  104965. declare module BABYLON {
  104966. interface Engine {
  104967. /**
  104968. * Create an effect to use with particle systems.
  104969. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  104970. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  104971. * @param uniformsNames defines a list of attribute names
  104972. * @param samplers defines an array of string used to represent textures
  104973. * @param defines defines the string containing the defines to use to compile the shaders
  104974. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104975. * @param onCompiled defines a function to call when the effect creation is successful
  104976. * @param onError defines a function to call when the effect creation has failed
  104977. * @returns the new Effect
  104978. */
  104979. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  104980. }
  104981. interface Mesh {
  104982. /**
  104983. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  104984. * @returns an array of IParticleSystem
  104985. */
  104986. getEmittedParticleSystems(): IParticleSystem[];
  104987. /**
  104988. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  104989. * @returns an array of IParticleSystem
  104990. */
  104991. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  104992. }
  104993. /**
  104994. * @hidden
  104995. */
  104996. export var _IDoNeedToBeInTheBuild: number;
  104997. }
  104998. declare module BABYLON {
  104999. interface Scene {
  105000. /** @hidden (Backing field) */
  105001. _physicsEngine: Nullable<IPhysicsEngine>;
  105002. /**
  105003. * Gets the current physics engine
  105004. * @returns a IPhysicsEngine or null if none attached
  105005. */
  105006. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105007. /**
  105008. * Enables physics to the current scene
  105009. * @param gravity defines the scene's gravity for the physics engine
  105010. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105011. * @return a boolean indicating if the physics engine was initialized
  105012. */
  105013. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105014. /**
  105015. * Disables and disposes the physics engine associated with the scene
  105016. */
  105017. disablePhysicsEngine(): void;
  105018. /**
  105019. * Gets a boolean indicating if there is an active physics engine
  105020. * @returns a boolean indicating if there is an active physics engine
  105021. */
  105022. isPhysicsEnabled(): boolean;
  105023. /**
  105024. * Deletes a physics compound impostor
  105025. * @param compound defines the compound to delete
  105026. */
  105027. deleteCompoundImpostor(compound: any): void;
  105028. /**
  105029. * An event triggered when physic simulation is about to be run
  105030. */
  105031. onBeforePhysicsObservable: Observable<Scene>;
  105032. /**
  105033. * An event triggered when physic simulation has been done
  105034. */
  105035. onAfterPhysicsObservable: Observable<Scene>;
  105036. }
  105037. interface AbstractMesh {
  105038. /** @hidden */
  105039. _physicsImpostor: Nullable<PhysicsImpostor>;
  105040. /**
  105041. * Gets or sets impostor used for physic simulation
  105042. * @see http://doc.babylonjs.com/features/physics_engine
  105043. */
  105044. physicsImpostor: Nullable<PhysicsImpostor>;
  105045. /**
  105046. * Gets the current physics impostor
  105047. * @see http://doc.babylonjs.com/features/physics_engine
  105048. * @returns a physics impostor or null
  105049. */
  105050. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105051. /** Apply a physic impulse to the mesh
  105052. * @param force defines the force to apply
  105053. * @param contactPoint defines where to apply the force
  105054. * @returns the current mesh
  105055. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105056. */
  105057. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105058. /**
  105059. * Creates a physic joint between two meshes
  105060. * @param otherMesh defines the other mesh to use
  105061. * @param pivot1 defines the pivot to use on this mesh
  105062. * @param pivot2 defines the pivot to use on the other mesh
  105063. * @param options defines additional options (can be plugin dependent)
  105064. * @returns the current mesh
  105065. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105066. */
  105067. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105068. /** @hidden */
  105069. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105070. }
  105071. /**
  105072. * Defines the physics engine scene component responsible to manage a physics engine
  105073. */
  105074. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105075. /**
  105076. * The component name helpful to identify the component in the list of scene components.
  105077. */
  105078. readonly name: string;
  105079. /**
  105080. * The scene the component belongs to.
  105081. */
  105082. scene: Scene;
  105083. /**
  105084. * Creates a new instance of the component for the given scene
  105085. * @param scene Defines the scene to register the component in
  105086. */
  105087. constructor(scene: Scene);
  105088. /**
  105089. * Registers the component in a given scene
  105090. */
  105091. register(): void;
  105092. /**
  105093. * Rebuilds the elements related to this component in case of
  105094. * context lost for instance.
  105095. */
  105096. rebuild(): void;
  105097. /**
  105098. * Disposes the component and the associated ressources
  105099. */
  105100. dispose(): void;
  105101. }
  105102. }
  105103. declare module BABYLON {
  105104. /**
  105105. * A helper for physics simulations
  105106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105107. */
  105108. export class PhysicsHelper {
  105109. private _scene;
  105110. private _physicsEngine;
  105111. /**
  105112. * Initializes the Physics helper
  105113. * @param scene Babylon.js scene
  105114. */
  105115. constructor(scene: Scene);
  105116. /**
  105117. * Applies a radial explosion impulse
  105118. * @param origin the origin of the explosion
  105119. * @param radius the explosion radius
  105120. * @param strength the explosion strength
  105121. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105122. * @returns A physics radial explosion event, or null
  105123. */
  105124. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105125. /**
  105126. * Applies a radial explosion force
  105127. * @param origin the origin of the explosion
  105128. * @param radius the explosion radius
  105129. * @param strength the explosion strength
  105130. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105131. * @returns A physics radial explosion event, or null
  105132. */
  105133. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105134. /**
  105135. * Creates a gravitational field
  105136. * @param origin the origin of the explosion
  105137. * @param radius the explosion radius
  105138. * @param strength the explosion strength
  105139. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105140. * @returns A physics gravitational field event, or null
  105141. */
  105142. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105143. /**
  105144. * Creates a physics updraft event
  105145. * @param origin the origin of the updraft
  105146. * @param radius the radius of the updraft
  105147. * @param strength the strength of the updraft
  105148. * @param height the height of the updraft
  105149. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105150. * @returns A physics updraft event, or null
  105151. */
  105152. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105153. /**
  105154. * Creates a physics vortex event
  105155. * @param origin the of the vortex
  105156. * @param radius the radius of the vortex
  105157. * @param strength the strength of the vortex
  105158. * @param height the height of the vortex
  105159. * @returns a Physics vortex event, or null
  105160. * A physics vortex event or null
  105161. */
  105162. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105163. }
  105164. /**
  105165. * Represents a physics radial explosion event
  105166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105167. */
  105168. export class PhysicsRadialExplosionEvent {
  105169. private _scene;
  105170. private _sphere;
  105171. private _sphereOptions;
  105172. private _rays;
  105173. private _dataFetched;
  105174. /**
  105175. * Initializes a radial explosioin event
  105176. * @param scene BabylonJS scene
  105177. */
  105178. constructor(scene: Scene);
  105179. /**
  105180. * Returns the data related to the radial explosion event (sphere & rays).
  105181. * @returns The radial explosion event data
  105182. */
  105183. getData(): PhysicsRadialExplosionEventData;
  105184. /**
  105185. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105186. * @param impostor A physics imposter
  105187. * @param origin the origin of the explosion
  105188. * @param radius the explosion radius
  105189. * @param strength the explosion strength
  105190. * @param falloff possible options: Constant & Linear
  105191. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105192. */
  105193. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105194. /**
  105195. * Disposes the sphere.
  105196. * @param force Specifies if the sphere should be disposed by force
  105197. */
  105198. dispose(force?: boolean): void;
  105199. /*** Helpers ***/
  105200. private _prepareSphere;
  105201. private _intersectsWithSphere;
  105202. }
  105203. /**
  105204. * Represents a gravitational field event
  105205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105206. */
  105207. export class PhysicsGravitationalFieldEvent {
  105208. private _physicsHelper;
  105209. private _scene;
  105210. private _origin;
  105211. private _radius;
  105212. private _strength;
  105213. private _falloff;
  105214. private _tickCallback;
  105215. private _sphere;
  105216. private _dataFetched;
  105217. /**
  105218. * Initializes the physics gravitational field event
  105219. * @param physicsHelper A physics helper
  105220. * @param scene BabylonJS scene
  105221. * @param origin The origin position of the gravitational field event
  105222. * @param radius The radius of the gravitational field event
  105223. * @param strength The strength of the gravitational field event
  105224. * @param falloff The falloff for the gravitational field event
  105225. */
  105226. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105227. /**
  105228. * Returns the data related to the gravitational field event (sphere).
  105229. * @returns A gravitational field event
  105230. */
  105231. getData(): PhysicsGravitationalFieldEventData;
  105232. /**
  105233. * Enables the gravitational field.
  105234. */
  105235. enable(): void;
  105236. /**
  105237. * Disables the gravitational field.
  105238. */
  105239. disable(): void;
  105240. /**
  105241. * Disposes the sphere.
  105242. * @param force The force to dispose from the gravitational field event
  105243. */
  105244. dispose(force?: boolean): void;
  105245. private _tick;
  105246. }
  105247. /**
  105248. * Represents a physics updraft event
  105249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105250. */
  105251. export class PhysicsUpdraftEvent {
  105252. private _scene;
  105253. private _origin;
  105254. private _radius;
  105255. private _strength;
  105256. private _height;
  105257. private _updraftMode;
  105258. private _physicsEngine;
  105259. private _originTop;
  105260. private _originDirection;
  105261. private _tickCallback;
  105262. private _cylinder;
  105263. private _cylinderPosition;
  105264. private _dataFetched;
  105265. /**
  105266. * Initializes the physics updraft event
  105267. * @param _scene BabylonJS scene
  105268. * @param _origin The origin position of the updraft
  105269. * @param _radius The radius of the updraft
  105270. * @param _strength The strength of the updraft
  105271. * @param _height The height of the updraft
  105272. * @param _updraftMode The mode of the updraft
  105273. */
  105274. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105275. /**
  105276. * Returns the data related to the updraft event (cylinder).
  105277. * @returns A physics updraft event
  105278. */
  105279. getData(): PhysicsUpdraftEventData;
  105280. /**
  105281. * Enables the updraft.
  105282. */
  105283. enable(): void;
  105284. /**
  105285. * Disables the cortex.
  105286. */
  105287. disable(): void;
  105288. /**
  105289. * Disposes the sphere.
  105290. * @param force Specifies if the updraft should be disposed by force
  105291. */
  105292. dispose(force?: boolean): void;
  105293. private getImpostorForceAndContactPoint;
  105294. private _tick;
  105295. /*** Helpers ***/
  105296. private _prepareCylinder;
  105297. private _intersectsWithCylinder;
  105298. }
  105299. /**
  105300. * Represents a physics vortex event
  105301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105302. */
  105303. export class PhysicsVortexEvent {
  105304. private _scene;
  105305. private _origin;
  105306. private _radius;
  105307. private _strength;
  105308. private _height;
  105309. private _physicsEngine;
  105310. private _originTop;
  105311. private _centripetalForceThreshold;
  105312. private _updraftMultiplier;
  105313. private _tickCallback;
  105314. private _cylinder;
  105315. private _cylinderPosition;
  105316. private _dataFetched;
  105317. /**
  105318. * Initializes the physics vortex event
  105319. * @param _scene The BabylonJS scene
  105320. * @param _origin The origin position of the vortex
  105321. * @param _radius The radius of the vortex
  105322. * @param _strength The strength of the vortex
  105323. * @param _height The height of the vortex
  105324. */
  105325. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105326. /**
  105327. * Returns the data related to the vortex event (cylinder).
  105328. * @returns The physics vortex event data
  105329. */
  105330. getData(): PhysicsVortexEventData;
  105331. /**
  105332. * Enables the vortex.
  105333. */
  105334. enable(): void;
  105335. /**
  105336. * Disables the cortex.
  105337. */
  105338. disable(): void;
  105339. /**
  105340. * Disposes the sphere.
  105341. * @param force
  105342. */
  105343. dispose(force?: boolean): void;
  105344. private getImpostorForceAndContactPoint;
  105345. private _tick;
  105346. /*** Helpers ***/
  105347. private _prepareCylinder;
  105348. private _intersectsWithCylinder;
  105349. }
  105350. /**
  105351. * The strenght of the force in correspondence to the distance of the affected object
  105352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105353. */
  105354. export enum PhysicsRadialImpulseFalloff {
  105355. /** Defines that impulse is constant in strength across it's whole radius */
  105356. Constant = 0,
  105357. /** DEfines that impulse gets weaker if it's further from the origin */
  105358. Linear = 1
  105359. }
  105360. /**
  105361. * The strength of the force in correspondence to the distance of the affected object
  105362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105363. */
  105364. export enum PhysicsUpdraftMode {
  105365. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105366. Center = 0,
  105367. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105368. Perpendicular = 1
  105369. }
  105370. /**
  105371. * Interface for a physics force and contact point
  105372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105373. */
  105374. export interface PhysicsForceAndContactPoint {
  105375. /**
  105376. * The force applied at the contact point
  105377. */
  105378. force: Vector3;
  105379. /**
  105380. * The contact point
  105381. */
  105382. contactPoint: Vector3;
  105383. }
  105384. /**
  105385. * Interface for radial explosion event data
  105386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105387. */
  105388. export interface PhysicsRadialExplosionEventData {
  105389. /**
  105390. * A sphere used for the radial explosion event
  105391. */
  105392. sphere: Mesh;
  105393. /**
  105394. * An array of rays for the radial explosion event
  105395. */
  105396. rays: Array<Ray>;
  105397. }
  105398. /**
  105399. * Interface for gravitational field event data
  105400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105401. */
  105402. export interface PhysicsGravitationalFieldEventData {
  105403. /**
  105404. * A sphere mesh used for the gravitational field event
  105405. */
  105406. sphere: Mesh;
  105407. }
  105408. /**
  105409. * Interface for updraft event data
  105410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105411. */
  105412. export interface PhysicsUpdraftEventData {
  105413. /**
  105414. * A cylinder used for the updraft event
  105415. */
  105416. cylinder: Mesh;
  105417. }
  105418. /**
  105419. * Interface for vortex event data
  105420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105421. */
  105422. export interface PhysicsVortexEventData {
  105423. /**
  105424. * A cylinder used for the vortex event
  105425. */
  105426. cylinder: Mesh;
  105427. }
  105428. }
  105429. declare module BABYLON {
  105430. /**
  105431. * AmmoJS Physics plugin
  105432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105433. * @see https://github.com/kripken/ammo.js/
  105434. */
  105435. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105436. private _useDeltaForWorldStep;
  105437. /**
  105438. * Reference to the Ammo library
  105439. */
  105440. bjsAMMO: any;
  105441. /**
  105442. * Created ammoJS world which physics bodies are added to
  105443. */
  105444. world: any;
  105445. /**
  105446. * Name of the plugin
  105447. */
  105448. name: string;
  105449. private _timeStep;
  105450. private _fixedTimeStep;
  105451. private _maxSteps;
  105452. private _tmpQuaternion;
  105453. private _tmpAmmoTransform;
  105454. private _tmpAmmoQuaternion;
  105455. private _tmpAmmoConcreteContactResultCallback;
  105456. private _collisionConfiguration;
  105457. private _dispatcher;
  105458. private _overlappingPairCache;
  105459. private _solver;
  105460. private _tmpAmmoVectorA;
  105461. private _tmpAmmoVectorB;
  105462. private _tmpAmmoVectorC;
  105463. private _tmpContactCallbackResult;
  105464. private static readonly DISABLE_COLLISION_FLAG;
  105465. private static readonly KINEMATIC_FLAG;
  105466. private static readonly DISABLE_DEACTIVATION_FLAG;
  105467. /**
  105468. * Initializes the ammoJS plugin
  105469. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105470. * @param ammoInjection can be used to inject your own ammo reference
  105471. */
  105472. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105473. /**
  105474. * Sets the gravity of the physics world (m/(s^2))
  105475. * @param gravity Gravity to set
  105476. */
  105477. setGravity(gravity: Vector3): void;
  105478. /**
  105479. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105480. * @param timeStep timestep to use in seconds
  105481. */
  105482. setTimeStep(timeStep: number): void;
  105483. /**
  105484. * 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)
  105485. * @param fixedTimeStep fixedTimeStep to use in seconds
  105486. */
  105487. setFixedTimeStep(fixedTimeStep: number): void;
  105488. /**
  105489. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105490. * @param maxSteps the maximum number of steps by the physics engine per frame
  105491. */
  105492. setMaxSteps(maxSteps: number): void;
  105493. /**
  105494. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105495. * @returns the current timestep in seconds
  105496. */
  105497. getTimeStep(): number;
  105498. private _isImpostorInContact;
  105499. private _isImpostorPairInContact;
  105500. private _stepSimulation;
  105501. /**
  105502. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105503. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105504. * After the step the babylon meshes are set to the position of the physics imposters
  105505. * @param delta amount of time to step forward
  105506. * @param impostors array of imposters to update before/after the step
  105507. */
  105508. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105509. private _tmpVector;
  105510. private _tmpMatrix;
  105511. /**
  105512. * Applies an implulse on the imposter
  105513. * @param impostor imposter to apply impulse
  105514. * @param force amount of force to be applied to the imposter
  105515. * @param contactPoint the location to apply the impulse on the imposter
  105516. */
  105517. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105518. /**
  105519. * Applies a force on the imposter
  105520. * @param impostor imposter to apply force
  105521. * @param force amount of force to be applied to the imposter
  105522. * @param contactPoint the location to apply the force on the imposter
  105523. */
  105524. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105525. /**
  105526. * Creates a physics body using the plugin
  105527. * @param impostor the imposter to create the physics body on
  105528. */
  105529. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105530. /**
  105531. * Removes the physics body from the imposter and disposes of the body's memory
  105532. * @param impostor imposter to remove the physics body from
  105533. */
  105534. removePhysicsBody(impostor: PhysicsImpostor): void;
  105535. /**
  105536. * Generates a joint
  105537. * @param impostorJoint the imposter joint to create the joint with
  105538. */
  105539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105540. /**
  105541. * Removes a joint
  105542. * @param impostorJoint the imposter joint to remove the joint from
  105543. */
  105544. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105545. private _addMeshVerts;
  105546. private _createShape;
  105547. /**
  105548. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105549. * @param impostor imposter containing the physics body and babylon object
  105550. */
  105551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105552. /**
  105553. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105554. * @param impostor imposter containing the physics body and babylon object
  105555. * @param newPosition new position
  105556. * @param newRotation new rotation
  105557. */
  105558. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105559. /**
  105560. * If this plugin is supported
  105561. * @returns true if its supported
  105562. */
  105563. isSupported(): boolean;
  105564. /**
  105565. * Sets the linear velocity of the physics body
  105566. * @param impostor imposter to set the velocity on
  105567. * @param velocity velocity to set
  105568. */
  105569. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105570. /**
  105571. * Sets the angular velocity of the physics body
  105572. * @param impostor imposter to set the velocity on
  105573. * @param velocity velocity to set
  105574. */
  105575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105576. /**
  105577. * gets the linear velocity
  105578. * @param impostor imposter to get linear velocity from
  105579. * @returns linear velocity
  105580. */
  105581. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105582. /**
  105583. * gets the angular velocity
  105584. * @param impostor imposter to get angular velocity from
  105585. * @returns angular velocity
  105586. */
  105587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105588. /**
  105589. * Sets the mass of physics body
  105590. * @param impostor imposter to set the mass on
  105591. * @param mass mass to set
  105592. */
  105593. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105594. /**
  105595. * Gets the mass of the physics body
  105596. * @param impostor imposter to get the mass from
  105597. * @returns mass
  105598. */
  105599. getBodyMass(impostor: PhysicsImpostor): number;
  105600. /**
  105601. * Gets friction of the impostor
  105602. * @param impostor impostor to get friction from
  105603. * @returns friction value
  105604. */
  105605. getBodyFriction(impostor: PhysicsImpostor): number;
  105606. /**
  105607. * Sets friction of the impostor
  105608. * @param impostor impostor to set friction on
  105609. * @param friction friction value
  105610. */
  105611. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105612. /**
  105613. * Gets restitution of the impostor
  105614. * @param impostor impostor to get restitution from
  105615. * @returns restitution value
  105616. */
  105617. getBodyRestitution(impostor: PhysicsImpostor): number;
  105618. /**
  105619. * Sets resitution of the impostor
  105620. * @param impostor impostor to set resitution on
  105621. * @param restitution resitution value
  105622. */
  105623. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105624. /**
  105625. * Sleeps the physics body and stops it from being active
  105626. * @param impostor impostor to sleep
  105627. */
  105628. sleepBody(impostor: PhysicsImpostor): void;
  105629. /**
  105630. * Activates the physics body
  105631. * @param impostor impostor to activate
  105632. */
  105633. wakeUpBody(impostor: PhysicsImpostor): void;
  105634. /**
  105635. * Updates the distance parameters of the joint
  105636. * @param joint joint to update
  105637. * @param maxDistance maximum distance of the joint
  105638. * @param minDistance minimum distance of the joint
  105639. */
  105640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105641. /**
  105642. * Sets a motor on the joint
  105643. * @param joint joint to set motor on
  105644. * @param speed speed of the motor
  105645. * @param maxForce maximum force of the motor
  105646. * @param motorIndex index of the motor
  105647. */
  105648. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105649. /**
  105650. * Sets the motors limit
  105651. * @param joint joint to set limit on
  105652. * @param upperLimit upper limit
  105653. * @param lowerLimit lower limit
  105654. */
  105655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105656. /**
  105657. * Syncs the position and rotation of a mesh with the impostor
  105658. * @param mesh mesh to sync
  105659. * @param impostor impostor to update the mesh with
  105660. */
  105661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105662. /**
  105663. * Gets the radius of the impostor
  105664. * @param impostor impostor to get radius from
  105665. * @returns the radius
  105666. */
  105667. getRadius(impostor: PhysicsImpostor): number;
  105668. /**
  105669. * Gets the box size of the impostor
  105670. * @param impostor impostor to get box size from
  105671. * @param result the resulting box size
  105672. */
  105673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105674. /**
  105675. * Disposes of the impostor
  105676. */
  105677. dispose(): void;
  105678. }
  105679. }
  105680. declare module BABYLON {
  105681. /** @hidden */
  105682. export var blackAndWhitePixelShader: {
  105683. name: string;
  105684. shader: string;
  105685. };
  105686. }
  105687. declare module BABYLON {
  105688. /**
  105689. * Post process used to render in black and white
  105690. */
  105691. export class BlackAndWhitePostProcess extends PostProcess {
  105692. /**
  105693. * Linear about to convert he result to black and white (default: 1)
  105694. */
  105695. degree: number;
  105696. /**
  105697. * Creates a black and white post process
  105698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105699. * @param name The name of the effect.
  105700. * @param options The required width/height ratio to downsize to before computing the render pass.
  105701. * @param camera The camera to apply the render pass to.
  105702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105703. * @param engine The engine which the post process will be applied. (default: current engine)
  105704. * @param reusable If the post process can be reused on the same frame. (default: false)
  105705. */
  105706. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105707. }
  105708. }
  105709. declare module BABYLON {
  105710. /**
  105711. * This represents a set of one or more post processes in Babylon.
  105712. * A post process can be used to apply a shader to a texture after it is rendered.
  105713. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105714. */
  105715. export class PostProcessRenderEffect {
  105716. private _postProcesses;
  105717. private _getPostProcesses;
  105718. private _singleInstance;
  105719. private _cameras;
  105720. private _indicesForCamera;
  105721. /**
  105722. * Name of the effect
  105723. * @hidden
  105724. */
  105725. _name: string;
  105726. /**
  105727. * Instantiates a post process render effect.
  105728. * A post process can be used to apply a shader to a texture after it is rendered.
  105729. * @param engine The engine the effect is tied to
  105730. * @param name The name of the effect
  105731. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105732. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105733. */
  105734. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105735. /**
  105736. * Checks if all the post processes in the effect are supported.
  105737. */
  105738. readonly isSupported: boolean;
  105739. /**
  105740. * Updates the current state of the effect
  105741. * @hidden
  105742. */
  105743. _update(): void;
  105744. /**
  105745. * Attaches the effect on cameras
  105746. * @param cameras The camera to attach to.
  105747. * @hidden
  105748. */
  105749. _attachCameras(cameras: Camera): void;
  105750. /**
  105751. * Attaches the effect on cameras
  105752. * @param cameras The camera to attach to.
  105753. * @hidden
  105754. */
  105755. _attachCameras(cameras: Camera[]): void;
  105756. /**
  105757. * Detatches the effect on cameras
  105758. * @param cameras The camera to detatch from.
  105759. * @hidden
  105760. */
  105761. _detachCameras(cameras: Camera): void;
  105762. /**
  105763. * Detatches the effect on cameras
  105764. * @param cameras The camera to detatch from.
  105765. * @hidden
  105766. */
  105767. _detachCameras(cameras: Camera[]): void;
  105768. /**
  105769. * Enables the effect on given cameras
  105770. * @param cameras The camera to enable.
  105771. * @hidden
  105772. */
  105773. _enable(cameras: Camera): void;
  105774. /**
  105775. * Enables the effect on given cameras
  105776. * @param cameras The camera to enable.
  105777. * @hidden
  105778. */
  105779. _enable(cameras: Nullable<Camera[]>): void;
  105780. /**
  105781. * Disables the effect on the given cameras
  105782. * @param cameras The camera to disable.
  105783. * @hidden
  105784. */
  105785. _disable(cameras: Camera): void;
  105786. /**
  105787. * Disables the effect on the given cameras
  105788. * @param cameras The camera to disable.
  105789. * @hidden
  105790. */
  105791. _disable(cameras: Nullable<Camera[]>): void;
  105792. /**
  105793. * Gets a list of the post processes contained in the effect.
  105794. * @param camera The camera to get the post processes on.
  105795. * @returns The list of the post processes in the effect.
  105796. */
  105797. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105798. }
  105799. }
  105800. declare module BABYLON {
  105801. /** @hidden */
  105802. export var extractHighlightsPixelShader: {
  105803. name: string;
  105804. shader: string;
  105805. };
  105806. }
  105807. declare module BABYLON {
  105808. /**
  105809. * 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.
  105810. */
  105811. export class ExtractHighlightsPostProcess extends PostProcess {
  105812. /**
  105813. * The luminance threshold, pixels below this value will be set to black.
  105814. */
  105815. threshold: number;
  105816. /** @hidden */
  105817. _exposure: number;
  105818. /**
  105819. * Post process which has the input texture to be used when performing highlight extraction
  105820. * @hidden
  105821. */
  105822. _inputPostProcess: Nullable<PostProcess>;
  105823. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105824. }
  105825. }
  105826. declare module BABYLON {
  105827. /** @hidden */
  105828. export var bloomMergePixelShader: {
  105829. name: string;
  105830. shader: string;
  105831. };
  105832. }
  105833. declare module BABYLON {
  105834. /**
  105835. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105836. */
  105837. export class BloomMergePostProcess extends PostProcess {
  105838. /** Weight of the bloom to be added to the original input. */
  105839. weight: number;
  105840. /**
  105841. * Creates a new instance of @see BloomMergePostProcess
  105842. * @param name The name of the effect.
  105843. * @param originalFromInput Post process which's input will be used for the merge.
  105844. * @param blurred Blurred highlights post process which's output will be used.
  105845. * @param weight Weight of the bloom to be added to the original input.
  105846. * @param options The required width/height ratio to downsize to before computing the render pass.
  105847. * @param camera The camera to apply the render pass to.
  105848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105849. * @param engine The engine which the post process will be applied. (default: current engine)
  105850. * @param reusable If the post process can be reused on the same frame. (default: false)
  105851. * @param textureType Type of textures used when performing the post process. (default: 0)
  105852. * @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)
  105853. */
  105854. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105855. /** Weight of the bloom to be added to the original input. */
  105856. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105857. }
  105858. }
  105859. declare module BABYLON {
  105860. /**
  105861. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105862. */
  105863. export class BloomEffect extends PostProcessRenderEffect {
  105864. private bloomScale;
  105865. /**
  105866. * @hidden Internal
  105867. */
  105868. _effects: Array<PostProcess>;
  105869. /**
  105870. * @hidden Internal
  105871. */
  105872. _downscale: ExtractHighlightsPostProcess;
  105873. private _blurX;
  105874. private _blurY;
  105875. private _merge;
  105876. /**
  105877. * The luminance threshold to find bright areas of the image to bloom.
  105878. */
  105879. threshold: number;
  105880. /**
  105881. * The strength of the bloom.
  105882. */
  105883. weight: number;
  105884. /**
  105885. * Specifies the size of the bloom blur kernel, relative to the final output size
  105886. */
  105887. kernel: number;
  105888. /**
  105889. * Creates a new instance of @see BloomEffect
  105890. * @param scene The scene the effect belongs to.
  105891. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105892. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105893. * @param bloomWeight The the strength of bloom.
  105894. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105895. * @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)
  105896. */
  105897. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105898. /**
  105899. * Disposes each of the internal effects for a given camera.
  105900. * @param camera The camera to dispose the effect on.
  105901. */
  105902. disposeEffects(camera: Camera): void;
  105903. /**
  105904. * @hidden Internal
  105905. */
  105906. _updateEffects(): void;
  105907. /**
  105908. * Internal
  105909. * @returns if all the contained post processes are ready.
  105910. * @hidden
  105911. */
  105912. _isReady(): boolean;
  105913. }
  105914. }
  105915. declare module BABYLON {
  105916. /** @hidden */
  105917. export var chromaticAberrationPixelShader: {
  105918. name: string;
  105919. shader: string;
  105920. };
  105921. }
  105922. declare module BABYLON {
  105923. /**
  105924. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105925. */
  105926. export class ChromaticAberrationPostProcess extends PostProcess {
  105927. /**
  105928. * The amount of seperation of rgb channels (default: 30)
  105929. */
  105930. aberrationAmount: number;
  105931. /**
  105932. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  105933. */
  105934. radialIntensity: number;
  105935. /**
  105936. * 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))
  105937. */
  105938. direction: Vector2;
  105939. /**
  105940. * 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))
  105941. */
  105942. centerPosition: Vector2;
  105943. /**
  105944. * Creates a new instance ChromaticAberrationPostProcess
  105945. * @param name The name of the effect.
  105946. * @param screenWidth The width of the screen to apply the effect on.
  105947. * @param screenHeight The height of the screen to apply the effect on.
  105948. * @param options The required width/height ratio to downsize to before computing the render pass.
  105949. * @param camera The camera to apply the render pass to.
  105950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105951. * @param engine The engine which the post process will be applied. (default: current engine)
  105952. * @param reusable If the post process can be reused on the same frame. (default: false)
  105953. * @param textureType Type of textures used when performing the post process. (default: 0)
  105954. * @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)
  105955. */
  105956. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105957. }
  105958. }
  105959. declare module BABYLON {
  105960. /** @hidden */
  105961. export var circleOfConfusionPixelShader: {
  105962. name: string;
  105963. shader: string;
  105964. };
  105965. }
  105966. declare module BABYLON {
  105967. /**
  105968. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  105969. */
  105970. export class CircleOfConfusionPostProcess extends PostProcess {
  105971. /**
  105972. * 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.
  105973. */
  105974. lensSize: number;
  105975. /**
  105976. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105977. */
  105978. fStop: number;
  105979. /**
  105980. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105981. */
  105982. focusDistance: number;
  105983. /**
  105984. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  105985. */
  105986. focalLength: number;
  105987. private _depthTexture;
  105988. /**
  105989. * Creates a new instance CircleOfConfusionPostProcess
  105990. * @param name The name of the effect.
  105991. * @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.
  105992. * @param options The required width/height ratio to downsize to before computing the render pass.
  105993. * @param camera The camera to apply the render pass to.
  105994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105995. * @param engine The engine which the post process will be applied. (default: current engine)
  105996. * @param reusable If the post process can be reused on the same frame. (default: false)
  105997. * @param textureType Type of textures used when performing the post process. (default: 0)
  105998. * @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)
  105999. */
  106000. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106001. /**
  106002. * 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.
  106003. */
  106004. depthTexture: RenderTargetTexture;
  106005. }
  106006. }
  106007. declare module BABYLON {
  106008. /** @hidden */
  106009. export var colorCorrectionPixelShader: {
  106010. name: string;
  106011. shader: string;
  106012. };
  106013. }
  106014. declare module BABYLON {
  106015. /**
  106016. *
  106017. * This post-process allows the modification of rendered colors by using
  106018. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106019. *
  106020. * The object needs to be provided an url to a texture containing the color
  106021. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106022. * Use an image editing software to tweak the LUT to match your needs.
  106023. *
  106024. * For an example of a color LUT, see here:
  106025. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106026. * For explanations on color grading, see here:
  106027. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106028. *
  106029. */
  106030. export class ColorCorrectionPostProcess extends PostProcess {
  106031. private _colorTableTexture;
  106032. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /** @hidden */
  106037. export var convolutionPixelShader: {
  106038. name: string;
  106039. shader: string;
  106040. };
  106041. }
  106042. declare module BABYLON {
  106043. /**
  106044. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106045. * input texture to perform effects such as edge detection or sharpening
  106046. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106047. */
  106048. export class ConvolutionPostProcess extends PostProcess {
  106049. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106050. kernel: number[];
  106051. /**
  106052. * Creates a new instance ConvolutionPostProcess
  106053. * @param name The name of the effect.
  106054. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106055. * @param options The required width/height ratio to downsize to before computing the render pass.
  106056. * @param camera The camera to apply the render pass to.
  106057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106058. * @param engine The engine which the post process will be applied. (default: current engine)
  106059. * @param reusable If the post process can be reused on the same frame. (default: false)
  106060. * @param textureType Type of textures used when performing the post process. (default: 0)
  106061. */
  106062. constructor(name: string,
  106063. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106064. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106065. /**
  106066. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106067. */
  106068. static EdgeDetect0Kernel: number[];
  106069. /**
  106070. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106071. */
  106072. static EdgeDetect1Kernel: number[];
  106073. /**
  106074. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106075. */
  106076. static EdgeDetect2Kernel: number[];
  106077. /**
  106078. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106079. */
  106080. static SharpenKernel: number[];
  106081. /**
  106082. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106083. */
  106084. static EmbossKernel: number[];
  106085. /**
  106086. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106087. */
  106088. static GaussianKernel: number[];
  106089. }
  106090. }
  106091. declare module BABYLON {
  106092. /**
  106093. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106094. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106095. * based on samples that have a large difference in distance than the center pixel.
  106096. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106097. */
  106098. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106099. direction: Vector2;
  106100. /**
  106101. * Creates a new instance CircleOfConfusionPostProcess
  106102. * @param name The name of the effect.
  106103. * @param scene The scene the effect belongs to.
  106104. * @param direction The direction the blur should be applied.
  106105. * @param kernel The size of the kernel used to blur.
  106106. * @param options The required width/height ratio to downsize to before computing the render pass.
  106107. * @param camera The camera to apply the render pass to.
  106108. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106109. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106111. * @param engine The engine which the post process will be applied. (default: current engine)
  106112. * @param reusable If the post process can be reused on the same frame. (default: false)
  106113. * @param textureType Type of textures used when performing the post process. (default: 0)
  106114. * @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)
  106115. */
  106116. 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);
  106117. }
  106118. }
  106119. declare module BABYLON {
  106120. /** @hidden */
  106121. export var depthOfFieldMergePixelShader: {
  106122. name: string;
  106123. shader: string;
  106124. };
  106125. }
  106126. declare module BABYLON {
  106127. /**
  106128. * Options to be set when merging outputs from the default pipeline.
  106129. */
  106130. export class DepthOfFieldMergePostProcessOptions {
  106131. /**
  106132. * The original image to merge on top of
  106133. */
  106134. originalFromInput: PostProcess;
  106135. /**
  106136. * Parameters to perform the merge of the depth of field effect
  106137. */
  106138. depthOfField?: {
  106139. circleOfConfusion: PostProcess;
  106140. blurSteps: Array<PostProcess>;
  106141. };
  106142. /**
  106143. * Parameters to perform the merge of bloom effect
  106144. */
  106145. bloom?: {
  106146. blurred: PostProcess;
  106147. weight: number;
  106148. };
  106149. }
  106150. /**
  106151. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106152. */
  106153. export class DepthOfFieldMergePostProcess extends PostProcess {
  106154. private blurSteps;
  106155. /**
  106156. * Creates a new instance of DepthOfFieldMergePostProcess
  106157. * @param name The name of the effect.
  106158. * @param originalFromInput Post process which's input will be used for the merge.
  106159. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106160. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106161. * @param options The required width/height ratio to downsize to before computing the render pass.
  106162. * @param camera The camera to apply the render pass to.
  106163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106164. * @param engine The engine which the post process will be applied. (default: current engine)
  106165. * @param reusable If the post process can be reused on the same frame. (default: false)
  106166. * @param textureType Type of textures used when performing the post process. (default: 0)
  106167. * @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)
  106168. */
  106169. 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);
  106170. /**
  106171. * Updates the effect with the current post process compile time values and recompiles the shader.
  106172. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106173. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106174. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106175. * @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
  106176. * @param onCompiled Called when the shader has been compiled.
  106177. * @param onError Called if there is an error when compiling a shader.
  106178. */
  106179. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106180. }
  106181. }
  106182. declare module BABYLON {
  106183. /**
  106184. * Specifies the level of max blur that should be applied when using the depth of field effect
  106185. */
  106186. export enum DepthOfFieldEffectBlurLevel {
  106187. /**
  106188. * Subtle blur
  106189. */
  106190. Low = 0,
  106191. /**
  106192. * Medium blur
  106193. */
  106194. Medium = 1,
  106195. /**
  106196. * Large blur
  106197. */
  106198. High = 2
  106199. }
  106200. /**
  106201. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106202. */
  106203. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106204. private _circleOfConfusion;
  106205. /**
  106206. * @hidden Internal, blurs from high to low
  106207. */
  106208. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106209. private _depthOfFieldBlurY;
  106210. private _dofMerge;
  106211. /**
  106212. * @hidden Internal post processes in depth of field effect
  106213. */
  106214. _effects: Array<PostProcess>;
  106215. /**
  106216. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106217. */
  106218. focalLength: number;
  106219. /**
  106220. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106221. */
  106222. fStop: number;
  106223. /**
  106224. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106225. */
  106226. focusDistance: number;
  106227. /**
  106228. * 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.
  106229. */
  106230. lensSize: number;
  106231. /**
  106232. * Creates a new instance DepthOfFieldEffect
  106233. * @param scene The scene the effect belongs to.
  106234. * @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.
  106235. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106236. * @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)
  106237. */
  106238. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106239. /**
  106240. * 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.
  106241. */
  106242. depthTexture: RenderTargetTexture;
  106243. /**
  106244. * Disposes each of the internal effects for a given camera.
  106245. * @param camera The camera to dispose the effect on.
  106246. */
  106247. disposeEffects(camera: Camera): void;
  106248. /**
  106249. * @hidden Internal
  106250. */
  106251. _updateEffects(): void;
  106252. /**
  106253. * Internal
  106254. * @returns if all the contained post processes are ready.
  106255. * @hidden
  106256. */
  106257. _isReady(): boolean;
  106258. }
  106259. }
  106260. declare module BABYLON {
  106261. /** @hidden */
  106262. export var displayPassPixelShader: {
  106263. name: string;
  106264. shader: string;
  106265. };
  106266. }
  106267. declare module BABYLON {
  106268. /**
  106269. * DisplayPassPostProcess which produces an output the same as it's input
  106270. */
  106271. export class DisplayPassPostProcess extends PostProcess {
  106272. /**
  106273. * Creates the DisplayPassPostProcess
  106274. * @param name The name of the effect.
  106275. * @param options The required width/height ratio to downsize to before computing the render pass.
  106276. * @param camera The camera to apply the render pass to.
  106277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106278. * @param engine The engine which the post process will be applied. (default: current engine)
  106279. * @param reusable If the post process can be reused on the same frame. (default: false)
  106280. */
  106281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106282. }
  106283. }
  106284. declare module BABYLON {
  106285. /** @hidden */
  106286. export var filterPixelShader: {
  106287. name: string;
  106288. shader: string;
  106289. };
  106290. }
  106291. declare module BABYLON {
  106292. /**
  106293. * Applies a kernel filter to the image
  106294. */
  106295. export class FilterPostProcess extends PostProcess {
  106296. /** The matrix to be applied to the image */
  106297. kernelMatrix: Matrix;
  106298. /**
  106299. *
  106300. * @param name The name of the effect.
  106301. * @param kernelMatrix The matrix to be applied to the image
  106302. * @param options The required width/height ratio to downsize to before computing the render pass.
  106303. * @param camera The camera to apply the render pass to.
  106304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106305. * @param engine The engine which the post process will be applied. (default: current engine)
  106306. * @param reusable If the post process can be reused on the same frame. (default: false)
  106307. */
  106308. constructor(name: string,
  106309. /** The matrix to be applied to the image */
  106310. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. /** @hidden */
  106315. export var fxaaPixelShader: {
  106316. name: string;
  106317. shader: string;
  106318. };
  106319. }
  106320. declare module BABYLON {
  106321. /** @hidden */
  106322. export var fxaaVertexShader: {
  106323. name: string;
  106324. shader: string;
  106325. };
  106326. }
  106327. declare module BABYLON {
  106328. /**
  106329. * Fxaa post process
  106330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106331. */
  106332. export class FxaaPostProcess extends PostProcess {
  106333. /** @hidden */
  106334. texelWidth: number;
  106335. /** @hidden */
  106336. texelHeight: number;
  106337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106338. private _getDefines;
  106339. }
  106340. }
  106341. declare module BABYLON {
  106342. /** @hidden */
  106343. export var grainPixelShader: {
  106344. name: string;
  106345. shader: string;
  106346. };
  106347. }
  106348. declare module BABYLON {
  106349. /**
  106350. * The GrainPostProcess adds noise to the image at mid luminance levels
  106351. */
  106352. export class GrainPostProcess extends PostProcess {
  106353. /**
  106354. * The intensity of the grain added (default: 30)
  106355. */
  106356. intensity: number;
  106357. /**
  106358. * If the grain should be randomized on every frame
  106359. */
  106360. animated: boolean;
  106361. /**
  106362. * Creates a new instance of @see GrainPostProcess
  106363. * @param name The name of the effect.
  106364. * @param options The required width/height ratio to downsize to before computing the render pass.
  106365. * @param camera The camera to apply the render pass to.
  106366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106367. * @param engine The engine which the post process will be applied. (default: current engine)
  106368. * @param reusable If the post process can be reused on the same frame. (default: false)
  106369. * @param textureType Type of textures used when performing the post process. (default: 0)
  106370. * @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)
  106371. */
  106372. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106373. }
  106374. }
  106375. declare module BABYLON {
  106376. /** @hidden */
  106377. export var highlightsPixelShader: {
  106378. name: string;
  106379. shader: string;
  106380. };
  106381. }
  106382. declare module BABYLON {
  106383. /**
  106384. * Extracts highlights from the image
  106385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106386. */
  106387. export class HighlightsPostProcess extends PostProcess {
  106388. /**
  106389. * Extracts highlights from the image
  106390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106391. * @param name The name of the effect.
  106392. * @param options The required width/height ratio to downsize to before computing the render pass.
  106393. * @param camera The camera to apply the render pass to.
  106394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106395. * @param engine The engine which the post process will be applied. (default: current engine)
  106396. * @param reusable If the post process can be reused on the same frame. (default: false)
  106397. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106398. */
  106399. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106400. }
  106401. }
  106402. declare module BABYLON {
  106403. /** @hidden */
  106404. export var mrtFragmentDeclaration: {
  106405. name: string;
  106406. shader: string;
  106407. };
  106408. }
  106409. declare module BABYLON {
  106410. /** @hidden */
  106411. export var geometryPixelShader: {
  106412. name: string;
  106413. shader: string;
  106414. };
  106415. }
  106416. declare module BABYLON {
  106417. /** @hidden */
  106418. export var geometryVertexShader: {
  106419. name: string;
  106420. shader: string;
  106421. };
  106422. }
  106423. declare module BABYLON {
  106424. /**
  106425. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106426. */
  106427. export class GeometryBufferRenderer {
  106428. /**
  106429. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106430. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106431. */
  106432. static readonly POSITION_TEXTURE_TYPE: number;
  106433. /**
  106434. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106435. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106436. */
  106437. static readonly VELOCITY_TEXTURE_TYPE: number;
  106438. /**
  106439. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106440. * in order to compute objects velocities when enableVelocity is set to "true"
  106441. * @hidden
  106442. */
  106443. _previousTransformationMatrices: {
  106444. [index: number]: Matrix;
  106445. };
  106446. private _scene;
  106447. private _multiRenderTarget;
  106448. private _ratio;
  106449. private _enablePosition;
  106450. private _enableVelocity;
  106451. private _positionIndex;
  106452. private _velocityIndex;
  106453. protected _effect: Effect;
  106454. protected _cachedDefines: string;
  106455. /**
  106456. * Set the render list (meshes to be rendered) used in the G buffer.
  106457. */
  106458. renderList: Mesh[];
  106459. /**
  106460. * Gets wether or not G buffer are supported by the running hardware.
  106461. * This requires draw buffer supports
  106462. */
  106463. readonly isSupported: boolean;
  106464. /**
  106465. * Returns the index of the given texture type in the G-Buffer textures array
  106466. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106467. * @returns the index of the given texture type in the G-Buffer textures array
  106468. */
  106469. getTextureIndex(textureType: number): number;
  106470. /**
  106471. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106472. */
  106473. /**
  106474. * Sets whether or not objects positions are enabled for the G buffer.
  106475. */
  106476. enablePosition: boolean;
  106477. /**
  106478. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106479. */
  106480. /**
  106481. * Sets wether or not objects velocities are enabled for the G buffer.
  106482. */
  106483. enableVelocity: boolean;
  106484. /**
  106485. * Gets the scene associated with the buffer.
  106486. */
  106487. readonly scene: Scene;
  106488. /**
  106489. * Gets the ratio used by the buffer during its creation.
  106490. * How big is the buffer related to the main canvas.
  106491. */
  106492. readonly ratio: number;
  106493. /** @hidden */
  106494. static _SceneComponentInitialization: (scene: Scene) => void;
  106495. /**
  106496. * Creates a new G Buffer for the scene
  106497. * @param scene The scene the buffer belongs to
  106498. * @param ratio How big is the buffer related to the main canvas.
  106499. */
  106500. constructor(scene: Scene, ratio?: number);
  106501. /**
  106502. * Checks wether everything is ready to render a submesh to the G buffer.
  106503. * @param subMesh the submesh to check readiness for
  106504. * @param useInstances is the mesh drawn using instance or not
  106505. * @returns true if ready otherwise false
  106506. */
  106507. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106508. /**
  106509. * Gets the current underlying G Buffer.
  106510. * @returns the buffer
  106511. */
  106512. getGBuffer(): MultiRenderTarget;
  106513. /**
  106514. * Gets the number of samples used to render the buffer (anti aliasing).
  106515. */
  106516. /**
  106517. * Sets the number of samples used to render the buffer (anti aliasing).
  106518. */
  106519. samples: number;
  106520. /**
  106521. * Disposes the renderer and frees up associated resources.
  106522. */
  106523. dispose(): void;
  106524. protected _createRenderTargets(): void;
  106525. }
  106526. }
  106527. declare module BABYLON {
  106528. /** @hidden */
  106529. export var motionBlurPixelShader: {
  106530. name: string;
  106531. shader: string;
  106532. };
  106533. }
  106534. declare module BABYLON {
  106535. /**
  106536. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106537. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106538. * As an example, all you have to do is to create the post-process:
  106539. * var mb = new BABYLON.MotionBlurPostProcess(
  106540. * 'mb', // The name of the effect.
  106541. * scene, // The scene containing the objects to blur according to their velocity.
  106542. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106543. * camera // The camera to apply the render pass to.
  106544. * );
  106545. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106546. */
  106547. export class MotionBlurPostProcess extends PostProcess {
  106548. /**
  106549. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106550. */
  106551. motionStrength: number;
  106552. /**
  106553. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106554. */
  106555. /**
  106556. * Sets the number of iterations to be used for motion blur quality
  106557. */
  106558. motionBlurSamples: number;
  106559. private _motionBlurSamples;
  106560. private _geometryBufferRenderer;
  106561. /**
  106562. * Creates a new instance MotionBlurPostProcess
  106563. * @param name The name of the effect.
  106564. * @param scene The scene containing the objects to blur according to their velocity.
  106565. * @param options The required width/height ratio to downsize to before computing the render pass.
  106566. * @param camera The camera to apply the render pass to.
  106567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106568. * @param engine The engine which the post process will be applied. (default: current engine)
  106569. * @param reusable If the post process can be reused on the same frame. (default: false)
  106570. * @param textureType Type of textures used when performing the post process. (default: 0)
  106571. * @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)
  106572. */
  106573. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106574. /**
  106575. * Disposes the post process.
  106576. * @param camera The camera to dispose the post process on.
  106577. */
  106578. dispose(camera?: Camera): void;
  106579. }
  106580. }
  106581. declare module BABYLON {
  106582. /** @hidden */
  106583. export var refractionPixelShader: {
  106584. name: string;
  106585. shader: string;
  106586. };
  106587. }
  106588. declare module BABYLON {
  106589. /**
  106590. * Post process which applies a refractin texture
  106591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106592. */
  106593. export class RefractionPostProcess extends PostProcess {
  106594. /** the base color of the refraction (used to taint the rendering) */
  106595. color: Color3;
  106596. /** simulated refraction depth */
  106597. depth: number;
  106598. /** the coefficient of the base color (0 to remove base color tainting) */
  106599. colorLevel: number;
  106600. private _refTexture;
  106601. private _ownRefractionTexture;
  106602. /**
  106603. * Gets or sets the refraction texture
  106604. * Please note that you are responsible for disposing the texture if you set it manually
  106605. */
  106606. refractionTexture: Texture;
  106607. /**
  106608. * Initializes the RefractionPostProcess
  106609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106610. * @param name The name of the effect.
  106611. * @param refractionTextureUrl Url of the refraction texture to use
  106612. * @param color the base color of the refraction (used to taint the rendering)
  106613. * @param depth simulated refraction depth
  106614. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106615. * @param camera The camera to apply the render pass to.
  106616. * @param options The required width/height ratio to downsize to before computing the render pass.
  106617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106618. * @param engine The engine which the post process will be applied. (default: current engine)
  106619. * @param reusable If the post process can be reused on the same frame. (default: false)
  106620. */
  106621. constructor(name: string, refractionTextureUrl: string,
  106622. /** the base color of the refraction (used to taint the rendering) */
  106623. color: Color3,
  106624. /** simulated refraction depth */
  106625. depth: number,
  106626. /** the coefficient of the base color (0 to remove base color tainting) */
  106627. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106628. /**
  106629. * Disposes of the post process
  106630. * @param camera Camera to dispose post process on
  106631. */
  106632. dispose(camera: Camera): void;
  106633. }
  106634. }
  106635. declare module BABYLON {
  106636. /** @hidden */
  106637. export var sharpenPixelShader: {
  106638. name: string;
  106639. shader: string;
  106640. };
  106641. }
  106642. declare module BABYLON {
  106643. /**
  106644. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106645. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106646. */
  106647. export class SharpenPostProcess extends PostProcess {
  106648. /**
  106649. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106650. */
  106651. colorAmount: number;
  106652. /**
  106653. * How much sharpness should be applied (default: 0.3)
  106654. */
  106655. edgeAmount: number;
  106656. /**
  106657. * Creates a new instance ConvolutionPostProcess
  106658. * @param name The name of the effect.
  106659. * @param options The required width/height ratio to downsize to before computing the render pass.
  106660. * @param camera The camera to apply the render pass to.
  106661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106662. * @param engine The engine which the post process will be applied. (default: current engine)
  106663. * @param reusable If the post process can be reused on the same frame. (default: false)
  106664. * @param textureType Type of textures used when performing the post process. (default: 0)
  106665. * @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)
  106666. */
  106667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106668. }
  106669. }
  106670. declare module BABYLON {
  106671. /**
  106672. * PostProcessRenderPipeline
  106673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106674. */
  106675. export class PostProcessRenderPipeline {
  106676. private engine;
  106677. private _renderEffects;
  106678. private _renderEffectsForIsolatedPass;
  106679. /**
  106680. * @hidden
  106681. */
  106682. protected _cameras: Camera[];
  106683. /** @hidden */
  106684. _name: string;
  106685. /**
  106686. * Initializes a PostProcessRenderPipeline
  106687. * @param engine engine to add the pipeline to
  106688. * @param name name of the pipeline
  106689. */
  106690. constructor(engine: Engine, name: string);
  106691. /**
  106692. * "PostProcessRenderPipeline"
  106693. * @returns "PostProcessRenderPipeline"
  106694. */
  106695. getClassName(): string;
  106696. /**
  106697. * If all the render effects in the pipeline are support
  106698. */
  106699. readonly isSupported: boolean;
  106700. /**
  106701. * Adds an effect to the pipeline
  106702. * @param renderEffect the effect to add
  106703. */
  106704. addEffect(renderEffect: PostProcessRenderEffect): void;
  106705. /** @hidden */
  106706. _rebuild(): void;
  106707. /** @hidden */
  106708. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106709. /** @hidden */
  106710. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106711. /** @hidden */
  106712. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106713. /** @hidden */
  106714. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106715. /** @hidden */
  106716. _attachCameras(cameras: Camera, unique: boolean): void;
  106717. /** @hidden */
  106718. _attachCameras(cameras: Camera[], unique: boolean): void;
  106719. /** @hidden */
  106720. _detachCameras(cameras: Camera): void;
  106721. /** @hidden */
  106722. _detachCameras(cameras: Nullable<Camera[]>): void;
  106723. /** @hidden */
  106724. _update(): void;
  106725. /** @hidden */
  106726. _reset(): void;
  106727. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106728. /**
  106729. * Disposes of the pipeline
  106730. */
  106731. dispose(): void;
  106732. }
  106733. }
  106734. declare module BABYLON {
  106735. /**
  106736. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106737. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106738. */
  106739. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106740. private _scene;
  106741. private _camerasToBeAttached;
  106742. /**
  106743. * ID of the sharpen post process,
  106744. */
  106745. private readonly SharpenPostProcessId;
  106746. /**
  106747. * @ignore
  106748. * ID of the image processing post process;
  106749. */
  106750. readonly ImageProcessingPostProcessId: string;
  106751. /**
  106752. * @ignore
  106753. * ID of the Fast Approximate Anti-Aliasing post process;
  106754. */
  106755. readonly FxaaPostProcessId: string;
  106756. /**
  106757. * ID of the chromatic aberration post process,
  106758. */
  106759. private readonly ChromaticAberrationPostProcessId;
  106760. /**
  106761. * ID of the grain post process
  106762. */
  106763. private readonly GrainPostProcessId;
  106764. /**
  106765. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106766. */
  106767. sharpen: SharpenPostProcess;
  106768. private _sharpenEffect;
  106769. private bloom;
  106770. /**
  106771. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106772. */
  106773. depthOfField: DepthOfFieldEffect;
  106774. /**
  106775. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106776. */
  106777. fxaa: FxaaPostProcess;
  106778. /**
  106779. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106780. */
  106781. imageProcessing: ImageProcessingPostProcess;
  106782. /**
  106783. * Chromatic aberration post process which will shift rgb colors in the image
  106784. */
  106785. chromaticAberration: ChromaticAberrationPostProcess;
  106786. private _chromaticAberrationEffect;
  106787. /**
  106788. * Grain post process which add noise to the image
  106789. */
  106790. grain: GrainPostProcess;
  106791. private _grainEffect;
  106792. /**
  106793. * Glow post process which adds a glow to emmisive areas of the image
  106794. */
  106795. private _glowLayer;
  106796. /**
  106797. * Animations which can be used to tweak settings over a period of time
  106798. */
  106799. animations: Animation[];
  106800. private _imageProcessingConfigurationObserver;
  106801. private _sharpenEnabled;
  106802. private _bloomEnabled;
  106803. private _depthOfFieldEnabled;
  106804. private _depthOfFieldBlurLevel;
  106805. private _fxaaEnabled;
  106806. private _imageProcessingEnabled;
  106807. private _defaultPipelineTextureType;
  106808. private _bloomScale;
  106809. private _chromaticAberrationEnabled;
  106810. private _grainEnabled;
  106811. private _buildAllowed;
  106812. /**
  106813. * Enable or disable the sharpen process from the pipeline
  106814. */
  106815. sharpenEnabled: boolean;
  106816. private _resizeObserver;
  106817. private _hardwareScaleLevel;
  106818. private _bloomKernel;
  106819. /**
  106820. * Specifies the size of the bloom blur kernel, relative to the final output size
  106821. */
  106822. bloomKernel: number;
  106823. /**
  106824. * Specifies the weight of the bloom in the final rendering
  106825. */
  106826. private _bloomWeight;
  106827. /**
  106828. * Specifies the luma threshold for the area that will be blurred by the bloom
  106829. */
  106830. private _bloomThreshold;
  106831. private _hdr;
  106832. /**
  106833. * The strength of the bloom.
  106834. */
  106835. bloomWeight: number;
  106836. /**
  106837. * The strength of the bloom.
  106838. */
  106839. bloomThreshold: number;
  106840. /**
  106841. * The scale of the bloom, lower value will provide better performance.
  106842. */
  106843. bloomScale: number;
  106844. /**
  106845. * Enable or disable the bloom from the pipeline
  106846. */
  106847. bloomEnabled: boolean;
  106848. private _rebuildBloom;
  106849. /**
  106850. * If the depth of field is enabled.
  106851. */
  106852. depthOfFieldEnabled: boolean;
  106853. /**
  106854. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106855. */
  106856. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106857. /**
  106858. * If the anti aliasing is enabled.
  106859. */
  106860. fxaaEnabled: boolean;
  106861. private _samples;
  106862. /**
  106863. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106864. */
  106865. samples: number;
  106866. /**
  106867. * If image processing is enabled.
  106868. */
  106869. imageProcessingEnabled: boolean;
  106870. /**
  106871. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106872. */
  106873. glowLayerEnabled: boolean;
  106874. /**
  106875. * Enable or disable the chromaticAberration process from the pipeline
  106876. */
  106877. chromaticAberrationEnabled: boolean;
  106878. /**
  106879. * Enable or disable the grain process from the pipeline
  106880. */
  106881. grainEnabled: boolean;
  106882. /**
  106883. * @constructor
  106884. * @param name - The rendering pipeline name (default: "")
  106885. * @param hdr - If high dynamic range textures should be used (default: true)
  106886. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106887. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106888. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106889. */
  106890. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  106891. /**
  106892. * Force the compilation of the entire pipeline.
  106893. */
  106894. prepare(): void;
  106895. private _hasCleared;
  106896. private _prevPostProcess;
  106897. private _prevPrevPostProcess;
  106898. private _setAutoClearAndTextureSharing;
  106899. private _depthOfFieldSceneObserver;
  106900. private _buildPipeline;
  106901. private _disposePostProcesses;
  106902. /**
  106903. * Adds a camera to the pipeline
  106904. * @param camera the camera to be added
  106905. */
  106906. addCamera(camera: Camera): void;
  106907. /**
  106908. * Removes a camera from the pipeline
  106909. * @param camera the camera to remove
  106910. */
  106911. removeCamera(camera: Camera): void;
  106912. /**
  106913. * Dispose of the pipeline and stop all post processes
  106914. */
  106915. dispose(): void;
  106916. /**
  106917. * Serialize the rendering pipeline (Used when exporting)
  106918. * @returns the serialized object
  106919. */
  106920. serialize(): any;
  106921. /**
  106922. * Parse the serialized pipeline
  106923. * @param source Source pipeline.
  106924. * @param scene The scene to load the pipeline to.
  106925. * @param rootUrl The URL of the serialized pipeline.
  106926. * @returns An instantiated pipeline from the serialized object.
  106927. */
  106928. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106929. }
  106930. }
  106931. declare module BABYLON {
  106932. /** @hidden */
  106933. export var lensHighlightsPixelShader: {
  106934. name: string;
  106935. shader: string;
  106936. };
  106937. }
  106938. declare module BABYLON {
  106939. /** @hidden */
  106940. export var depthOfFieldPixelShader: {
  106941. name: string;
  106942. shader: string;
  106943. };
  106944. }
  106945. declare module BABYLON {
  106946. /**
  106947. * BABYLON.JS Chromatic Aberration GLSL Shader
  106948. * Author: Olivier Guyot
  106949. * Separates very slightly R, G and B colors on the edges of the screen
  106950. * Inspired by Francois Tarlier & Martins Upitis
  106951. */
  106952. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  106953. /**
  106954. * @ignore
  106955. * The chromatic aberration PostProcess id in the pipeline
  106956. */
  106957. LensChromaticAberrationEffect: string;
  106958. /**
  106959. * @ignore
  106960. * The highlights enhancing PostProcess id in the pipeline
  106961. */
  106962. HighlightsEnhancingEffect: string;
  106963. /**
  106964. * @ignore
  106965. * The depth-of-field PostProcess id in the pipeline
  106966. */
  106967. LensDepthOfFieldEffect: string;
  106968. private _scene;
  106969. private _depthTexture;
  106970. private _grainTexture;
  106971. private _chromaticAberrationPostProcess;
  106972. private _highlightsPostProcess;
  106973. private _depthOfFieldPostProcess;
  106974. private _edgeBlur;
  106975. private _grainAmount;
  106976. private _chromaticAberration;
  106977. private _distortion;
  106978. private _highlightsGain;
  106979. private _highlightsThreshold;
  106980. private _dofDistance;
  106981. private _dofAperture;
  106982. private _dofDarken;
  106983. private _dofPentagon;
  106984. private _blurNoise;
  106985. /**
  106986. * @constructor
  106987. *
  106988. * Effect parameters are as follow:
  106989. * {
  106990. * chromatic_aberration: number; // from 0 to x (1 for realism)
  106991. * edge_blur: number; // from 0 to x (1 for realism)
  106992. * distortion: number; // from 0 to x (1 for realism)
  106993. * grain_amount: number; // from 0 to 1
  106994. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  106995. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  106996. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  106997. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  106998. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  106999. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107000. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107001. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107002. * }
  107003. * Note: if an effect parameter is unset, effect is disabled
  107004. *
  107005. * @param name The rendering pipeline name
  107006. * @param parameters - An object containing all parameters (see above)
  107007. * @param scene The scene linked to this pipeline
  107008. * @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)
  107009. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107010. */
  107011. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107012. /**
  107013. * Sets the amount of blur at the edges
  107014. * @param amount blur amount
  107015. */
  107016. setEdgeBlur(amount: number): void;
  107017. /**
  107018. * Sets edge blur to 0
  107019. */
  107020. disableEdgeBlur(): void;
  107021. /**
  107022. * Sets the amout of grain
  107023. * @param amount Amount of grain
  107024. */
  107025. setGrainAmount(amount: number): void;
  107026. /**
  107027. * Set grain amount to 0
  107028. */
  107029. disableGrain(): void;
  107030. /**
  107031. * Sets the chromatic aberration amount
  107032. * @param amount amount of chromatic aberration
  107033. */
  107034. setChromaticAberration(amount: number): void;
  107035. /**
  107036. * Sets chromatic aberration amount to 0
  107037. */
  107038. disableChromaticAberration(): void;
  107039. /**
  107040. * Sets the EdgeDistortion amount
  107041. * @param amount amount of EdgeDistortion
  107042. */
  107043. setEdgeDistortion(amount: number): void;
  107044. /**
  107045. * Sets edge distortion to 0
  107046. */
  107047. disableEdgeDistortion(): void;
  107048. /**
  107049. * Sets the FocusDistance amount
  107050. * @param amount amount of FocusDistance
  107051. */
  107052. setFocusDistance(amount: number): void;
  107053. /**
  107054. * Disables depth of field
  107055. */
  107056. disableDepthOfField(): void;
  107057. /**
  107058. * Sets the Aperture amount
  107059. * @param amount amount of Aperture
  107060. */
  107061. setAperture(amount: number): void;
  107062. /**
  107063. * Sets the DarkenOutOfFocus amount
  107064. * @param amount amount of DarkenOutOfFocus
  107065. */
  107066. setDarkenOutOfFocus(amount: number): void;
  107067. /**
  107068. * Creates a pentagon bokeh effect
  107069. */
  107070. enablePentagonBokeh(): void;
  107071. /**
  107072. * Disables the pentagon bokeh effect
  107073. */
  107074. disablePentagonBokeh(): void;
  107075. /**
  107076. * Enables noise blur
  107077. */
  107078. enableNoiseBlur(): void;
  107079. /**
  107080. * Disables noise blur
  107081. */
  107082. disableNoiseBlur(): void;
  107083. /**
  107084. * Sets the HighlightsGain amount
  107085. * @param amount amount of HighlightsGain
  107086. */
  107087. setHighlightsGain(amount: number): void;
  107088. /**
  107089. * Sets the HighlightsThreshold amount
  107090. * @param amount amount of HighlightsThreshold
  107091. */
  107092. setHighlightsThreshold(amount: number): void;
  107093. /**
  107094. * Disables highlights
  107095. */
  107096. disableHighlights(): void;
  107097. /**
  107098. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107099. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107100. */
  107101. dispose(disableDepthRender?: boolean): void;
  107102. private _createChromaticAberrationPostProcess;
  107103. private _createHighlightsPostProcess;
  107104. private _createDepthOfFieldPostProcess;
  107105. private _createGrainTexture;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /** @hidden */
  107110. export var ssao2PixelShader: {
  107111. name: string;
  107112. shader: string;
  107113. };
  107114. }
  107115. declare module BABYLON {
  107116. /** @hidden */
  107117. export var ssaoCombinePixelShader: {
  107118. name: string;
  107119. shader: string;
  107120. };
  107121. }
  107122. declare module BABYLON {
  107123. /**
  107124. * Render pipeline to produce ssao effect
  107125. */
  107126. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107127. /**
  107128. * @ignore
  107129. * The PassPostProcess id in the pipeline that contains the original scene color
  107130. */
  107131. SSAOOriginalSceneColorEffect: string;
  107132. /**
  107133. * @ignore
  107134. * The SSAO PostProcess id in the pipeline
  107135. */
  107136. SSAORenderEffect: string;
  107137. /**
  107138. * @ignore
  107139. * The horizontal blur PostProcess id in the pipeline
  107140. */
  107141. SSAOBlurHRenderEffect: string;
  107142. /**
  107143. * @ignore
  107144. * The vertical blur PostProcess id in the pipeline
  107145. */
  107146. SSAOBlurVRenderEffect: string;
  107147. /**
  107148. * @ignore
  107149. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107150. */
  107151. SSAOCombineRenderEffect: string;
  107152. /**
  107153. * The output strength of the SSAO post-process. Default value is 1.0.
  107154. */
  107155. totalStrength: number;
  107156. /**
  107157. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107158. */
  107159. maxZ: number;
  107160. /**
  107161. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107162. */
  107163. minZAspect: number;
  107164. private _samples;
  107165. /**
  107166. * Number of samples used for the SSAO calculations. Default value is 8
  107167. */
  107168. samples: number;
  107169. private _textureSamples;
  107170. /**
  107171. * Number of samples to use for antialiasing
  107172. */
  107173. textureSamples: number;
  107174. /**
  107175. * Ratio object used for SSAO ratio and blur ratio
  107176. */
  107177. private _ratio;
  107178. /**
  107179. * Dynamically generated sphere sampler.
  107180. */
  107181. private _sampleSphere;
  107182. /**
  107183. * Blur filter offsets
  107184. */
  107185. private _samplerOffsets;
  107186. private _expensiveBlur;
  107187. /**
  107188. * If bilateral blur should be used
  107189. */
  107190. expensiveBlur: boolean;
  107191. /**
  107192. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107193. */
  107194. radius: number;
  107195. /**
  107196. * The base color of the SSAO post-process
  107197. * The final result is "base + ssao" between [0, 1]
  107198. */
  107199. base: number;
  107200. /**
  107201. * Support test.
  107202. */
  107203. static readonly IsSupported: boolean;
  107204. private _scene;
  107205. private _depthTexture;
  107206. private _normalTexture;
  107207. private _randomTexture;
  107208. private _originalColorPostProcess;
  107209. private _ssaoPostProcess;
  107210. private _blurHPostProcess;
  107211. private _blurVPostProcess;
  107212. private _ssaoCombinePostProcess;
  107213. private _firstUpdate;
  107214. /**
  107215. * @constructor
  107216. * @param name The rendering pipeline name
  107217. * @param scene The scene linked to this pipeline
  107218. * @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 }
  107219. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107220. */
  107221. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107222. /**
  107223. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107224. */
  107225. dispose(disableGeometryBufferRenderer?: boolean): void;
  107226. private _createBlurPostProcess;
  107227. /** @hidden */
  107228. _rebuild(): void;
  107229. private _bits;
  107230. private _radicalInverse_VdC;
  107231. private _hammersley;
  107232. private _hemisphereSample_uniform;
  107233. private _generateHemisphere;
  107234. private _createSSAOPostProcess;
  107235. private _createSSAOCombinePostProcess;
  107236. private _createRandomTexture;
  107237. /**
  107238. * Serialize the rendering pipeline (Used when exporting)
  107239. * @returns the serialized object
  107240. */
  107241. serialize(): any;
  107242. /**
  107243. * Parse the serialized pipeline
  107244. * @param source Source pipeline.
  107245. * @param scene The scene to load the pipeline to.
  107246. * @param rootUrl The URL of the serialized pipeline.
  107247. * @returns An instantiated pipeline from the serialized object.
  107248. */
  107249. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107250. }
  107251. }
  107252. declare module BABYLON {
  107253. /** @hidden */
  107254. export var ssaoPixelShader: {
  107255. name: string;
  107256. shader: string;
  107257. };
  107258. }
  107259. declare module BABYLON {
  107260. /**
  107261. * Render pipeline to produce ssao effect
  107262. */
  107263. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107264. /**
  107265. * @ignore
  107266. * The PassPostProcess id in the pipeline that contains the original scene color
  107267. */
  107268. SSAOOriginalSceneColorEffect: string;
  107269. /**
  107270. * @ignore
  107271. * The SSAO PostProcess id in the pipeline
  107272. */
  107273. SSAORenderEffect: string;
  107274. /**
  107275. * @ignore
  107276. * The horizontal blur PostProcess id in the pipeline
  107277. */
  107278. SSAOBlurHRenderEffect: string;
  107279. /**
  107280. * @ignore
  107281. * The vertical blur PostProcess id in the pipeline
  107282. */
  107283. SSAOBlurVRenderEffect: string;
  107284. /**
  107285. * @ignore
  107286. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107287. */
  107288. SSAOCombineRenderEffect: string;
  107289. /**
  107290. * The output strength of the SSAO post-process. Default value is 1.0.
  107291. */
  107292. totalStrength: number;
  107293. /**
  107294. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107295. */
  107296. radius: number;
  107297. /**
  107298. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107299. * Must not be equal to fallOff and superior to fallOff.
  107300. * Default value is 0.975
  107301. */
  107302. area: number;
  107303. /**
  107304. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107305. * Must not be equal to area and inferior to area.
  107306. * Default value is 0.0
  107307. */
  107308. fallOff: number;
  107309. /**
  107310. * The base color of the SSAO post-process
  107311. * The final result is "base + ssao" between [0, 1]
  107312. */
  107313. base: number;
  107314. private _scene;
  107315. private _depthTexture;
  107316. private _randomTexture;
  107317. private _originalColorPostProcess;
  107318. private _ssaoPostProcess;
  107319. private _blurHPostProcess;
  107320. private _blurVPostProcess;
  107321. private _ssaoCombinePostProcess;
  107322. private _firstUpdate;
  107323. /**
  107324. * @constructor
  107325. * @param name - The rendering pipeline name
  107326. * @param scene - The scene linked to this pipeline
  107327. * @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 }
  107328. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107329. */
  107330. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107331. /**
  107332. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107333. */
  107334. dispose(disableDepthRender?: boolean): void;
  107335. private _createBlurPostProcess;
  107336. /** @hidden */
  107337. _rebuild(): void;
  107338. private _createSSAOPostProcess;
  107339. private _createSSAOCombinePostProcess;
  107340. private _createRandomTexture;
  107341. }
  107342. }
  107343. declare module BABYLON {
  107344. /** @hidden */
  107345. export var standardPixelShader: {
  107346. name: string;
  107347. shader: string;
  107348. };
  107349. }
  107350. declare module BABYLON {
  107351. /**
  107352. * Standard rendering pipeline
  107353. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107354. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107355. */
  107356. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107357. /**
  107358. * Public members
  107359. */
  107360. /**
  107361. * Post-process which contains the original scene color before the pipeline applies all the effects
  107362. */
  107363. originalPostProcess: Nullable<PostProcess>;
  107364. /**
  107365. * Post-process used to down scale an image x4
  107366. */
  107367. downSampleX4PostProcess: Nullable<PostProcess>;
  107368. /**
  107369. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107370. */
  107371. brightPassPostProcess: Nullable<PostProcess>;
  107372. /**
  107373. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107374. */
  107375. blurHPostProcesses: PostProcess[];
  107376. /**
  107377. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107378. */
  107379. blurVPostProcesses: PostProcess[];
  107380. /**
  107381. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107382. */
  107383. textureAdderPostProcess: Nullable<PostProcess>;
  107384. /**
  107385. * Post-process used to create volumetric lighting effect
  107386. */
  107387. volumetricLightPostProcess: Nullable<PostProcess>;
  107388. /**
  107389. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107390. */
  107391. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107392. /**
  107393. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107394. */
  107395. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107396. /**
  107397. * Post-process used to merge the volumetric light effect and the real scene color
  107398. */
  107399. volumetricLightMergePostProces: Nullable<PostProcess>;
  107400. /**
  107401. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107402. */
  107403. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107404. /**
  107405. * Base post-process used to calculate the average luminance of the final image for HDR
  107406. */
  107407. luminancePostProcess: Nullable<PostProcess>;
  107408. /**
  107409. * Post-processes used to create down sample post-processes in order to get
  107410. * the average luminance of the final image for HDR
  107411. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107412. */
  107413. luminanceDownSamplePostProcesses: PostProcess[];
  107414. /**
  107415. * Post-process used to create a HDR effect (light adaptation)
  107416. */
  107417. hdrPostProcess: Nullable<PostProcess>;
  107418. /**
  107419. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107420. */
  107421. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107422. /**
  107423. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107424. */
  107425. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107426. /**
  107427. * Post-process used to merge the final HDR post-process and the real scene color
  107428. */
  107429. hdrFinalPostProcess: Nullable<PostProcess>;
  107430. /**
  107431. * Post-process used to create a lens flare effect
  107432. */
  107433. lensFlarePostProcess: Nullable<PostProcess>;
  107434. /**
  107435. * Post-process that merges the result of the lens flare post-process and the real scene color
  107436. */
  107437. lensFlareComposePostProcess: Nullable<PostProcess>;
  107438. /**
  107439. * Post-process used to create a motion blur effect
  107440. */
  107441. motionBlurPostProcess: Nullable<PostProcess>;
  107442. /**
  107443. * Post-process used to create a depth of field effect
  107444. */
  107445. depthOfFieldPostProcess: Nullable<PostProcess>;
  107446. /**
  107447. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107448. */
  107449. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107450. /**
  107451. * Represents the brightness threshold in order to configure the illuminated surfaces
  107452. */
  107453. brightThreshold: number;
  107454. /**
  107455. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107456. */
  107457. blurWidth: number;
  107458. /**
  107459. * Sets if the blur for highlighted surfaces must be only horizontal
  107460. */
  107461. horizontalBlur: boolean;
  107462. /**
  107463. * Sets the overall exposure used by the pipeline
  107464. */
  107465. exposure: number;
  107466. /**
  107467. * Texture used typically to simulate "dirty" on camera lens
  107468. */
  107469. lensTexture: Nullable<Texture>;
  107470. /**
  107471. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107472. */
  107473. volumetricLightCoefficient: number;
  107474. /**
  107475. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107476. */
  107477. volumetricLightPower: number;
  107478. /**
  107479. * Used the set the blur intensity to smooth the volumetric lights
  107480. */
  107481. volumetricLightBlurScale: number;
  107482. /**
  107483. * Light (spot or directional) used to generate the volumetric lights rays
  107484. * The source light must have a shadow generate so the pipeline can get its
  107485. * depth map
  107486. */
  107487. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107488. /**
  107489. * For eye adaptation, represents the minimum luminance the eye can see
  107490. */
  107491. hdrMinimumLuminance: number;
  107492. /**
  107493. * For eye adaptation, represents the decrease luminance speed
  107494. */
  107495. hdrDecreaseRate: number;
  107496. /**
  107497. * For eye adaptation, represents the increase luminance speed
  107498. */
  107499. hdrIncreaseRate: number;
  107500. /**
  107501. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107502. */
  107503. lensColorTexture: Nullable<Texture>;
  107504. /**
  107505. * The overall strengh for the lens flare effect
  107506. */
  107507. lensFlareStrength: number;
  107508. /**
  107509. * Dispersion coefficient for lens flare ghosts
  107510. */
  107511. lensFlareGhostDispersal: number;
  107512. /**
  107513. * Main lens flare halo width
  107514. */
  107515. lensFlareHaloWidth: number;
  107516. /**
  107517. * Based on the lens distortion effect, defines how much the lens flare result
  107518. * is distorted
  107519. */
  107520. lensFlareDistortionStrength: number;
  107521. /**
  107522. * Lens star texture must be used to simulate rays on the flares and is available
  107523. * in the documentation
  107524. */
  107525. lensStarTexture: Nullable<Texture>;
  107526. /**
  107527. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107528. * flare effect by taking account of the dirt texture
  107529. */
  107530. lensFlareDirtTexture: Nullable<Texture>;
  107531. /**
  107532. * Represents the focal length for the depth of field effect
  107533. */
  107534. depthOfFieldDistance: number;
  107535. /**
  107536. * Represents the blur intensity for the blurred part of the depth of field effect
  107537. */
  107538. depthOfFieldBlurWidth: number;
  107539. /**
  107540. * For motion blur, defines how much the image is blurred by the movement
  107541. */
  107542. motionStrength: number;
  107543. /**
  107544. * List of animations for the pipeline (IAnimatable implementation)
  107545. */
  107546. animations: Animation[];
  107547. /**
  107548. * Private members
  107549. */
  107550. private _scene;
  107551. private _currentDepthOfFieldSource;
  107552. private _basePostProcess;
  107553. private _hdrCurrentLuminance;
  107554. private _floatTextureType;
  107555. private _ratio;
  107556. private _bloomEnabled;
  107557. private _depthOfFieldEnabled;
  107558. private _vlsEnabled;
  107559. private _lensFlareEnabled;
  107560. private _hdrEnabled;
  107561. private _motionBlurEnabled;
  107562. private _fxaaEnabled;
  107563. private _motionBlurSamples;
  107564. private _volumetricLightStepsCount;
  107565. private _samples;
  107566. /**
  107567. * @ignore
  107568. * Specifies if the bloom pipeline is enabled
  107569. */
  107570. BloomEnabled: boolean;
  107571. /**
  107572. * @ignore
  107573. * Specifies if the depth of field pipeline is enabed
  107574. */
  107575. DepthOfFieldEnabled: boolean;
  107576. /**
  107577. * @ignore
  107578. * Specifies if the lens flare pipeline is enabed
  107579. */
  107580. LensFlareEnabled: boolean;
  107581. /**
  107582. * @ignore
  107583. * Specifies if the HDR pipeline is enabled
  107584. */
  107585. HDREnabled: boolean;
  107586. /**
  107587. * @ignore
  107588. * Specifies if the volumetric lights scattering effect is enabled
  107589. */
  107590. VLSEnabled: boolean;
  107591. /**
  107592. * @ignore
  107593. * Specifies if the motion blur effect is enabled
  107594. */
  107595. MotionBlurEnabled: boolean;
  107596. /**
  107597. * Specifies if anti-aliasing is enabled
  107598. */
  107599. fxaaEnabled: boolean;
  107600. /**
  107601. * Specifies the number of steps used to calculate the volumetric lights
  107602. * Typically in interval [50, 200]
  107603. */
  107604. volumetricLightStepsCount: number;
  107605. /**
  107606. * Specifies the number of samples used for the motion blur effect
  107607. * Typically in interval [16, 64]
  107608. */
  107609. motionBlurSamples: number;
  107610. /**
  107611. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107612. */
  107613. samples: number;
  107614. /**
  107615. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107616. * @constructor
  107617. * @param name The rendering pipeline name
  107618. * @param scene The scene linked to this pipeline
  107619. * @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)
  107620. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107621. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107622. */
  107623. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107624. private _buildPipeline;
  107625. private _createDownSampleX4PostProcess;
  107626. private _createBrightPassPostProcess;
  107627. private _createBlurPostProcesses;
  107628. private _createTextureAdderPostProcess;
  107629. private _createVolumetricLightPostProcess;
  107630. private _createLuminancePostProcesses;
  107631. private _createHdrPostProcess;
  107632. private _createLensFlarePostProcess;
  107633. private _createDepthOfFieldPostProcess;
  107634. private _createMotionBlurPostProcess;
  107635. private _getDepthTexture;
  107636. private _disposePostProcesses;
  107637. /**
  107638. * Dispose of the pipeline and stop all post processes
  107639. */
  107640. dispose(): void;
  107641. /**
  107642. * Serialize the rendering pipeline (Used when exporting)
  107643. * @returns the serialized object
  107644. */
  107645. serialize(): any;
  107646. /**
  107647. * Parse the serialized pipeline
  107648. * @param source Source pipeline.
  107649. * @param scene The scene to load the pipeline to.
  107650. * @param rootUrl The URL of the serialized pipeline.
  107651. * @returns An instantiated pipeline from the serialized object.
  107652. */
  107653. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107654. /**
  107655. * Luminance steps
  107656. */
  107657. static LuminanceSteps: number;
  107658. }
  107659. }
  107660. declare module BABYLON {
  107661. /**
  107662. * PostProcessRenderPipelineManager class
  107663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107664. */
  107665. export class PostProcessRenderPipelineManager {
  107666. private _renderPipelines;
  107667. /**
  107668. * Initializes a PostProcessRenderPipelineManager
  107669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107670. */
  107671. constructor();
  107672. /**
  107673. * Adds a pipeline to the manager
  107674. * @param renderPipeline The pipeline to add
  107675. */
  107676. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107677. /**
  107678. * Attaches a camera to the pipeline
  107679. * @param renderPipelineName The name of the pipeline to attach to
  107680. * @param cameras the camera to attach
  107681. * @param unique if the camera can be attached multiple times to the pipeline
  107682. */
  107683. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107684. /**
  107685. * Detaches a camera from the pipeline
  107686. * @param renderPipelineName The name of the pipeline to detach from
  107687. * @param cameras the camera to detach
  107688. */
  107689. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107690. /**
  107691. * Enables an effect by name on a pipeline
  107692. * @param renderPipelineName the name of the pipeline to enable the effect in
  107693. * @param renderEffectName the name of the effect to enable
  107694. * @param cameras the cameras that the effect should be enabled on
  107695. */
  107696. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107697. /**
  107698. * Disables an effect by name on a pipeline
  107699. * @param renderPipelineName the name of the pipeline to disable the effect in
  107700. * @param renderEffectName the name of the effect to disable
  107701. * @param cameras the cameras that the effect should be disabled on
  107702. */
  107703. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107704. /**
  107705. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107706. */
  107707. update(): void;
  107708. /** @hidden */
  107709. _rebuild(): void;
  107710. /**
  107711. * Disposes of the manager and pipelines
  107712. */
  107713. dispose(): void;
  107714. }
  107715. }
  107716. declare module BABYLON {
  107717. interface Scene {
  107718. /** @hidden (Backing field) */
  107719. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107720. /**
  107721. * Gets the postprocess render pipeline manager
  107722. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107723. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107724. */
  107725. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107726. }
  107727. /**
  107728. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107729. */
  107730. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107731. /**
  107732. * The component name helpfull to identify the component in the list of scene components.
  107733. */
  107734. readonly name: string;
  107735. /**
  107736. * The scene the component belongs to.
  107737. */
  107738. scene: Scene;
  107739. /**
  107740. * Creates a new instance of the component for the given scene
  107741. * @param scene Defines the scene to register the component in
  107742. */
  107743. constructor(scene: Scene);
  107744. /**
  107745. * Registers the component in a given scene
  107746. */
  107747. register(): void;
  107748. /**
  107749. * Rebuilds the elements related to this component in case of
  107750. * context lost for instance.
  107751. */
  107752. rebuild(): void;
  107753. /**
  107754. * Disposes the component and the associated ressources
  107755. */
  107756. dispose(): void;
  107757. private _gatherRenderTargets;
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /** @hidden */
  107762. export var tonemapPixelShader: {
  107763. name: string;
  107764. shader: string;
  107765. };
  107766. }
  107767. declare module BABYLON {
  107768. /** Defines operator used for tonemapping */
  107769. export enum TonemappingOperator {
  107770. /** Hable */
  107771. Hable = 0,
  107772. /** Reinhard */
  107773. Reinhard = 1,
  107774. /** HejiDawson */
  107775. HejiDawson = 2,
  107776. /** Photographic */
  107777. Photographic = 3
  107778. }
  107779. /**
  107780. * Defines a post process to apply tone mapping
  107781. */
  107782. export class TonemapPostProcess extends PostProcess {
  107783. private _operator;
  107784. /** Defines the required exposure adjustement */
  107785. exposureAdjustment: number;
  107786. /**
  107787. * Creates a new TonemapPostProcess
  107788. * @param name defines the name of the postprocess
  107789. * @param _operator defines the operator to use
  107790. * @param exposureAdjustment defines the required exposure adjustement
  107791. * @param camera defines the camera to use (can be null)
  107792. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107793. * @param engine defines the hosting engine (can be ignore if camera is set)
  107794. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107795. */
  107796. constructor(name: string, _operator: TonemappingOperator,
  107797. /** Defines the required exposure adjustement */
  107798. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107799. }
  107800. }
  107801. declare module BABYLON {
  107802. /** @hidden */
  107803. export var depthVertexShader: {
  107804. name: string;
  107805. shader: string;
  107806. };
  107807. }
  107808. declare module BABYLON {
  107809. /** @hidden */
  107810. export var volumetricLightScatteringPixelShader: {
  107811. name: string;
  107812. shader: string;
  107813. };
  107814. }
  107815. declare module BABYLON {
  107816. /** @hidden */
  107817. export var volumetricLightScatteringPassPixelShader: {
  107818. name: string;
  107819. shader: string;
  107820. };
  107821. }
  107822. declare module BABYLON {
  107823. /**
  107824. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107825. */
  107826. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107827. private _volumetricLightScatteringPass;
  107828. private _volumetricLightScatteringRTT;
  107829. private _viewPort;
  107830. private _screenCoordinates;
  107831. private _cachedDefines;
  107832. /**
  107833. * If not undefined, the mesh position is computed from the attached node position
  107834. */
  107835. attachedNode: {
  107836. position: Vector3;
  107837. };
  107838. /**
  107839. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107840. */
  107841. customMeshPosition: Vector3;
  107842. /**
  107843. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107844. */
  107845. useCustomMeshPosition: boolean;
  107846. /**
  107847. * If the post-process should inverse the light scattering direction
  107848. */
  107849. invert: boolean;
  107850. /**
  107851. * The internal mesh used by the post-process
  107852. */
  107853. mesh: Mesh;
  107854. /**
  107855. * @hidden
  107856. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107857. */
  107858. useDiffuseColor: boolean;
  107859. /**
  107860. * Array containing the excluded meshes not rendered in the internal pass
  107861. */
  107862. excludedMeshes: AbstractMesh[];
  107863. /**
  107864. * Controls the overall intensity of the post-process
  107865. */
  107866. exposure: number;
  107867. /**
  107868. * Dissipates each sample's contribution in range [0, 1]
  107869. */
  107870. decay: number;
  107871. /**
  107872. * Controls the overall intensity of each sample
  107873. */
  107874. weight: number;
  107875. /**
  107876. * Controls the density of each sample
  107877. */
  107878. density: number;
  107879. /**
  107880. * @constructor
  107881. * @param name The post-process name
  107882. * @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)
  107883. * @param camera The camera that the post-process will be attached to
  107884. * @param mesh The mesh used to create the light scattering
  107885. * @param samples The post-process quality, default 100
  107886. * @param samplingModeThe post-process filtering mode
  107887. * @param engine The babylon engine
  107888. * @param reusable If the post-process is reusable
  107889. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  107890. */
  107891. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107892. /**
  107893. * Returns the string "VolumetricLightScatteringPostProcess"
  107894. * @returns "VolumetricLightScatteringPostProcess"
  107895. */
  107896. getClassName(): string;
  107897. private _isReady;
  107898. /**
  107899. * Sets the new light position for light scattering effect
  107900. * @param position The new custom light position
  107901. */
  107902. setCustomMeshPosition(position: Vector3): void;
  107903. /**
  107904. * Returns the light position for light scattering effect
  107905. * @return Vector3 The custom light position
  107906. */
  107907. getCustomMeshPosition(): Vector3;
  107908. /**
  107909. * Disposes the internal assets and detaches the post-process from the camera
  107910. */
  107911. dispose(camera: Camera): void;
  107912. /**
  107913. * Returns the render target texture used by the post-process
  107914. * @return the render target texture used by the post-process
  107915. */
  107916. getPass(): RenderTargetTexture;
  107917. private _meshExcluded;
  107918. private _createPass;
  107919. private _updateMeshScreenCoordinates;
  107920. /**
  107921. * Creates a default mesh for the Volumeric Light Scattering post-process
  107922. * @param name The mesh name
  107923. * @param scene The scene where to create the mesh
  107924. * @return the default mesh
  107925. */
  107926. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107927. }
  107928. }
  107929. declare module BABYLON {
  107930. interface Scene {
  107931. /** @hidden (Backing field) */
  107932. _boundingBoxRenderer: BoundingBoxRenderer;
  107933. /** @hidden (Backing field) */
  107934. _forceShowBoundingBoxes: boolean;
  107935. /**
  107936. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  107937. */
  107938. forceShowBoundingBoxes: boolean;
  107939. /**
  107940. * Gets the bounding box renderer associated with the scene
  107941. * @returns a BoundingBoxRenderer
  107942. */
  107943. getBoundingBoxRenderer(): BoundingBoxRenderer;
  107944. }
  107945. interface AbstractMesh {
  107946. /** @hidden (Backing field) */
  107947. _showBoundingBox: boolean;
  107948. /**
  107949. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  107950. */
  107951. showBoundingBox: boolean;
  107952. }
  107953. /**
  107954. * Component responsible of rendering the bounding box of the meshes in a scene.
  107955. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  107956. */
  107957. export class BoundingBoxRenderer implements ISceneComponent {
  107958. /**
  107959. * The component name helpfull to identify the component in the list of scene components.
  107960. */
  107961. readonly name: string;
  107962. /**
  107963. * The scene the component belongs to.
  107964. */
  107965. scene: Scene;
  107966. /**
  107967. * Color of the bounding box lines placed in front of an object
  107968. */
  107969. frontColor: Color3;
  107970. /**
  107971. * Color of the bounding box lines placed behind an object
  107972. */
  107973. backColor: Color3;
  107974. /**
  107975. * Defines if the renderer should show the back lines or not
  107976. */
  107977. showBackLines: boolean;
  107978. /**
  107979. * @hidden
  107980. */
  107981. renderList: SmartArray<BoundingBox>;
  107982. private _colorShader;
  107983. private _vertexBuffers;
  107984. private _indexBuffer;
  107985. /**
  107986. * Instantiates a new bounding box renderer in a scene.
  107987. * @param scene the scene the renderer renders in
  107988. */
  107989. constructor(scene: Scene);
  107990. /**
  107991. * Registers the component in a given scene
  107992. */
  107993. register(): void;
  107994. private _evaluateSubMesh;
  107995. private _activeMesh;
  107996. private _prepareRessources;
  107997. private _createIndexBuffer;
  107998. /**
  107999. * Rebuilds the elements related to this component in case of
  108000. * context lost for instance.
  108001. */
  108002. rebuild(): void;
  108003. /**
  108004. * @hidden
  108005. */
  108006. reset(): void;
  108007. /**
  108008. * Render the bounding boxes of a specific rendering group
  108009. * @param renderingGroupId defines the rendering group to render
  108010. */
  108011. render(renderingGroupId: number): void;
  108012. /**
  108013. * In case of occlusion queries, we can render the occlusion bounding box through this method
  108014. * @param mesh Define the mesh to render the occlusion bounding box for
  108015. */
  108016. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  108017. /**
  108018. * Dispose and release the resources attached to this renderer.
  108019. */
  108020. dispose(): void;
  108021. }
  108022. }
  108023. declare module BABYLON {
  108024. /** @hidden */
  108025. export var depthPixelShader: {
  108026. name: string;
  108027. shader: string;
  108028. };
  108029. }
  108030. declare module BABYLON {
  108031. /**
  108032. * This represents a depth renderer in Babylon.
  108033. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108034. */
  108035. export class DepthRenderer {
  108036. private _scene;
  108037. private _depthMap;
  108038. private _effect;
  108039. private _cachedDefines;
  108040. private _camera;
  108041. /**
  108042. * Specifiess that the depth renderer will only be used within
  108043. * the camera it is created for.
  108044. * This can help forcing its rendering during the camera processing.
  108045. */
  108046. useOnlyInActiveCamera: boolean;
  108047. /** @hidden */
  108048. static _SceneComponentInitialization: (scene: Scene) => void;
  108049. /**
  108050. * Instantiates a depth renderer
  108051. * @param scene The scene the renderer belongs to
  108052. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108053. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108054. */
  108055. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108056. /**
  108057. * Creates the depth rendering effect and checks if the effect is ready.
  108058. * @param subMesh The submesh to be used to render the depth map of
  108059. * @param useInstances If multiple world instances should be used
  108060. * @returns if the depth renderer is ready to render the depth map
  108061. */
  108062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108063. /**
  108064. * Gets the texture which the depth map will be written to.
  108065. * @returns The depth map texture
  108066. */
  108067. getDepthMap(): RenderTargetTexture;
  108068. /**
  108069. * Disposes of the depth renderer.
  108070. */
  108071. dispose(): void;
  108072. }
  108073. }
  108074. declare module BABYLON {
  108075. interface Scene {
  108076. /** @hidden (Backing field) */
  108077. _depthRenderer: {
  108078. [id: string]: DepthRenderer;
  108079. };
  108080. /**
  108081. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108082. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108083. * @returns the created depth renderer
  108084. */
  108085. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108086. /**
  108087. * Disables a depth renderer for a given camera
  108088. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108089. */
  108090. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108091. }
  108092. /**
  108093. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108094. * in several rendering techniques.
  108095. */
  108096. export class DepthRendererSceneComponent implements ISceneComponent {
  108097. /**
  108098. * The component name helpfull to identify the component in the list of scene components.
  108099. */
  108100. readonly name: string;
  108101. /**
  108102. * The scene the component belongs to.
  108103. */
  108104. scene: Scene;
  108105. /**
  108106. * Creates a new instance of the component for the given scene
  108107. * @param scene Defines the scene to register the component in
  108108. */
  108109. constructor(scene: Scene);
  108110. /**
  108111. * Registers the component in a given scene
  108112. */
  108113. register(): void;
  108114. /**
  108115. * Rebuilds the elements related to this component in case of
  108116. * context lost for instance.
  108117. */
  108118. rebuild(): void;
  108119. /**
  108120. * Disposes the component and the associated ressources
  108121. */
  108122. dispose(): void;
  108123. private _gatherRenderTargets;
  108124. private _gatherActiveCameraRenderTargets;
  108125. }
  108126. }
  108127. declare module BABYLON {
  108128. interface Scene {
  108129. /** @hidden (Backing field) */
  108130. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108131. /**
  108132. * Gets or Sets the current geometry buffer associated to the scene.
  108133. */
  108134. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108135. /**
  108136. * Enables a GeometryBufferRender and associates it with the scene
  108137. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108138. * @returns the GeometryBufferRenderer
  108139. */
  108140. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108141. /**
  108142. * Disables the GeometryBufferRender associated with the scene
  108143. */
  108144. disableGeometryBufferRenderer(): void;
  108145. }
  108146. /**
  108147. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108148. * in several rendering techniques.
  108149. */
  108150. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108151. /**
  108152. * The component name helpful to identify the component in the list of scene components.
  108153. */
  108154. readonly name: string;
  108155. /**
  108156. * The scene the component belongs to.
  108157. */
  108158. scene: Scene;
  108159. /**
  108160. * Creates a new instance of the component for the given scene
  108161. * @param scene Defines the scene to register the component in
  108162. */
  108163. constructor(scene: Scene);
  108164. /**
  108165. * Registers the component in a given scene
  108166. */
  108167. register(): void;
  108168. /**
  108169. * Rebuilds the elements related to this component in case of
  108170. * context lost for instance.
  108171. */
  108172. rebuild(): void;
  108173. /**
  108174. * Disposes the component and the associated ressources
  108175. */
  108176. dispose(): void;
  108177. private _gatherRenderTargets;
  108178. }
  108179. }
  108180. declare module BABYLON {
  108181. /** @hidden */
  108182. export var outlinePixelShader: {
  108183. name: string;
  108184. shader: string;
  108185. };
  108186. }
  108187. declare module BABYLON {
  108188. /** @hidden */
  108189. export var outlineVertexShader: {
  108190. name: string;
  108191. shader: string;
  108192. };
  108193. }
  108194. declare module BABYLON {
  108195. interface Scene {
  108196. /** @hidden */
  108197. _outlineRenderer: OutlineRenderer;
  108198. /**
  108199. * Gets the outline renderer associated with the scene
  108200. * @returns a OutlineRenderer
  108201. */
  108202. getOutlineRenderer(): OutlineRenderer;
  108203. }
  108204. interface AbstractMesh {
  108205. /** @hidden (Backing field) */
  108206. _renderOutline: boolean;
  108207. /**
  108208. * Gets or sets a boolean indicating if the outline must be rendered as well
  108209. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108210. */
  108211. renderOutline: boolean;
  108212. /** @hidden (Backing field) */
  108213. _renderOverlay: boolean;
  108214. /**
  108215. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108216. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108217. */
  108218. renderOverlay: boolean;
  108219. }
  108220. /**
  108221. * This class is responsible to draw bothe outline/overlay of meshes.
  108222. * It should not be used directly but through the available method on mesh.
  108223. */
  108224. export class OutlineRenderer implements ISceneComponent {
  108225. /**
  108226. * The name of the component. Each component must have a unique name.
  108227. */
  108228. name: string;
  108229. /**
  108230. * The scene the component belongs to.
  108231. */
  108232. scene: Scene;
  108233. /**
  108234. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108235. */
  108236. zOffset: number;
  108237. private _engine;
  108238. private _effect;
  108239. private _cachedDefines;
  108240. private _savedDepthWrite;
  108241. /**
  108242. * Instantiates a new outline renderer. (There could be only one per scene).
  108243. * @param scene Defines the scene it belongs to
  108244. */
  108245. constructor(scene: Scene);
  108246. /**
  108247. * Register the component to one instance of a scene.
  108248. */
  108249. register(): void;
  108250. /**
  108251. * Rebuilds the elements related to this component in case of
  108252. * context lost for instance.
  108253. */
  108254. rebuild(): void;
  108255. /**
  108256. * Disposes the component and the associated ressources.
  108257. */
  108258. dispose(): void;
  108259. /**
  108260. * Renders the outline in the canvas.
  108261. * @param subMesh Defines the sumesh to render
  108262. * @param batch Defines the batch of meshes in case of instances
  108263. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108264. */
  108265. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108266. /**
  108267. * Returns whether or not the outline renderer is ready for a given submesh.
  108268. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108269. * @param subMesh Defines the submesh to check readyness for
  108270. * @param useInstances Defines wheter wee are trying to render instances or not
  108271. * @returns true if ready otherwise false
  108272. */
  108273. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108274. private _beforeRenderingMesh;
  108275. private _afterRenderingMesh;
  108276. }
  108277. }
  108278. declare module BABYLON {
  108279. /**
  108280. * Defines the list of states available for a task inside a AssetsManager
  108281. */
  108282. export enum AssetTaskState {
  108283. /**
  108284. * Initialization
  108285. */
  108286. INIT = 0,
  108287. /**
  108288. * Running
  108289. */
  108290. RUNNING = 1,
  108291. /**
  108292. * Done
  108293. */
  108294. DONE = 2,
  108295. /**
  108296. * Error
  108297. */
  108298. ERROR = 3
  108299. }
  108300. /**
  108301. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108302. */
  108303. export abstract class AbstractAssetTask {
  108304. /**
  108305. * Task name
  108306. */ name: string;
  108307. /**
  108308. * Callback called when the task is successful
  108309. */
  108310. onSuccess: (task: any) => void;
  108311. /**
  108312. * Callback called when the task is not successful
  108313. */
  108314. onError: (task: any, message?: string, exception?: any) => void;
  108315. /**
  108316. * Creates a new AssetsManager
  108317. * @param name defines the name of the task
  108318. */
  108319. constructor(
  108320. /**
  108321. * Task name
  108322. */ name: string);
  108323. private _isCompleted;
  108324. private _taskState;
  108325. private _errorObject;
  108326. /**
  108327. * Get if the task is completed
  108328. */
  108329. readonly isCompleted: boolean;
  108330. /**
  108331. * Gets the current state of the task
  108332. */
  108333. readonly taskState: AssetTaskState;
  108334. /**
  108335. * Gets the current error object (if task is in error)
  108336. */
  108337. readonly errorObject: {
  108338. message?: string;
  108339. exception?: any;
  108340. };
  108341. /**
  108342. * Internal only
  108343. * @hidden
  108344. */
  108345. _setErrorObject(message?: string, exception?: any): void;
  108346. /**
  108347. * Execute the current task
  108348. * @param scene defines the scene where you want your assets to be loaded
  108349. * @param onSuccess is a callback called when the task is successfully executed
  108350. * @param onError is a callback called if an error occurs
  108351. */
  108352. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108353. /**
  108354. * Execute the current task
  108355. * @param scene defines the scene where you want your assets to be loaded
  108356. * @param onSuccess is a callback called when the task is successfully executed
  108357. * @param onError is a callback called if an error occurs
  108358. */
  108359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108360. /**
  108361. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108362. * This can be used with failed tasks that have the reason for failure fixed.
  108363. */
  108364. reset(): void;
  108365. private onErrorCallback;
  108366. private onDoneCallback;
  108367. }
  108368. /**
  108369. * Define the interface used by progress events raised during assets loading
  108370. */
  108371. export interface IAssetsProgressEvent {
  108372. /**
  108373. * Defines the number of remaining tasks to process
  108374. */
  108375. remainingCount: number;
  108376. /**
  108377. * Defines the total number of tasks
  108378. */
  108379. totalCount: number;
  108380. /**
  108381. * Defines the task that was just processed
  108382. */
  108383. task: AbstractAssetTask;
  108384. }
  108385. /**
  108386. * Class used to share progress information about assets loading
  108387. */
  108388. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108389. /**
  108390. * Defines the number of remaining tasks to process
  108391. */
  108392. remainingCount: number;
  108393. /**
  108394. * Defines the total number of tasks
  108395. */
  108396. totalCount: number;
  108397. /**
  108398. * Defines the task that was just processed
  108399. */
  108400. task: AbstractAssetTask;
  108401. /**
  108402. * Creates a AssetsProgressEvent
  108403. * @param remainingCount defines the number of remaining tasks to process
  108404. * @param totalCount defines the total number of tasks
  108405. * @param task defines the task that was just processed
  108406. */
  108407. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108408. }
  108409. /**
  108410. * Define a task used by AssetsManager to load meshes
  108411. */
  108412. export class MeshAssetTask extends AbstractAssetTask {
  108413. /**
  108414. * Defines the name of the task
  108415. */
  108416. name: string;
  108417. /**
  108418. * Defines the list of mesh's names you want to load
  108419. */
  108420. meshesNames: any;
  108421. /**
  108422. * Defines the root url to use as a base to load your meshes and associated resources
  108423. */
  108424. rootUrl: string;
  108425. /**
  108426. * Defines the filename of the scene to load from
  108427. */
  108428. sceneFilename: string;
  108429. /**
  108430. * Gets the list of loaded meshes
  108431. */
  108432. loadedMeshes: Array<AbstractMesh>;
  108433. /**
  108434. * Gets the list of loaded particle systems
  108435. */
  108436. loadedParticleSystems: Array<IParticleSystem>;
  108437. /**
  108438. * Gets the list of loaded skeletons
  108439. */
  108440. loadedSkeletons: Array<Skeleton>;
  108441. /**
  108442. * Gets the list of loaded animation groups
  108443. */
  108444. loadedAnimationGroups: Array<AnimationGroup>;
  108445. /**
  108446. * Callback called when the task is successful
  108447. */
  108448. onSuccess: (task: MeshAssetTask) => void;
  108449. /**
  108450. * Callback called when the task is successful
  108451. */
  108452. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108453. /**
  108454. * Creates a new MeshAssetTask
  108455. * @param name defines the name of the task
  108456. * @param meshesNames defines the list of mesh's names you want to load
  108457. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108458. * @param sceneFilename defines the filename of the scene to load from
  108459. */
  108460. constructor(
  108461. /**
  108462. * Defines the name of the task
  108463. */
  108464. name: string,
  108465. /**
  108466. * Defines the list of mesh's names you want to load
  108467. */
  108468. meshesNames: any,
  108469. /**
  108470. * Defines the root url to use as a base to load your meshes and associated resources
  108471. */
  108472. rootUrl: string,
  108473. /**
  108474. * Defines the filename of the scene to load from
  108475. */
  108476. sceneFilename: string);
  108477. /**
  108478. * Execute the current task
  108479. * @param scene defines the scene where you want your assets to be loaded
  108480. * @param onSuccess is a callback called when the task is successfully executed
  108481. * @param onError is a callback called if an error occurs
  108482. */
  108483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108484. }
  108485. /**
  108486. * Define a task used by AssetsManager to load text content
  108487. */
  108488. export class TextFileAssetTask extends AbstractAssetTask {
  108489. /**
  108490. * Defines the name of the task
  108491. */
  108492. name: string;
  108493. /**
  108494. * Defines the location of the file to load
  108495. */
  108496. url: string;
  108497. /**
  108498. * Gets the loaded text string
  108499. */
  108500. text: string;
  108501. /**
  108502. * Callback called when the task is successful
  108503. */
  108504. onSuccess: (task: TextFileAssetTask) => void;
  108505. /**
  108506. * Callback called when the task is successful
  108507. */
  108508. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108509. /**
  108510. * Creates a new TextFileAssetTask object
  108511. * @param name defines the name of the task
  108512. * @param url defines the location of the file to load
  108513. */
  108514. constructor(
  108515. /**
  108516. * Defines the name of the task
  108517. */
  108518. name: string,
  108519. /**
  108520. * Defines the location of the file to load
  108521. */
  108522. url: string);
  108523. /**
  108524. * Execute the current task
  108525. * @param scene defines the scene where you want your assets to be loaded
  108526. * @param onSuccess is a callback called when the task is successfully executed
  108527. * @param onError is a callback called if an error occurs
  108528. */
  108529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108530. }
  108531. /**
  108532. * Define a task used by AssetsManager to load binary data
  108533. */
  108534. export class BinaryFileAssetTask extends AbstractAssetTask {
  108535. /**
  108536. * Defines the name of the task
  108537. */
  108538. name: string;
  108539. /**
  108540. * Defines the location of the file to load
  108541. */
  108542. url: string;
  108543. /**
  108544. * Gets the lodaded data (as an array buffer)
  108545. */
  108546. data: ArrayBuffer;
  108547. /**
  108548. * Callback called when the task is successful
  108549. */
  108550. onSuccess: (task: BinaryFileAssetTask) => void;
  108551. /**
  108552. * Callback called when the task is successful
  108553. */
  108554. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108555. /**
  108556. * Creates a new BinaryFileAssetTask object
  108557. * @param name defines the name of the new task
  108558. * @param url defines the location of the file to load
  108559. */
  108560. constructor(
  108561. /**
  108562. * Defines the name of the task
  108563. */
  108564. name: string,
  108565. /**
  108566. * Defines the location of the file to load
  108567. */
  108568. url: string);
  108569. /**
  108570. * Execute the current task
  108571. * @param scene defines the scene where you want your assets to be loaded
  108572. * @param onSuccess is a callback called when the task is successfully executed
  108573. * @param onError is a callback called if an error occurs
  108574. */
  108575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108576. }
  108577. /**
  108578. * Define a task used by AssetsManager to load images
  108579. */
  108580. export class ImageAssetTask extends AbstractAssetTask {
  108581. /**
  108582. * Defines the name of the task
  108583. */
  108584. name: string;
  108585. /**
  108586. * Defines the location of the image to load
  108587. */
  108588. url: string;
  108589. /**
  108590. * Gets the loaded images
  108591. */
  108592. image: HTMLImageElement;
  108593. /**
  108594. * Callback called when the task is successful
  108595. */
  108596. onSuccess: (task: ImageAssetTask) => void;
  108597. /**
  108598. * Callback called when the task is successful
  108599. */
  108600. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108601. /**
  108602. * Creates a new ImageAssetTask
  108603. * @param name defines the name of the task
  108604. * @param url defines the location of the image to load
  108605. */
  108606. constructor(
  108607. /**
  108608. * Defines the name of the task
  108609. */
  108610. name: string,
  108611. /**
  108612. * Defines the location of the image to load
  108613. */
  108614. url: string);
  108615. /**
  108616. * Execute the current task
  108617. * @param scene defines the scene where you want your assets to be loaded
  108618. * @param onSuccess is a callback called when the task is successfully executed
  108619. * @param onError is a callback called if an error occurs
  108620. */
  108621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108622. }
  108623. /**
  108624. * Defines the interface used by texture loading tasks
  108625. */
  108626. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108627. /**
  108628. * Gets the loaded texture
  108629. */
  108630. texture: TEX;
  108631. }
  108632. /**
  108633. * Define a task used by AssetsManager to load 2D textures
  108634. */
  108635. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108636. /**
  108637. * Defines the name of the task
  108638. */
  108639. name: string;
  108640. /**
  108641. * Defines the location of the file to load
  108642. */
  108643. url: string;
  108644. /**
  108645. * Defines if mipmap should not be generated (default is false)
  108646. */
  108647. noMipmap?: boolean | undefined;
  108648. /**
  108649. * Defines if texture must be inverted on Y axis (default is false)
  108650. */
  108651. invertY?: boolean | undefined;
  108652. /**
  108653. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108654. */
  108655. samplingMode: number;
  108656. /**
  108657. * Gets the loaded texture
  108658. */
  108659. texture: Texture;
  108660. /**
  108661. * Callback called when the task is successful
  108662. */
  108663. onSuccess: (task: TextureAssetTask) => void;
  108664. /**
  108665. * Callback called when the task is successful
  108666. */
  108667. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108668. /**
  108669. * Creates a new TextureAssetTask object
  108670. * @param name defines the name of the task
  108671. * @param url defines the location of the file to load
  108672. * @param noMipmap defines if mipmap should not be generated (default is false)
  108673. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108674. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108675. */
  108676. constructor(
  108677. /**
  108678. * Defines the name of the task
  108679. */
  108680. name: string,
  108681. /**
  108682. * Defines the location of the file to load
  108683. */
  108684. url: string,
  108685. /**
  108686. * Defines if mipmap should not be generated (default is false)
  108687. */
  108688. noMipmap?: boolean | undefined,
  108689. /**
  108690. * Defines if texture must be inverted on Y axis (default is false)
  108691. */
  108692. invertY?: boolean | undefined,
  108693. /**
  108694. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108695. */
  108696. samplingMode?: number);
  108697. /**
  108698. * Execute the current task
  108699. * @param scene defines the scene where you want your assets to be loaded
  108700. * @param onSuccess is a callback called when the task is successfully executed
  108701. * @param onError is a callback called if an error occurs
  108702. */
  108703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108704. }
  108705. /**
  108706. * Define a task used by AssetsManager to load cube textures
  108707. */
  108708. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108709. /**
  108710. * Defines the name of the task
  108711. */
  108712. name: string;
  108713. /**
  108714. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108715. */
  108716. url: string;
  108717. /**
  108718. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108719. */
  108720. extensions?: string[] | undefined;
  108721. /**
  108722. * Defines if mipmaps should not be generated (default is false)
  108723. */
  108724. noMipmap?: boolean | undefined;
  108725. /**
  108726. * Defines the explicit list of files (undefined by default)
  108727. */
  108728. files?: string[] | undefined;
  108729. /**
  108730. * Gets the loaded texture
  108731. */
  108732. texture: CubeTexture;
  108733. /**
  108734. * Callback called when the task is successful
  108735. */
  108736. onSuccess: (task: CubeTextureAssetTask) => void;
  108737. /**
  108738. * Callback called when the task is successful
  108739. */
  108740. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108741. /**
  108742. * Creates a new CubeTextureAssetTask
  108743. * @param name defines the name of the task
  108744. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108745. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108746. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108747. * @param files defines the explicit list of files (undefined by default)
  108748. */
  108749. constructor(
  108750. /**
  108751. * Defines the name of the task
  108752. */
  108753. name: string,
  108754. /**
  108755. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108756. */
  108757. url: string,
  108758. /**
  108759. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108760. */
  108761. extensions?: string[] | undefined,
  108762. /**
  108763. * Defines if mipmaps should not be generated (default is false)
  108764. */
  108765. noMipmap?: boolean | undefined,
  108766. /**
  108767. * Defines the explicit list of files (undefined by default)
  108768. */
  108769. files?: string[] | undefined);
  108770. /**
  108771. * Execute the current task
  108772. * @param scene defines the scene where you want your assets to be loaded
  108773. * @param onSuccess is a callback called when the task is successfully executed
  108774. * @param onError is a callback called if an error occurs
  108775. */
  108776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108777. }
  108778. /**
  108779. * Define a task used by AssetsManager to load HDR cube textures
  108780. */
  108781. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108782. /**
  108783. * Defines the name of the task
  108784. */
  108785. name: string;
  108786. /**
  108787. * Defines the location of the file to load
  108788. */
  108789. url: string;
  108790. /**
  108791. * Defines the desired size (the more it increases the longer the generation will be)
  108792. */
  108793. size: number;
  108794. /**
  108795. * Defines if mipmaps should not be generated (default is false)
  108796. */
  108797. noMipmap: boolean;
  108798. /**
  108799. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108800. */
  108801. generateHarmonics: boolean;
  108802. /**
  108803. * 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)
  108804. */
  108805. gammaSpace: boolean;
  108806. /**
  108807. * Internal Use Only
  108808. */
  108809. reserved: boolean;
  108810. /**
  108811. * Gets the loaded texture
  108812. */
  108813. texture: HDRCubeTexture;
  108814. /**
  108815. * Callback called when the task is successful
  108816. */
  108817. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108818. /**
  108819. * Callback called when the task is successful
  108820. */
  108821. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108822. /**
  108823. * Creates a new HDRCubeTextureAssetTask object
  108824. * @param name defines the name of the task
  108825. * @param url defines the location of the file to load
  108826. * @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.
  108827. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108828. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108829. * @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)
  108830. * @param reserved Internal use only
  108831. */
  108832. constructor(
  108833. /**
  108834. * Defines the name of the task
  108835. */
  108836. name: string,
  108837. /**
  108838. * Defines the location of the file to load
  108839. */
  108840. url: string,
  108841. /**
  108842. * Defines the desired size (the more it increases the longer the generation will be)
  108843. */
  108844. size: number,
  108845. /**
  108846. * Defines if mipmaps should not be generated (default is false)
  108847. */
  108848. noMipmap?: boolean,
  108849. /**
  108850. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108851. */
  108852. generateHarmonics?: boolean,
  108853. /**
  108854. * 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)
  108855. */
  108856. gammaSpace?: boolean,
  108857. /**
  108858. * Internal Use Only
  108859. */
  108860. reserved?: boolean);
  108861. /**
  108862. * Execute the current task
  108863. * @param scene defines the scene where you want your assets to be loaded
  108864. * @param onSuccess is a callback called when the task is successfully executed
  108865. * @param onError is a callback called if an error occurs
  108866. */
  108867. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108868. }
  108869. /**
  108870. * This class can be used to easily import assets into a scene
  108871. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108872. */
  108873. export class AssetsManager {
  108874. private _scene;
  108875. private _isLoading;
  108876. protected _tasks: AbstractAssetTask[];
  108877. protected _waitingTasksCount: number;
  108878. protected _totalTasksCount: number;
  108879. /**
  108880. * Callback called when all tasks are processed
  108881. */
  108882. onFinish: (tasks: AbstractAssetTask[]) => void;
  108883. /**
  108884. * Callback called when a task is successful
  108885. */
  108886. onTaskSuccess: (task: AbstractAssetTask) => void;
  108887. /**
  108888. * Callback called when a task had an error
  108889. */
  108890. onTaskError: (task: AbstractAssetTask) => void;
  108891. /**
  108892. * Callback called when a task is done (whatever the result is)
  108893. */
  108894. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108895. /**
  108896. * Observable called when all tasks are processed
  108897. */
  108898. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108899. /**
  108900. * Observable called when a task had an error
  108901. */
  108902. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108903. /**
  108904. * Observable called when a task is successful
  108905. */
  108906. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108907. /**
  108908. * Observable called when a task is done (whatever the result is)
  108909. */
  108910. onProgressObservable: Observable<IAssetsProgressEvent>;
  108911. /**
  108912. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108914. */
  108915. useDefaultLoadingScreen: boolean;
  108916. /**
  108917. * Creates a new AssetsManager
  108918. * @param scene defines the scene to work on
  108919. */
  108920. constructor(scene: Scene);
  108921. /**
  108922. * Add a MeshAssetTask to the list of active tasks
  108923. * @param taskName defines the name of the new task
  108924. * @param meshesNames defines the name of meshes to load
  108925. * @param rootUrl defines the root url to use to locate files
  108926. * @param sceneFilename defines the filename of the scene file
  108927. * @returns a new MeshAssetTask object
  108928. */
  108929. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108930. /**
  108931. * Add a TextFileAssetTask to the list of active tasks
  108932. * @param taskName defines the name of the new task
  108933. * @param url defines the url of the file to load
  108934. * @returns a new TextFileAssetTask object
  108935. */
  108936. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  108937. /**
  108938. * Add a BinaryFileAssetTask to the list of active tasks
  108939. * @param taskName defines the name of the new task
  108940. * @param url defines the url of the file to load
  108941. * @returns a new BinaryFileAssetTask object
  108942. */
  108943. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  108944. /**
  108945. * Add a ImageAssetTask to the list of active tasks
  108946. * @param taskName defines the name of the new task
  108947. * @param url defines the url of the file to load
  108948. * @returns a new ImageAssetTask object
  108949. */
  108950. addImageTask(taskName: string, url: string): ImageAssetTask;
  108951. /**
  108952. * Add a TextureAssetTask to the list of active tasks
  108953. * @param taskName defines the name of the new task
  108954. * @param url defines the url of the file to load
  108955. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108956. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  108957. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108958. * @returns a new TextureAssetTask object
  108959. */
  108960. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  108961. /**
  108962. * Add a CubeTextureAssetTask to the list of active tasks
  108963. * @param taskName defines the name of the new task
  108964. * @param url defines the url of the file to load
  108965. * @param extensions defines the extension to use to load the cube map (can be null)
  108966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108967. * @param files defines the list of files to load (can be null)
  108968. * @returns a new CubeTextureAssetTask object
  108969. */
  108970. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  108971. /**
  108972. *
  108973. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108974. * @param taskName defines the name of the new task
  108975. * @param url defines the url of the file to load
  108976. * @param size defines the size you want for the cubemap (can be null)
  108977. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108978. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108979. * @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)
  108980. * @param reserved Internal use only
  108981. * @returns a new HDRCubeTextureAssetTask object
  108982. */
  108983. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  108984. /**
  108985. * Remove a task from the assets manager.
  108986. * @param task the task to remove
  108987. */
  108988. removeTask(task: AbstractAssetTask): void;
  108989. private _decreaseWaitingTasksCount;
  108990. private _runTask;
  108991. /**
  108992. * Reset the AssetsManager and remove all tasks
  108993. * @return the current instance of the AssetsManager
  108994. */
  108995. reset(): AssetsManager;
  108996. /**
  108997. * Start the loading process
  108998. * @return the current instance of the AssetsManager
  108999. */
  109000. load(): AssetsManager;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * Wrapper class for promise with external resolve and reject.
  109006. */
  109007. export class Deferred<T> {
  109008. /**
  109009. * The promise associated with this deferred object.
  109010. */
  109011. readonly promise: Promise<T>;
  109012. private _resolve;
  109013. private _reject;
  109014. /**
  109015. * The resolve method of the promise associated with this deferred object.
  109016. */
  109017. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  109018. /**
  109019. * The reject method of the promise associated with this deferred object.
  109020. */
  109021. readonly reject: (reason?: any) => void;
  109022. /**
  109023. * Constructor for this deferred object.
  109024. */
  109025. constructor();
  109026. }
  109027. }
  109028. declare module BABYLON {
  109029. /**
  109030. * Class used to help managing file picking and drag'n'drop
  109031. */
  109032. export class FilesInput {
  109033. /**
  109034. * List of files ready to be loaded
  109035. */
  109036. static readonly FilesToLoad: {
  109037. [key: string]: File;
  109038. };
  109039. /**
  109040. * Callback called when a file is processed
  109041. */
  109042. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109043. private _engine;
  109044. private _currentScene;
  109045. private _sceneLoadedCallback;
  109046. private _progressCallback;
  109047. private _additionalRenderLoopLogicCallback;
  109048. private _textureLoadingCallback;
  109049. private _startingProcessingFilesCallback;
  109050. private _onReloadCallback;
  109051. private _errorCallback;
  109052. private _elementToMonitor;
  109053. private _sceneFileToLoad;
  109054. private _filesToLoad;
  109055. /**
  109056. * Creates a new FilesInput
  109057. * @param engine defines the rendering engine
  109058. * @param scene defines the hosting scene
  109059. * @param sceneLoadedCallback callback called when scene is loaded
  109060. * @param progressCallback callback called to track progress
  109061. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  109062. * @param textureLoadingCallback callback called when a texture is loading
  109063. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  109064. * @param onReloadCallback callback called when a reload is requested
  109065. * @param errorCallback callback call if an error occurs
  109066. */
  109067. 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);
  109068. private _dragEnterHandler;
  109069. private _dragOverHandler;
  109070. private _dropHandler;
  109071. /**
  109072. * Calls this function to listen to drag'n'drop events on a specific DOM element
  109073. * @param elementToMonitor defines the DOM element to track
  109074. */
  109075. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  109076. /**
  109077. * Release all associated resources
  109078. */
  109079. dispose(): void;
  109080. private renderFunction;
  109081. private drag;
  109082. private drop;
  109083. private _traverseFolder;
  109084. private _processFiles;
  109085. /**
  109086. * Load files from a drop event
  109087. * @param event defines the drop event to use as source
  109088. */
  109089. loadFiles(event: any): void;
  109090. private _processReload;
  109091. /**
  109092. * Reload the current scene from the loaded files
  109093. */
  109094. reload(): void;
  109095. }
  109096. }
  109097. declare module BABYLON {
  109098. /**
  109099. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109101. */
  109102. export class SceneOptimization {
  109103. /**
  109104. * Defines the priority of this optimization (0 by default which means first in the list)
  109105. */
  109106. priority: number;
  109107. /**
  109108. * Gets a string describing the action executed by the current optimization
  109109. * @returns description string
  109110. */
  109111. getDescription(): string;
  109112. /**
  109113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109114. * @param scene defines the current scene where to apply this optimization
  109115. * @param optimizer defines the current optimizer
  109116. * @returns true if everything that can be done was applied
  109117. */
  109118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109119. /**
  109120. * Creates the SceneOptimization object
  109121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109122. * @param desc defines the description associated with the optimization
  109123. */
  109124. constructor(
  109125. /**
  109126. * Defines the priority of this optimization (0 by default which means first in the list)
  109127. */
  109128. priority?: number);
  109129. }
  109130. /**
  109131. * Defines an optimization used to reduce the size of render target textures
  109132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109133. */
  109134. export class TextureOptimization extends SceneOptimization {
  109135. /**
  109136. * Defines the priority of this optimization (0 by default which means first in the list)
  109137. */
  109138. priority: number;
  109139. /**
  109140. * 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
  109141. */
  109142. maximumSize: number;
  109143. /**
  109144. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109145. */
  109146. step: number;
  109147. /**
  109148. * Gets a string describing the action executed by the current optimization
  109149. * @returns description string
  109150. */
  109151. getDescription(): string;
  109152. /**
  109153. * Creates the TextureOptimization object
  109154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109155. * @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
  109156. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109157. */
  109158. constructor(
  109159. /**
  109160. * Defines the priority of this optimization (0 by default which means first in the list)
  109161. */
  109162. priority?: number,
  109163. /**
  109164. * 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
  109165. */
  109166. maximumSize?: number,
  109167. /**
  109168. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109169. */
  109170. step?: number);
  109171. /**
  109172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109173. * @param scene defines the current scene where to apply this optimization
  109174. * @param optimizer defines the current optimizer
  109175. * @returns true if everything that can be done was applied
  109176. */
  109177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109178. }
  109179. /**
  109180. * Defines an optimization used to increase or decrease the rendering resolution
  109181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109182. */
  109183. export class HardwareScalingOptimization extends SceneOptimization {
  109184. /**
  109185. * Defines the priority of this optimization (0 by default which means first in the list)
  109186. */
  109187. priority: number;
  109188. /**
  109189. * Defines the maximum scale to use (2 by default)
  109190. */
  109191. maximumScale: number;
  109192. /**
  109193. * Defines the step to use between two passes (0.5 by default)
  109194. */
  109195. step: number;
  109196. private _currentScale;
  109197. private _directionOffset;
  109198. /**
  109199. * Gets a string describing the action executed by the current optimization
  109200. * @return description string
  109201. */
  109202. getDescription(): string;
  109203. /**
  109204. * Creates the HardwareScalingOptimization object
  109205. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109206. * @param maximumScale defines the maximum scale to use (2 by default)
  109207. * @param step defines the step to use between two passes (0.5 by default)
  109208. */
  109209. constructor(
  109210. /**
  109211. * Defines the priority of this optimization (0 by default which means first in the list)
  109212. */
  109213. priority?: number,
  109214. /**
  109215. * Defines the maximum scale to use (2 by default)
  109216. */
  109217. maximumScale?: number,
  109218. /**
  109219. * Defines the step to use between two passes (0.5 by default)
  109220. */
  109221. step?: number);
  109222. /**
  109223. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109224. * @param scene defines the current scene where to apply this optimization
  109225. * @param optimizer defines the current optimizer
  109226. * @returns true if everything that can be done was applied
  109227. */
  109228. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109229. }
  109230. /**
  109231. * Defines an optimization used to remove shadows
  109232. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109233. */
  109234. export class ShadowsOptimization extends SceneOptimization {
  109235. /**
  109236. * Gets a string describing the action executed by the current optimization
  109237. * @return description string
  109238. */
  109239. getDescription(): string;
  109240. /**
  109241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109242. * @param scene defines the current scene where to apply this optimization
  109243. * @param optimizer defines the current optimizer
  109244. * @returns true if everything that can be done was applied
  109245. */
  109246. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109247. }
  109248. /**
  109249. * Defines an optimization used to turn post-processes off
  109250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109251. */
  109252. export class PostProcessesOptimization extends SceneOptimization {
  109253. /**
  109254. * Gets a string describing the action executed by the current optimization
  109255. * @return description string
  109256. */
  109257. getDescription(): string;
  109258. /**
  109259. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109260. * @param scene defines the current scene where to apply this optimization
  109261. * @param optimizer defines the current optimizer
  109262. * @returns true if everything that can be done was applied
  109263. */
  109264. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109265. }
  109266. /**
  109267. * Defines an optimization used to turn lens flares off
  109268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109269. */
  109270. export class LensFlaresOptimization extends SceneOptimization {
  109271. /**
  109272. * Gets a string describing the action executed by the current optimization
  109273. * @return description string
  109274. */
  109275. getDescription(): string;
  109276. /**
  109277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109278. * @param scene defines the current scene where to apply this optimization
  109279. * @param optimizer defines the current optimizer
  109280. * @returns true if everything that can be done was applied
  109281. */
  109282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109283. }
  109284. /**
  109285. * Defines an optimization based on user defined callback.
  109286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109287. */
  109288. export class CustomOptimization extends SceneOptimization {
  109289. /**
  109290. * Callback called to apply the custom optimization.
  109291. */
  109292. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109293. /**
  109294. * Callback called to get custom description
  109295. */
  109296. onGetDescription: () => string;
  109297. /**
  109298. * Gets a string describing the action executed by the current optimization
  109299. * @returns description string
  109300. */
  109301. getDescription(): string;
  109302. /**
  109303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109304. * @param scene defines the current scene where to apply this optimization
  109305. * @param optimizer defines the current optimizer
  109306. * @returns true if everything that can be done was applied
  109307. */
  109308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109309. }
  109310. /**
  109311. * Defines an optimization used to turn particles off
  109312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109313. */
  109314. export class ParticlesOptimization extends SceneOptimization {
  109315. /**
  109316. * Gets a string describing the action executed by the current optimization
  109317. * @return description string
  109318. */
  109319. getDescription(): string;
  109320. /**
  109321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109322. * @param scene defines the current scene where to apply this optimization
  109323. * @param optimizer defines the current optimizer
  109324. * @returns true if everything that can be done was applied
  109325. */
  109326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109327. }
  109328. /**
  109329. * Defines an optimization used to turn render targets off
  109330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109331. */
  109332. export class RenderTargetsOptimization extends SceneOptimization {
  109333. /**
  109334. * Gets a string describing the action executed by the current optimization
  109335. * @return description string
  109336. */
  109337. getDescription(): string;
  109338. /**
  109339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109340. * @param scene defines the current scene where to apply this optimization
  109341. * @param optimizer defines the current optimizer
  109342. * @returns true if everything that can be done was applied
  109343. */
  109344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109345. }
  109346. /**
  109347. * Defines an optimization used to merge meshes with compatible materials
  109348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109349. */
  109350. export class MergeMeshesOptimization extends SceneOptimization {
  109351. private static _UpdateSelectionTree;
  109352. /**
  109353. * Gets or sets a boolean which defines if optimization octree has to be updated
  109354. */
  109355. /**
  109356. * Gets or sets a boolean which defines if optimization octree has to be updated
  109357. */
  109358. static UpdateSelectionTree: boolean;
  109359. /**
  109360. * Gets a string describing the action executed by the current optimization
  109361. * @return description string
  109362. */
  109363. getDescription(): string;
  109364. private _canBeMerged;
  109365. /**
  109366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109367. * @param scene defines the current scene where to apply this optimization
  109368. * @param optimizer defines the current optimizer
  109369. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109370. * @returns true if everything that can be done was applied
  109371. */
  109372. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109373. }
  109374. /**
  109375. * Defines a list of options used by SceneOptimizer
  109376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109377. */
  109378. export class SceneOptimizerOptions {
  109379. /**
  109380. * Defines the target frame rate to reach (60 by default)
  109381. */
  109382. targetFrameRate: number;
  109383. /**
  109384. * Defines the interval between two checkes (2000ms by default)
  109385. */
  109386. trackerDuration: number;
  109387. /**
  109388. * Gets the list of optimizations to apply
  109389. */
  109390. optimizations: SceneOptimization[];
  109391. /**
  109392. * Creates a new list of options used by SceneOptimizer
  109393. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109394. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109395. */
  109396. constructor(
  109397. /**
  109398. * Defines the target frame rate to reach (60 by default)
  109399. */
  109400. targetFrameRate?: number,
  109401. /**
  109402. * Defines the interval between two checkes (2000ms by default)
  109403. */
  109404. trackerDuration?: number);
  109405. /**
  109406. * Add a new optimization
  109407. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109408. * @returns the current SceneOptimizerOptions
  109409. */
  109410. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109411. /**
  109412. * Add a new custom optimization
  109413. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109414. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109416. * @returns the current SceneOptimizerOptions
  109417. */
  109418. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109419. /**
  109420. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109421. * @param targetFrameRate defines the target frame rate (60 by default)
  109422. * @returns a SceneOptimizerOptions object
  109423. */
  109424. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109425. /**
  109426. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109427. * @param targetFrameRate defines the target frame rate (60 by default)
  109428. * @returns a SceneOptimizerOptions object
  109429. */
  109430. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109431. /**
  109432. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109433. * @param targetFrameRate defines the target frame rate (60 by default)
  109434. * @returns a SceneOptimizerOptions object
  109435. */
  109436. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109437. }
  109438. /**
  109439. * Class used to run optimizations in order to reach a target frame rate
  109440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109441. */
  109442. export class SceneOptimizer implements IDisposable {
  109443. private _isRunning;
  109444. private _options;
  109445. private _scene;
  109446. private _currentPriorityLevel;
  109447. private _targetFrameRate;
  109448. private _trackerDuration;
  109449. private _currentFrameRate;
  109450. private _sceneDisposeObserver;
  109451. private _improvementMode;
  109452. /**
  109453. * Defines an observable called when the optimizer reaches the target frame rate
  109454. */
  109455. onSuccessObservable: Observable<SceneOptimizer>;
  109456. /**
  109457. * Defines an observable called when the optimizer enables an optimization
  109458. */
  109459. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109460. /**
  109461. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109462. */
  109463. onFailureObservable: Observable<SceneOptimizer>;
  109464. /**
  109465. * Gets a boolean indicating if the optimizer is in improvement mode
  109466. */
  109467. readonly isInImprovementMode: boolean;
  109468. /**
  109469. * Gets the current priority level (0 at start)
  109470. */
  109471. readonly currentPriorityLevel: number;
  109472. /**
  109473. * Gets the current frame rate checked by the SceneOptimizer
  109474. */
  109475. readonly currentFrameRate: number;
  109476. /**
  109477. * Gets or sets the current target frame rate (60 by default)
  109478. */
  109479. /**
  109480. * Gets or sets the current target frame rate (60 by default)
  109481. */
  109482. targetFrameRate: number;
  109483. /**
  109484. * Gets or sets the current interval between two checks (every 2000ms by default)
  109485. */
  109486. /**
  109487. * Gets or sets the current interval between two checks (every 2000ms by default)
  109488. */
  109489. trackerDuration: number;
  109490. /**
  109491. * Gets the list of active optimizations
  109492. */
  109493. readonly optimizations: SceneOptimization[];
  109494. /**
  109495. * Creates a new SceneOptimizer
  109496. * @param scene defines the scene to work on
  109497. * @param options defines the options to use with the SceneOptimizer
  109498. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109499. * @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)
  109500. */
  109501. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109502. /**
  109503. * Stops the current optimizer
  109504. */
  109505. stop(): void;
  109506. /**
  109507. * Reset the optimizer to initial step (current priority level = 0)
  109508. */
  109509. reset(): void;
  109510. /**
  109511. * Start the optimizer. By default it will try to reach a specific framerate
  109512. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109513. */
  109514. start(): void;
  109515. private _checkCurrentState;
  109516. /**
  109517. * Release all resources
  109518. */
  109519. dispose(): void;
  109520. /**
  109521. * Helper function to create a SceneOptimizer with one single line of code
  109522. * @param scene defines the scene to work on
  109523. * @param options defines the options to use with the SceneOptimizer
  109524. * @param onSuccess defines a callback to call on success
  109525. * @param onFailure defines a callback to call on failure
  109526. * @returns the new SceneOptimizer object
  109527. */
  109528. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109529. }
  109530. }
  109531. declare module BABYLON {
  109532. /**
  109533. * Class used to serialize a scene into a string
  109534. */
  109535. export class SceneSerializer {
  109536. /**
  109537. * Clear cache used by a previous serialization
  109538. */
  109539. static ClearCache(): void;
  109540. /**
  109541. * Serialize a scene into a JSON compatible object
  109542. * @param scene defines the scene to serialize
  109543. * @returns a JSON compatible object
  109544. */
  109545. static Serialize(scene: Scene): any;
  109546. /**
  109547. * Serialize a mesh into a JSON compatible object
  109548. * @param toSerialize defines the mesh to serialize
  109549. * @param withParents defines if parents must be serialized as well
  109550. * @param withChildren defines if children must be serialized as well
  109551. * @returns a JSON compatible object
  109552. */
  109553. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109554. }
  109555. }
  109556. declare module BABYLON {
  109557. /**
  109558. * This represents the different options avilable for the video capture.
  109559. */
  109560. export interface VideoRecorderOptions {
  109561. /** Defines the mime type of the video */
  109562. mimeType: string;
  109563. /** Defines the video the video should be recorded at */
  109564. fps: number;
  109565. /** Defines the chunk size for the recording data */
  109566. recordChunckSize: number;
  109567. }
  109568. /**
  109569. * This can helps recording videos from BabylonJS.
  109570. * This is based on the available WebRTC functionalities of the browser.
  109571. *
  109572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109573. */
  109574. export class VideoRecorder {
  109575. private static readonly _defaultOptions;
  109576. /**
  109577. * Returns wehther or not the VideoRecorder is available in your browser.
  109578. * @param engine Defines the Babylon Engine to check the support for
  109579. * @returns true if supported otherwise false
  109580. */
  109581. static IsSupported(engine: Engine): boolean;
  109582. private readonly _options;
  109583. private _canvas;
  109584. private _mediaRecorder;
  109585. private _recordedChunks;
  109586. private _fileName;
  109587. private _resolve;
  109588. private _reject;
  109589. /**
  109590. * True wether a recording is already in progress.
  109591. */
  109592. readonly isRecording: boolean;
  109593. /**
  109594. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109595. * a video file.
  109596. * @param engine Defines the BabylonJS Engine you wish to record
  109597. * @param options Defines options that can be used to customized the capture
  109598. */
  109599. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109600. /**
  109601. * Stops the current recording before the default capture timeout passed in the startRecording
  109602. * functions.
  109603. */
  109604. stopRecording(): void;
  109605. /**
  109606. * Starts recording the canvas for a max duration specified in parameters.
  109607. * @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.
  109608. * @param maxDuration Defines the maximum recording time in seconds.
  109609. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109610. * @return a promise callback at the end of the recording with the video data in Blob.
  109611. */
  109612. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109613. /**
  109614. * Releases internal resources used during the recording.
  109615. */
  109616. dispose(): void;
  109617. private _handleDataAvailable;
  109618. private _handleError;
  109619. private _handleStop;
  109620. }
  109621. }
  109622. declare module BABYLON {
  109623. /**
  109624. * Helper class to push actions to a pool of workers.
  109625. */
  109626. export class WorkerPool implements IDisposable {
  109627. private _workerInfos;
  109628. private _pendingActions;
  109629. /**
  109630. * Constructor
  109631. * @param workers Array of workers to use for actions
  109632. */
  109633. constructor(workers: Array<Worker>);
  109634. /**
  109635. * Terminates all workers and clears any pending actions.
  109636. */
  109637. dispose(): void;
  109638. /**
  109639. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109640. * pended until a worker has completed its action.
  109641. * @param action The action to perform. Call onComplete when the action is complete.
  109642. */
  109643. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109644. private _execute;
  109645. }
  109646. }
  109647. declare module BABYLON {
  109648. /**
  109649. * Class containing a set of static utilities functions for screenshots
  109650. */
  109651. export class ScreenshotTools {
  109652. /**
  109653. * Captures a screenshot of the current rendering
  109654. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109655. * @param engine defines the rendering engine
  109656. * @param camera defines the source camera
  109657. * @param size This parameter can be set to a single number or to an object with the
  109658. * following (optional) properties: precision, width, height. If a single number is passed,
  109659. * it will be used for both width and height. If an object is passed, the screenshot size
  109660. * will be derived from the parameters. The precision property is a multiplier allowing
  109661. * rendering at a higher or lower resolution
  109662. * @param successCallback defines the callback receives a single parameter which contains the
  109663. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109664. * src parameter of an <img> to display it
  109665. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109666. * Check your browser for supported MIME types
  109667. */
  109668. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109669. /**
  109670. * Generates an image screenshot from the specified camera.
  109671. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109672. * @param engine The engine to use for rendering
  109673. * @param camera The camera to use for rendering
  109674. * @param size This parameter can be set to a single number or to an object with the
  109675. * following (optional) properties: precision, width, height. If a single number is passed,
  109676. * it will be used for both width and height. If an object is passed, the screenshot size
  109677. * will be derived from the parameters. The precision property is a multiplier allowing
  109678. * rendering at a higher or lower resolution
  109679. * @param successCallback The callback receives a single parameter which contains the
  109680. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109681. * src parameter of an <img> to display it
  109682. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109683. * Check your browser for supported MIME types
  109684. * @param samples Texture samples (default: 1)
  109685. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109686. * @param fileName A name for for the downloaded file.
  109687. */
  109688. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109689. }
  109690. }
  109691. declare module BABYLON {
  109692. /**
  109693. * A cursor which tracks a point on a path
  109694. */
  109695. export class PathCursor {
  109696. private path;
  109697. /**
  109698. * Stores path cursor callbacks for when an onchange event is triggered
  109699. */
  109700. private _onchange;
  109701. /**
  109702. * The value of the path cursor
  109703. */
  109704. value: number;
  109705. /**
  109706. * The animation array of the path cursor
  109707. */
  109708. animations: Animation[];
  109709. /**
  109710. * Initializes the path cursor
  109711. * @param path The path to track
  109712. */
  109713. constructor(path: Path2);
  109714. /**
  109715. * Gets the cursor point on the path
  109716. * @returns A point on the path cursor at the cursor location
  109717. */
  109718. getPoint(): Vector3;
  109719. /**
  109720. * Moves the cursor ahead by the step amount
  109721. * @param step The amount to move the cursor forward
  109722. * @returns This path cursor
  109723. */
  109724. moveAhead(step?: number): PathCursor;
  109725. /**
  109726. * Moves the cursor behind by the step amount
  109727. * @param step The amount to move the cursor back
  109728. * @returns This path cursor
  109729. */
  109730. moveBack(step?: number): PathCursor;
  109731. /**
  109732. * Moves the cursor by the step amount
  109733. * If the step amount is greater than one, an exception is thrown
  109734. * @param step The amount to move the cursor
  109735. * @returns This path cursor
  109736. */
  109737. move(step: number): PathCursor;
  109738. /**
  109739. * Ensures that the value is limited between zero and one
  109740. * @returns This path cursor
  109741. */
  109742. private ensureLimits;
  109743. /**
  109744. * Runs onchange callbacks on change (used by the animation engine)
  109745. * @returns This path cursor
  109746. */
  109747. private raiseOnChange;
  109748. /**
  109749. * Executes a function on change
  109750. * @param f A path cursor onchange callback
  109751. * @returns This path cursor
  109752. */
  109753. onchange(f: (cursor: PathCursor) => void): PathCursor;
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. /** @hidden */
  109758. export var blurPixelShader: {
  109759. name: string;
  109760. shader: string;
  109761. };
  109762. }
  109763. declare module BABYLON {
  109764. /** @hidden */
  109765. export var bones300Declaration: {
  109766. name: string;
  109767. shader: string;
  109768. };
  109769. }
  109770. declare module BABYLON {
  109771. /** @hidden */
  109772. export var instances300Declaration: {
  109773. name: string;
  109774. shader: string;
  109775. };
  109776. }
  109777. declare module BABYLON {
  109778. /** @hidden */
  109779. export var pointCloudVertexDeclaration: {
  109780. name: string;
  109781. shader: string;
  109782. };
  109783. }
  109784. // Mixins
  109785. interface Window {
  109786. mozIndexedDB: IDBFactory;
  109787. webkitIndexedDB: IDBFactory;
  109788. msIndexedDB: IDBFactory;
  109789. webkitURL: typeof URL;
  109790. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109791. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109792. WebGLRenderingContext: WebGLRenderingContext;
  109793. MSGesture: MSGesture;
  109794. CANNON: any;
  109795. AudioContext: AudioContext;
  109796. webkitAudioContext: AudioContext;
  109797. PointerEvent: any;
  109798. Math: Math;
  109799. Uint8Array: Uint8ArrayConstructor;
  109800. Float32Array: Float32ArrayConstructor;
  109801. mozURL: typeof URL;
  109802. msURL: typeof URL;
  109803. VRFrameData: any; // WebVR, from specs 1.1
  109804. DracoDecoderModule: any;
  109805. setImmediate(handler: (...args: any[]) => void): number;
  109806. }
  109807. interface Document {
  109808. mozCancelFullScreen(): void;
  109809. msCancelFullScreen(): void;
  109810. webkitCancelFullScreen(): void;
  109811. requestPointerLock(): void;
  109812. exitPointerLock(): void;
  109813. mozFullScreen: boolean;
  109814. msIsFullScreen: boolean;
  109815. readonly webkitIsFullScreen: boolean;
  109816. readonly pointerLockElement: Element;
  109817. mozPointerLockElement: HTMLElement;
  109818. msPointerLockElement: HTMLElement;
  109819. webkitPointerLockElement: HTMLElement;
  109820. }
  109821. interface HTMLCanvasElement {
  109822. requestPointerLock(): void;
  109823. msRequestPointerLock?(): void;
  109824. mozRequestPointerLock?(): void;
  109825. webkitRequestPointerLock?(): void;
  109826. /** Track wether a record is in progress */
  109827. isRecording: boolean;
  109828. /** Capture Stream method defined by some browsers */
  109829. captureStream(fps?: number): MediaStream;
  109830. }
  109831. interface CanvasRenderingContext2D {
  109832. msImageSmoothingEnabled: boolean;
  109833. }
  109834. interface MouseEvent {
  109835. mozMovementX: number;
  109836. mozMovementY: number;
  109837. webkitMovementX: number;
  109838. webkitMovementY: number;
  109839. msMovementX: number;
  109840. msMovementY: number;
  109841. }
  109842. interface Navigator {
  109843. mozGetVRDevices: (any: any) => any;
  109844. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109845. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109846. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109847. webkitGetGamepads(): Gamepad[];
  109848. msGetGamepads(): Gamepad[];
  109849. webkitGamepads(): Gamepad[];
  109850. }
  109851. interface HTMLVideoElement {
  109852. mozSrcObject: any;
  109853. }
  109854. interface Math {
  109855. fround(x: number): number;
  109856. imul(a: number, b: number): number;
  109857. }
  109858. interface WebGLProgram {
  109859. context?: WebGLRenderingContext;
  109860. vertexShader?: WebGLShader;
  109861. fragmentShader?: WebGLShader;
  109862. isParallelCompiled: boolean;
  109863. onCompiled?: () => void;
  109864. }
  109865. interface WebGLRenderingContext {
  109866. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109867. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109868. vertexAttribDivisor(index: number, divisor: number): void;
  109869. createVertexArray(): any;
  109870. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109871. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109872. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109873. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109874. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109875. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109876. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109877. // Queries
  109878. createQuery(): WebGLQuery;
  109879. deleteQuery(query: WebGLQuery): void;
  109880. beginQuery(target: number, query: WebGLQuery): void;
  109881. endQuery(target: number): void;
  109882. getQueryParameter(query: WebGLQuery, pname: number): any;
  109883. getQuery(target: number, pname: number): any;
  109884. MAX_SAMPLES: number;
  109885. RGBA8: number;
  109886. READ_FRAMEBUFFER: number;
  109887. DRAW_FRAMEBUFFER: number;
  109888. UNIFORM_BUFFER: number;
  109889. HALF_FLOAT_OES: number;
  109890. RGBA16F: number;
  109891. RGBA32F: number;
  109892. R32F: number;
  109893. RG32F: number;
  109894. RGB32F: number;
  109895. R16F: number;
  109896. RG16F: number;
  109897. RGB16F: number;
  109898. RED: number;
  109899. RG: number;
  109900. R8: number;
  109901. RG8: number;
  109902. UNSIGNED_INT_24_8: number;
  109903. DEPTH24_STENCIL8: number;
  109904. /* Multiple Render Targets */
  109905. drawBuffers(buffers: number[]): void;
  109906. readBuffer(src: number): void;
  109907. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  109908. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  109909. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  109910. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  109911. // Occlusion Query
  109912. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  109913. ANY_SAMPLES_PASSED: number;
  109914. QUERY_RESULT_AVAILABLE: number;
  109915. QUERY_RESULT: number;
  109916. }
  109917. interface WebGLBuffer {
  109918. references: number;
  109919. capacity: number;
  109920. is32Bits: boolean;
  109921. }
  109922. interface WebGLProgram {
  109923. transformFeedback?: WebGLTransformFeedback | null;
  109924. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  109925. }
  109926. interface EXT_disjoint_timer_query {
  109927. QUERY_COUNTER_BITS_EXT: number;
  109928. TIME_ELAPSED_EXT: number;
  109929. TIMESTAMP_EXT: number;
  109930. GPU_DISJOINT_EXT: number;
  109931. QUERY_RESULT_EXT: number;
  109932. QUERY_RESULT_AVAILABLE_EXT: number;
  109933. queryCounterEXT(query: WebGLQuery, target: number): void;
  109934. createQueryEXT(): WebGLQuery;
  109935. beginQueryEXT(target: number, query: WebGLQuery): void;
  109936. endQueryEXT(target: number): void;
  109937. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  109938. deleteQueryEXT(query: WebGLQuery): void;
  109939. }
  109940. interface WebGLUniformLocation {
  109941. _currentState: any;
  109942. }
  109943. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  109944. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  109945. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  109946. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109947. interface WebGLRenderingContext {
  109948. readonly RASTERIZER_DISCARD: number;
  109949. readonly DEPTH_COMPONENT24: number;
  109950. readonly TEXTURE_3D: number;
  109951. readonly TEXTURE_2D_ARRAY: number;
  109952. readonly TEXTURE_COMPARE_FUNC: number;
  109953. readonly TEXTURE_COMPARE_MODE: number;
  109954. readonly COMPARE_REF_TO_TEXTURE: number;
  109955. readonly TEXTURE_WRAP_R: number;
  109956. readonly HALF_FLOAT: number;
  109957. readonly RGB8: number;
  109958. readonly RED_INTEGER: number;
  109959. readonly RG_INTEGER: number;
  109960. readonly RGB_INTEGER: number;
  109961. readonly RGBA_INTEGER: number;
  109962. readonly R8_SNORM: number;
  109963. readonly RG8_SNORM: number;
  109964. readonly RGB8_SNORM: number;
  109965. readonly RGBA8_SNORM: number;
  109966. readonly R8I: number;
  109967. readonly RG8I: number;
  109968. readonly RGB8I: number;
  109969. readonly RGBA8I: number;
  109970. readonly R8UI: number;
  109971. readonly RG8UI: number;
  109972. readonly RGB8UI: number;
  109973. readonly RGBA8UI: number;
  109974. readonly R16I: number;
  109975. readonly RG16I: number;
  109976. readonly RGB16I: number;
  109977. readonly RGBA16I: number;
  109978. readonly R16UI: number;
  109979. readonly RG16UI: number;
  109980. readonly RGB16UI: number;
  109981. readonly RGBA16UI: number;
  109982. readonly R32I: number;
  109983. readonly RG32I: number;
  109984. readonly RGB32I: number;
  109985. readonly RGBA32I: number;
  109986. readonly R32UI: number;
  109987. readonly RG32UI: number;
  109988. readonly RGB32UI: number;
  109989. readonly RGBA32UI: number;
  109990. readonly RGB10_A2UI: number;
  109991. readonly R11F_G11F_B10F: number;
  109992. readonly RGB9_E5: number;
  109993. readonly RGB10_A2: number;
  109994. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  109995. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  109996. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  109997. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109998. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  109999. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110000. 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;
  110001. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110002. readonly TRANSFORM_FEEDBACK: number;
  110003. readonly INTERLEAVED_ATTRIBS: number;
  110004. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110005. createTransformFeedback(): WebGLTransformFeedback;
  110006. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110007. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110008. beginTransformFeedback(primitiveMode: number): void;
  110009. endTransformFeedback(): void;
  110010. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  110011. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110012. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110013. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110014. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  110015. }
  110016. interface ImageBitmap {
  110017. readonly width: number;
  110018. readonly height: number;
  110019. close(): void;
  110020. }
  110021. interface WebGLQuery extends WebGLObject {
  110022. }
  110023. declare var WebGLQuery: {
  110024. prototype: WebGLQuery;
  110025. new(): WebGLQuery;
  110026. };
  110027. interface WebGLSampler extends WebGLObject {
  110028. }
  110029. declare var WebGLSampler: {
  110030. prototype: WebGLSampler;
  110031. new(): WebGLSampler;
  110032. };
  110033. interface WebGLSync extends WebGLObject {
  110034. }
  110035. declare var WebGLSync: {
  110036. prototype: WebGLSync;
  110037. new(): WebGLSync;
  110038. };
  110039. interface WebGLTransformFeedback extends WebGLObject {
  110040. }
  110041. declare var WebGLTransformFeedback: {
  110042. prototype: WebGLTransformFeedback;
  110043. new(): WebGLTransformFeedback;
  110044. };
  110045. interface WebGLVertexArrayObject extends WebGLObject {
  110046. }
  110047. declare var WebGLVertexArrayObject: {
  110048. prototype: WebGLVertexArrayObject;
  110049. new(): WebGLVertexArrayObject;
  110050. };
  110051. // Type definitions for WebVR API
  110052. // Project: https://w3c.github.io/webvr/
  110053. // Definitions by: six a <https://github.com/lostfictions>
  110054. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110055. interface VRDisplay extends EventTarget {
  110056. /**
  110057. * Dictionary of capabilities describing the VRDisplay.
  110058. */
  110059. readonly capabilities: VRDisplayCapabilities;
  110060. /**
  110061. * z-depth defining the far plane of the eye view frustum
  110062. * enables mapping of values in the render target depth
  110063. * attachment to scene coordinates. Initially set to 10000.0.
  110064. */
  110065. depthFar: number;
  110066. /**
  110067. * z-depth defining the near plane of the eye view frustum
  110068. * enables mapping of values in the render target depth
  110069. * attachment to scene coordinates. Initially set to 0.01.
  110070. */
  110071. depthNear: number;
  110072. /**
  110073. * An identifier for this distinct VRDisplay. Used as an
  110074. * association point in the Gamepad API.
  110075. */
  110076. readonly displayId: number;
  110077. /**
  110078. * A display name, a user-readable name identifying it.
  110079. */
  110080. readonly displayName: string;
  110081. readonly isConnected: boolean;
  110082. readonly isPresenting: boolean;
  110083. /**
  110084. * If this VRDisplay supports room-scale experiences, the optional
  110085. * stage attribute contains details on the room-scale parameters.
  110086. */
  110087. readonly stageParameters: VRStageParameters | null;
  110088. /**
  110089. * Passing the value returned by `requestAnimationFrame` to
  110090. * `cancelAnimationFrame` will unregister the callback.
  110091. * @param handle Define the hanle of the request to cancel
  110092. */
  110093. cancelAnimationFrame(handle: number): void;
  110094. /**
  110095. * Stops presenting to the VRDisplay.
  110096. * @returns a promise to know when it stopped
  110097. */
  110098. exitPresent(): Promise<void>;
  110099. /**
  110100. * Return the current VREyeParameters for the given eye.
  110101. * @param whichEye Define the eye we want the parameter for
  110102. * @returns the eye parameters
  110103. */
  110104. getEyeParameters(whichEye: string): VREyeParameters;
  110105. /**
  110106. * Populates the passed VRFrameData with the information required to render
  110107. * the current frame.
  110108. * @param frameData Define the data structure to populate
  110109. * @returns true if ok otherwise false
  110110. */
  110111. getFrameData(frameData: VRFrameData): boolean;
  110112. /**
  110113. * Get the layers currently being presented.
  110114. * @returns the list of VR layers
  110115. */
  110116. getLayers(): VRLayer[];
  110117. /**
  110118. * Return a VRPose containing the future predicted pose of the VRDisplay
  110119. * when the current frame will be presented. The value returned will not
  110120. * change until JavaScript has returned control to the browser.
  110121. *
  110122. * The VRPose will contain the position, orientation, velocity,
  110123. * and acceleration of each of these properties.
  110124. * @returns the pose object
  110125. */
  110126. getPose(): VRPose;
  110127. /**
  110128. * Return the current instantaneous pose of the VRDisplay, with no
  110129. * prediction applied.
  110130. * @returns the current instantaneous pose
  110131. */
  110132. getImmediatePose(): VRPose;
  110133. /**
  110134. * The callback passed to `requestAnimationFrame` will be called
  110135. * any time a new frame should be rendered. When the VRDisplay is
  110136. * presenting the callback will be called at the native refresh
  110137. * rate of the HMD. When not presenting this function acts
  110138. * identically to how window.requestAnimationFrame acts. Content should
  110139. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110140. * asynchronously from other displays and at differing refresh rates.
  110141. * @param callback Define the eaction to run next frame
  110142. * @returns the request handle it
  110143. */
  110144. requestAnimationFrame(callback: FrameRequestCallback): number;
  110145. /**
  110146. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110147. * Repeat calls while already presenting will update the VRLayers being displayed.
  110148. * @param layers Define the list of layer to present
  110149. * @returns a promise to know when the request has been fulfilled
  110150. */
  110151. requestPresent(layers: VRLayer[]): Promise<void>;
  110152. /**
  110153. * Reset the pose for this display, treating its current position and
  110154. * orientation as the "origin/zero" values. VRPose.position,
  110155. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110156. * updated when calling resetPose(). This should be called in only
  110157. * sitting-space experiences.
  110158. */
  110159. resetPose(): void;
  110160. /**
  110161. * The VRLayer provided to the VRDisplay will be captured and presented
  110162. * in the HMD. Calling this function has the same effect on the source
  110163. * canvas as any other operation that uses its source image, and canvases
  110164. * created without preserveDrawingBuffer set to true will be cleared.
  110165. * @param pose Define the pose to submit
  110166. */
  110167. submitFrame(pose?: VRPose): void;
  110168. }
  110169. declare var VRDisplay: {
  110170. prototype: VRDisplay;
  110171. new(): VRDisplay;
  110172. };
  110173. interface VRLayer {
  110174. leftBounds?: number[] | Float32Array | null;
  110175. rightBounds?: number[] | Float32Array | null;
  110176. source?: HTMLCanvasElement | null;
  110177. }
  110178. interface VRDisplayCapabilities {
  110179. readonly canPresent: boolean;
  110180. readonly hasExternalDisplay: boolean;
  110181. readonly hasOrientation: boolean;
  110182. readonly hasPosition: boolean;
  110183. readonly maxLayers: number;
  110184. }
  110185. interface VREyeParameters {
  110186. /** @deprecated */
  110187. readonly fieldOfView: VRFieldOfView;
  110188. readonly offset: Float32Array;
  110189. readonly renderHeight: number;
  110190. readonly renderWidth: number;
  110191. }
  110192. interface VRFieldOfView {
  110193. readonly downDegrees: number;
  110194. readonly leftDegrees: number;
  110195. readonly rightDegrees: number;
  110196. readonly upDegrees: number;
  110197. }
  110198. interface VRFrameData {
  110199. readonly leftProjectionMatrix: Float32Array;
  110200. readonly leftViewMatrix: Float32Array;
  110201. readonly pose: VRPose;
  110202. readonly rightProjectionMatrix: Float32Array;
  110203. readonly rightViewMatrix: Float32Array;
  110204. readonly timestamp: number;
  110205. }
  110206. interface VRPose {
  110207. readonly angularAcceleration: Float32Array | null;
  110208. readonly angularVelocity: Float32Array | null;
  110209. readonly linearAcceleration: Float32Array | null;
  110210. readonly linearVelocity: Float32Array | null;
  110211. readonly orientation: Float32Array | null;
  110212. readonly position: Float32Array | null;
  110213. readonly timestamp: number;
  110214. }
  110215. interface VRStageParameters {
  110216. sittingToStandingTransform?: Float32Array;
  110217. sizeX?: number;
  110218. sizeY?: number;
  110219. }
  110220. interface Navigator {
  110221. getVRDisplays(): Promise<VRDisplay[]>;
  110222. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110223. }
  110224. interface Window {
  110225. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110226. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110227. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110228. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110229. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110230. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110231. }
  110232. interface Gamepad {
  110233. readonly displayId: number;
  110234. }
  110235. interface XRDevice {
  110236. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110237. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110238. }
  110239. interface XRSession {
  110240. getInputSources(): Array<any>;
  110241. baseLayer: XRWebGLLayer;
  110242. requestFrameOfReference(type: string): Promise<void>;
  110243. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110244. end(): Promise<void>;
  110245. requestAnimationFrame: Function;
  110246. addEventListener: Function;
  110247. }
  110248. interface XRSessionCreationOptions {
  110249. outputContext?: WebGLRenderingContext | null;
  110250. immersive?: boolean;
  110251. environmentIntegration?: boolean;
  110252. }
  110253. interface XRLayer {
  110254. getViewport: Function;
  110255. framebufferWidth: number;
  110256. framebufferHeight: number;
  110257. }
  110258. interface XRView {
  110259. projectionMatrix: Float32Array;
  110260. }
  110261. interface XRFrame {
  110262. getDevicePose: Function;
  110263. getInputPose: Function;
  110264. views: Array<XRView>;
  110265. baseLayer: XRLayer;
  110266. }
  110267. interface XRFrameOfReference {
  110268. }
  110269. interface XRWebGLLayer extends XRLayer {
  110270. framebuffer: WebGLFramebuffer;
  110271. }
  110272. declare var XRWebGLLayer: {
  110273. prototype: XRWebGLLayer;
  110274. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110275. };